public void GetProviderMetadata()
        {
            string             hostname = GetBaseUrl("/");
            OpenIdRelyingParty rp       = new OpenIdRelyingParty();

            providerMetadata = rp.ObtainProviderInformation(hostname);
        }
Exemplo n.º 2
0
        public void Obtain_Provider_Information()
        {
            // given
            rpid   = "rp-discovery-openid_configuration";
            claims = "normal";
            string             hostname = GetBaseUrl("/");
            OpenIdRelyingParty rp       = new OpenIdRelyingParty();

            // when
            OIDCProviderMetadata response = rp.ObtainProviderInformation(hostname);

            // then
            response.validate();
        }
Exemplo n.º 3
0
        public void Reject_Wrong_Discovered_Issuer()
        {
            // given
            rpid   = "rp-discovery-issuer_not_matching_config";
            claims = "_";
            string             hostname = GetBaseUrl("/");
            string             userid   = "https://rp.certification.openid.net:8080/" + rpid;
            OpenIdRelyingParty rp       = new OpenIdRelyingParty();
            string             issuer   = rp.ObtainIssuerFromURL(userid, baseurl.ToString());

            // when
            OIDCProviderMetadata response = rp.ObtainProviderInformation(hostname, issuer);

            // then
        }
Exemplo n.º 4
0
        public void Can_Discover_OpenID_Providers_With_JWKS_Json()
        {
            // given
            rpid   = "rp-discovery-jwks_uri_keys";
            claims = "normal";
            string             hostname = GetBaseUrl("/");
            OpenIdRelyingParty rp       = new OpenIdRelyingParty();

            // when
            OIDCProviderMetadata response = rp.ObtainProviderInformation(hostname);

            // then
            response.validate();
            Assert.NotNull(response.JwksUri);
            Assert.NotNull(response.Keys);
            Assert.Greater(response.Keys.Count, 0);
        }
Exemplo n.º 5
0
        public void Should_Obtain_Provider_Information_With_JWKS_Json()
        {
            rpid = "rp-discovery-jwks_uri_keys";

            // given
            string             hostname = GetBaseUrl("/");
            OpenIdRelyingParty rp       = new OpenIdRelyingParty();

            // when
            OIDCProviderMetadata response = rp.ObtainProviderInformation(hostname);

            // then
            response.Validate();

            Assert.IsNotNull(response.Keys);
            Assert.Greater(response.Keys.Count, 0);
        }
        private void LoadOPInformation(OpenIDProviderElement opEntry)
        {
            Sign    = opEntry.Sign;
            Encrypt = opEntry.Encrypt;

            if (!String.IsNullOrEmpty(opEntry.OPIssuer))
            {
                OpenIdRelyingParty rp = new OpenIdRelyingParty();
                ProviderMatadata = rp.ObtainProviderInformation(opEntry.OPIssuer, opEntry.OPIssuer);
            }
            else
            {
                foreach (string value in new List <string>()
                {
                    opEntry.AuthorizationEndpoint, opEntry.TokenEndpoint, opEntry.UserinfoEndpoint
                })
                {
                    if (string.IsNullOrEmpty(value))
                    {
                        throw new ArgumentException("Missign one requred value for configuration. When configuring rp without isser discovery, all these fields must be specified: authorizationEndpoint, tokenEndpoint, userinfoEndpoint.");
                    }
                }

                ProviderMatadata = new OIDCProviderMetadata()
                {
                    AuthorizationEndpoint = opEntry.AuthorizationEndpoint,
                    TokenEndpoint         = opEntry.TokenEndpoint,
                    UserinfoEndpoint      = opEntry.UserinfoEndpoint,
                };

                if (!string.IsNullOrEmpty(opEntry.RegistrationEndpoint))
                {
                    ProviderMatadata.RegistrationEndpoint = opEntry.RegistrationEndpoint;
                }
            }
        }
        private void LoadOPInformation(OpenIDProviderElement opEntry)
        {
            Sign = opEntry.Sign;
            Encrypt = opEntry.Encrypt;

            if (!String.IsNullOrEmpty(opEntry.OPIssuer))
            {
                OpenIdRelyingParty rp = new OpenIdRelyingParty();
                ProviderMatadata = rp.ObtainProviderInformation(opEntry.OPIssuer, opEntry.OPIssuer);
            }
            else
            {
                foreach (string value in new List<string>() { opEntry.AuthorizationEndpoint, opEntry.TokenEndpoint, opEntry.UserinfoEndpoint })
                {
                    if (string.IsNullOrEmpty(value))
                    {
                        throw new ArgumentException("Missign one requred value for configuration. When configuring rp without isser discovery, all these fields must be specified: authorizationEndpoint, tokenEndpoint, userinfoEndpoint.");
                    }
                }

                ProviderMatadata = new OIDCProviderMetadata()
                {
                    AuthorizationEndpoint = opEntry.AuthorizationEndpoint,
                    TokenEndpoint = opEntry.TokenEndpoint,
                    UserinfoEndpoint = opEntry.UserinfoEndpoint,
                };

                if (!string.IsNullOrEmpty(opEntry.RegistrationEndpoint))
                {
                    ProviderMatadata.RegistrationEndpoint = opEntry.RegistrationEndpoint;
                }
            }
        }