public async Task Metadata_CanBeDeserializedAsMetadata()
        {
            var response = await _client.GetAsync("/wsfederation/metadata");

            var content = await response.Content.ReadAsStreamAsync();

            using (var reader = XmlReader.Create(content))
            {
                var serializer    = new WsFederationMetadataSerializer();
                var configuration = serializer.ReadMetadata(reader);
                Assert.AreEqual("http://localhost/wsfederation", configuration.TokenEndpoint);
            }
        }
Exemplo n.º 2
0
        public async Task Metadata_should_return_metadata_document_with_key_rotation()
        {
            var configuration = new Dictionary <string, string>
            {
                ["IdentityServer:Key:Type"] = "KeysRotation",
                ["Seed"] = "false"
            };
            var sut = TestUtils.CreateTestServer(configurationOverrides: configuration);

            using var client   = sut.CreateClient();
            using var response = await client.GetAsync("/wsfederation/metadata");

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            using var reader = XmlReader.Create(await response.Content.ReadAsStreamAsync().ConfigureAwait(false));
            var serializer = new WsFederationMetadataSerializer();
            var metadata   = serializer.ReadMetadata(reader);

            Assert.NotNull(metadata);
        }
Exemplo n.º 3
0
        public static IssuerSigningKeys GetSigningKeys(string metadataEndpoint, TimeSpan backchannelTimeout, HttpMessageHandler backchannelHttpHandler)
        {
            using (var metadataRequest = new HttpClient(backchannelHttpHandler, false))
            {
                metadataRequest.Timeout = backchannelTimeout;
                using (HttpResponseMessage metadataResponse = metadataRequest.GetAsync(metadataEndpoint).Result)
                {
                    metadataResponse.EnsureSuccessStatusCode();
                    Stream metadataStream = metadataResponse.Content.ReadAsStreamAsync().Result;
                    using (XmlReader metaDataReader = XmlReader.Create(metadataStream, SafeSettings))
                    {
                        var serializer = new WsFederationMetadataSerializer();
                        var wsFederationConfiguration = serializer.ReadMetadata(metaDataReader);

                        return(new IssuerSigningKeys {
                            Issuer = wsFederationConfiguration.Issuer, Keys = wsFederationConfiguration.SigningKeys
                        });
                    }
                }
            }
        }