1
0
Форкнуть 0
This commit is contained in:
Jessica Schumaker 2019-01-03 16:07:49 -05:00
Родитель fc3bebd379
Коммит 03861a9e2e
5 изменённых файлов: 22 добавлений и 15 удалений

Просмотреть файл

@ -33,16 +33,13 @@ namespace AzureDevOps.Authentication
public sealed class MsaAuthentication : Authentication, IMsaAuthentication public sealed class MsaAuthentication : Authentication, IMsaAuthentication
{ {
public const string DefaultAuthorityHost = AzureDevOps.Authentication.Authority.AuthorityHostUrlBase + "/live.com";
internal const string QueryParameters = "domain_hint=live.com&display=popup&site_id=501454&nux=1";
public MsaAuthentication( public MsaAuthentication(
RuntimeContext context, RuntimeContext context,
TokenScope tokenScope, TokenScope tokenScope,
ICredentialStore personalAccessTokenStore) ICredentialStore personalAccessTokenStore)
: base(context, tokenScope, personalAccessTokenStore) : base(context, tokenScope, personalAccessTokenStore)
{ {
Authority = new Authority(context, DefaultAuthorityHost); Authority = new Authority(context, AzureDevOps.Authentication.Authority.DefaultAuthorityHostUrl);
} }
/// <summary> /// <summary>
@ -79,7 +76,12 @@ namespace AzureDevOps.Authentication
try try
{ {
Token token; Token token;
if ((token = await Authority.InteractiveAcquireToken(targetUri, ClientId, Resource, new Uri(RedirectUrl), QueryParameters)) != null) if ((token = await Authority.InteractiveAcquireToken(
targetUri,
ClientId,
Resource,
new Uri(RedirectUrl),
queryParameters: null)) != null)
{ {
Trace.WriteLine($"token '{targetUri}' successfully acquired."); Trace.WriteLine($"token '{targetUri}' successfully acquired.");
@ -109,7 +111,12 @@ namespace AzureDevOps.Authentication
try try
{ {
Token token; Token token;
if ((token = await Authority.InteractiveAcquireToken(targetUri, ClientId, Resource, new Uri(RedirectUrl), QueryParameters)) != null) if ((token = await Authority.InteractiveAcquireToken(
targetUri,
ClientId,
Resource,
new Uri(RedirectUrl),
queryParameters: null)) != null)
{ {
Trace.WriteLine($"token '{targetUri}' successfully acquired."); Trace.WriteLine($"token '{targetUri}' successfully acquired.");

Просмотреть файл

@ -109,7 +109,7 @@ namespace AzureDevOps.Authentication.Test
{ {
ICredentialStore tokenStore1 = new SecretCache(context, @namespace + 1, Secret.UriToIdentityUrl); ICredentialStore tokenStore1 = new SecretCache(context, @namespace + 1, Secret.UriToIdentityUrl);
ITokenStore tokenStore2 = new SecretCache(context, @namespace + 2, Secret.UriToIdentityUrl); ITokenStore tokenStore2 = new SecretCache(context, @namespace + 2, Secret.UriToIdentityUrl);
IAuthority liveAuthority = new AuthorityFake(MsaAuthentication.QueryParameters); IAuthority liveAuthority = new AuthorityFake(null);
return new MsaAuthentication(context, tokenStore1, tokenStore2, liveAuthority); return new MsaAuthentication(context, tokenStore1, tokenStore2, liveAuthority);
} }
} }

Просмотреть файл

@ -3231,17 +3231,17 @@
"Adal": { "Adal": {
"Operations": [ "Operations": [
{ {
"AuthorityUrl": "https://login.microsoftonline.com/live.com", "AuthorityUrl": "https://login.microsoftonline.com/common",
"Error": {}, "Error": {},
"Input": { "Input": {
"ClientId": "872cd9fa-d31f-45e0-9eab-6e460a02d1f1", "ClientId": "872cd9fa-d31f-45e0-9eab-6e460a02d1f1",
"ExtraQueryParameters": "domain_hint=live.com&display=popup&site_id=501454&nux=1", "ExtraQueryParameters": "",
"Resource": "499b84ac-1321-427f-aa17-267ca6975798", "Resource": "499b84ac-1321-427f-aa17-267ca6975798",
"RedirectUrl": "urn:ietf:wg:oauth:2.0:oob" "RedirectUrl": "urn:ietf:wg:oauth:2.0:oob"
}, },
"Result": { "Result": {
"AccessToken": "Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token", "AccessToken": "Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token",
"Authority": "https://login.microsoftonline.com/live.com/", "Authority": "https://login.microsoftonline.com/common/",
"TokenType": "Bearer", "TokenType": "Bearer",
"TenantId": "9cd80435-793b-4f48-844b-6b3f37d1c1f3" "TenantId": "9cd80435-793b-4f48-844b-6b3f37d1c1f3"
} }

Просмотреть файл

@ -3005,7 +3005,7 @@
"Adal": { "Adal": {
"Operations": [ "Operations": [
{ {
"AuthorityUrl": "https://login.microsoftonline.com/live.com", "AuthorityUrl": "https://login.microsoftonline.com/common",
"Error": { "Error": {
"Message": "User canceled authentication" "Message": "User canceled authentication"
}, },
@ -3013,7 +3013,7 @@
"Resource": "499b84ac-1321-427f-aa17-267ca6975798", "Resource": "499b84ac-1321-427f-aa17-267ca6975798",
"ClientId": "872cd9fa-d31f-45e0-9eab-6e460a02d1f1", "ClientId": "872cd9fa-d31f-45e0-9eab-6e460a02d1f1",
"RedirectUrl": "urn:ietf:wg:oauth:2.0:oob", "RedirectUrl": "urn:ietf:wg:oauth:2.0:oob",
"ExtraQueryParameters": "domain_hint=live.com&display=popup&site_id=501454&nux=1" "ExtraQueryParameters": ""
}, },
"Result": {} "Result": {}
} }

Просмотреть файл

@ -3670,17 +3670,17 @@
"Adal": { "Adal": {
"Operations": [ "Operations": [
{ {
"AuthorityUrl": "https://login.microsoftonline.com/live.com", "AuthorityUrl": "https://login.microsoftonline.com/common",
"Error": {}, "Error": {},
"Input": { "Input": {
"ClientId": "872cd9fa-d31f-45e0-9eab-6e460a02d1f1", "ClientId": "872cd9fa-d31f-45e0-9eab-6e460a02d1f1",
"ExtraQueryParameters": "domain_hint=live.com&display=popup&site_id=501454&nux=1", "ExtraQueryParameters": "",
"Resource": "499b84ac-1321-427f-aa17-267ca6975798", "Resource": "499b84ac-1321-427f-aa17-267ca6975798",
"RedirectUrl": "urn:ietf:wg:oauth:2.0:oob" "RedirectUrl": "urn:ietf:wg:oauth:2.0:oob"
}, },
"Result": { "Result": {
"AccessToken": "Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token", "AccessToken": "Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token;Fake+Token",
"Authority": "https://login.microsoftonline.com/live.com/", "Authority": "https://login.microsoftonline.com/common/",
"TokenType": "Bearer", "TokenType": "Bearer",
"TenantId": "9cd80435-793b-4f48-844b-6b3f37d1c1f3" "TenantId": "9cd80435-793b-4f48-844b-6b3f37d1c1f3"
} }