예제 #1
0
        private IAccount GetAccount(JsonWebToken token)
        {
            token.AssertNotNull(nameof(token));

            token.TryGetClaim("upn", out Claim claim);

            if (claim != null)
            {
                ServiceClientTracing.Information($"[AccessTokenAuthenticator] The UPN claim value is {claim.Value}");
                ServiceClientTracing.Information($"[AccessTokenAuthenticator] Constructing the resource account value based on specified access token");

                return(new ResourceAccount(
                           "login.microsoftonline.com",
                           $"{token.GetClaim("oid").Value}.{token.GetClaim("tid")}",
                           token.GetClaim("oid").Value,
                           token.GetClaim("tid").Value,
                           claim.Value));
            }

            ServiceClientTracing.Information("[AccessTokenAuthenticator] The UPN claim is not present in the access token.");
            return(null);
        }