Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new parameter skipCertValidation #421

Merged
merged 6 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ To avoid providing credentials with every command, you can login once. Currently

> Warning! Using this feature will store your login credentials on disk in plain text.

> To skip certificate validation connecting to On-Prem Azure DevOps Server you can use parameter `--skip-cert-validation`

#### Personal access token

Start by [creating a personal access token](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online) and paste it into the login command.
Expand Down
6 changes: 5 additions & 1 deletion app/exec/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ export class Login extends TfCommand<CoreArguments, LoginResult> {
public async exec(): Promise<LoginResult> {
trace.debug("Login.exec");
return this.commandArgs.serviceUrl.val().then(async collectionUrl => {
const skipCertValidation = await this.commandArgs.skipCertValidation.val(false);

const authHandler = await this.getCredentials(collectionUrl, false);
const webApi = await this.getWebApi();
const webApi = await this.getWebApi({
ignoreSslError: skipCertValidation
});
const locationsApi = await webApi.getLocationsApi();

try {
Expand Down
15 changes: 12 additions & 3 deletions app/lib/tfcommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import fsUtils = require("./fsUtils");
import { promisify } from "util";
import trace = require("./trace");
import version = require("./version");
import { IRequestOptions } from "azure-devops-node-api/interfaces/common/VsoBaseInterfaces";

export interface CoreArguments {
[key: string]: args.Argument<any>;
Expand All @@ -37,6 +38,7 @@ export interface CoreArguments {
noPrompt: args.BooleanArgument;
noColor: args.BooleanArgument;
debugLogStream: args.StringArgument;
skipCertValidation: args.BooleanArgument;
}

export interface Executor<TResult> {
Expand Down Expand Up @@ -334,6 +336,13 @@ export abstract class TfCommand<TArguments extends CoreArguments, TResult> {
args.StringArgument,
"stdout",
);
this.registerCommandArgument(
"skipCertValidation",
"Skip Certificate Validation",
"Skip certificate validation during login",
args.BooleanArgument,
"false",
);
}

/**
Expand Down Expand Up @@ -409,11 +418,11 @@ export abstract class TfCommand<TArguments extends CoreArguments, TResult> {
});
}

public getWebApi(): Promise<WebApi> {
public getWebApi(options?: IRequestOptions): Promise<WebApi> {
return this.commandArgs.serviceUrl.val().then(url => {
return this.getCredentials(url).then(handler => {
this.connection = new TfsConnection(url);
this.webApi = new WebApi(url, handler);
this.webApi = new WebApi(url, handler, options);
return this.webApi;
});
});
Expand Down Expand Up @@ -549,7 +558,7 @@ export abstract class TfCommand<TArguments extends CoreArguments, TResult> {

if (this.serverCommand) {
result += eol + cyan("Global server command arguments:") + eol;
["authType", "username", "password", "token", "serviceUrl", "fiddler", "proxy"].forEach(arg => {
["authType", "username", "password", "token", "serviceUrl", "fiddler", "proxy", "skipCertValidation"].forEach(arg => {
result += singleArgData(arg, 11);
});
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tfx-cli",
"version": "0.12.0",
"version": "0.13.0",
"description": "CLI for Azure DevOps Services and Team Foundation Server",
"repository": {
"type": "git",
Expand Down