示例#1
0
 private void CacheInstanceDiscoveryMetadata(InstanceDiscoveryResponse instanceDiscoveryResponse)
 {
     foreach (InstanceDiscoveryMetadataEntry entry in instanceDiscoveryResponse.Metadata ?? Enumerable.Empty <InstanceDiscoveryMetadataEntry>())
     {
         foreach (string aliasedEnvironment in entry.Aliases ?? Enumerable.Empty <string>())
         {
             _networkCacheMetadataProvider.AddMetadata(aliasedEnvironment, entry);
         }
     }
 }
 public InstanceDiscoveryManager(
     IHttpManager httpManager,
     bool /* for test */ shouldClearCaches,
     InstanceDiscoveryResponse userProvidedInstanceDiscoveryResponse = null,
     Uri userProvidedInstanceDiscoveryUri = null) :
     this(
         httpManager,
         shouldClearCaches,
         userProvidedInstanceDiscoveryResponse != null ? new UserMetadataProvider(userProvidedInstanceDiscoveryResponse) : null,
         userProvidedInstanceDiscoveryUri,
         null, null, null, null)
 {
 }
示例#3
0
        private async Task <InstanceDiscoveryResponse> SendInstanceDiscoveryRequestAsync(
            Uri authority,
            RequestContext requestContext)
        {
            var client = new OAuth2Client(requestContext.Logger, _httpManager, _telemetryManager);

            client.AddQueryParameter("api-version", "1.1");
            client.AddQueryParameter("authorization_endpoint", BuildAuthorizeEndpoint(authority));

            Uri instanceDiscoveryEndpoint = ComputeHttpEndpoint(authority, requestContext);

            InstanceDiscoveryResponse discoveryResponse = await client
                                                          .DiscoverAadInstanceAsync(instanceDiscoveryEndpoint, requestContext)
                                                          .ConfigureAwait(false);

            return(discoveryResponse);
        }
        private async Task <InstanceDiscoveryResponse> SendInstanceDiscoveryRequestAsync(
            Uri authority,
            RequestContext requestContext)
        {
            var client = new OAuth2Client(requestContext.Logger, _httpManager, _telemetryManager);

            client.AddQueryParameter("api-version", "1.1");
            client.AddQueryParameter("authorization_endpoint", BuildAuthorizeEndpoint(authority.Host, GetTenant(authority)));

            string discoveryHost = KnownMetadataProvider.IsKnownEnvironment(authority.Host) ?
                                   authority.Host :
                                   AadAuthority.DefaultTrustedHost;

            string instanceDiscoveryEndpoint = BuildInstanceDiscoveryEndpoint(discoveryHost);

            InstanceDiscoveryResponse discoveryResponse = await client
                                                          .DiscoverAadInstanceAsync(new Uri(instanceDiscoveryEndpoint), requestContext)
                                                          .ConfigureAwait(false);

            return(discoveryResponse);
        }