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

Add support for token based auth to services other than VSTS #6440

Merged
merged 1 commit into from
Feb 21, 2018

Conversation

keithrob
Copy link
Contributor

No description provided.

@keithrob keithrob requested a review from jotaylo February 15, 2018 01:46
let lineEnd = os.EOL;
let nerfed = util.toNerfDart(url);
let password64 = (new Buffer(password).toString('base64'));
console.log("##vso[task.setvariable variable=" + endpointId + "BASE64_PASSWORD;issecret=true;]" + password64);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping this console.log is important, it basically says "this string is a password, obfuscate it in any logging"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -36,6 +40,12 @@ export class NpmRegistry implements INpmRegistry {

try {
url = NormalizeRegistry(tl.getEndpointUrl(endpointId, false));
if (endpointAuth.scheme === 'Token' &&
URL.parse(url).hostname.toUpperCase().endsWith('.VISUALSTUDIO.COM')){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this. I suggest renaming the auth type of the endpoint back to 'external VSTS/TFS', and adding a third 'authToken' option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that; however, I don't like the additional complexity/choices that a user would now need to make. The root of the problem, IMO, is that we don't have a JWT generator that has the same capabilities as the PAT generator under security settings. A JWT would work with _authToken a PAT; however, does not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two options:

  1. Add a third endpoint type specific to VSTS, so we have Basic, AuthToken (bearer), and VSTS PAT.
  2. Make the current AuthToken to use bearerToken only and update our guidance for current VSTS customers to use the Basic type and put whatever in the username field.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 would break existing users

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, forgot to add that 1 would make AuthToken bearer only, which would break existing users as well. This seems like the best option to keep existing users working without having to bump the major version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, this is the best approach as it it the least impact on the front-end decision process while taking advantage of the information we have to "do the right thing".

if (endpointAuth.scheme === 'Token' &&
URL.parse(url).hostname.toUpperCase().endsWith('.VISUALSTUDIO.COM')){
// VSTS does not support a PAT in _authToken. Therefore, you must do basic.
endpointAuth.scheme = 'CrossAccount';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, but would be better to treat endpointAuth as immutable and not set a scheme type that it doesn't really support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pspill, @aldoms , code has been adjusted.

@aldoms
Copy link
Contributor

aldoms commented Feb 15, 2018

I would also add some unit tests for the FromServiceEndpoint() method in order to avoid regressions in the future.

@keithrob keithrob force-pushed the users/kerobert/fixTokenAuth branch 3 times, most recently from 8fee658 to cd66a16 Compare February 19, 2018 17:34
@keithrob
Copy link
Contributor Author

@aldoms, tests added.

@keithrob keithrob force-pushed the users/kerobert/fixTokenAuth branch from cd66a16 to 203e9c8 Compare February 19, 2018 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants