Esempio n. 1
0
        internal override AuthProviderConfig.Request ToUpdateRequest()
        {
            var req = new OidcProviderConfig.Request()
            {
                DisplayName = this.DisplayName,
                Enabled     = this.Enabled,
                ClientId    = this.ClientId,
                Issuer      = this.Issuer,
            };

            if (req.ClientId == string.Empty)
            {
                throw new ArgumentException("Client ID must not be empty.");
            }

            if (req.Issuer == string.Empty)
            {
                throw new ArgumentException("Issuer must not be empty.");
            }
            else if (req.Issuer != null && !IsWellFormedUriString(req.Issuer))
            {
                throw new ArgumentException($"Malformed issuer string: {req.Issuer}");
            }

            return(req);
        }
Esempio n. 2
0
        internal override AuthProviderConfig.Request ToCreateRequest()
        {
            var req = new OidcProviderConfig.Request()
            {
                DisplayName  = this.DisplayName,
                Enabled      = this.Enabled,
                ClientId     = this.ClientId,
                Issuer       = this.Issuer,
                ClientSecret = this.ClientSecret,
            };

            if (this.CodeResponseType != null || this.IdTokenResponseType != null)
            {
                req.ResponseType = new OidcProviderConfig.ResponseTypeInfo()
                {
                    Code    = this.CodeResponseType,
                    IdToken = this.IdTokenResponseType,
                };
            }

            if (string.IsNullOrEmpty(req.ClientId))
            {
                throw new ArgumentException("Client ID must not be null or empty.");
            }

            if (string.IsNullOrEmpty(req.Issuer))
            {
                throw new ArgumentException("Issuer must not be null or empty.");
            }
            else if (!IsWellFormedUriString(req.Issuer))
            {
                throw new ArgumentException($"Malformed issuer string: {req.Issuer}");
            }

            if (req.ResponseType?.Code == true && string.IsNullOrEmpty(req.ClientSecret))
            {
                throw new ArgumentException("Client secret must not be null or empty for code response type.");
            }

            if (req.ResponseType?.Code == false && req.ResponseType?.IdToken == false)
            {
                throw new ArgumentException("At least one response type must be returned.");
            }

            return(req);
        }
        internal override AuthProviderConfig.Request ToUpdateRequest()
        {
            var req = new OidcProviderConfig.Request()
            {
                DisplayName  = this.DisplayName,
                Enabled      = this.Enabled,
                ClientId     = this.ClientId,
                Issuer       = this.Issuer,
                ClientSecret = this.ClientSecret,
            };

            if (this.CodeResponseType != null || this.IDTokenResponseType != null)
            {
                req.ResponseType = new OidcProviderConfig.ResponseTypeJson()
                {
                    Code    = this.CodeResponseType,
                    IDToken = this.IDTokenResponseType,
                };
            }

            if (req.ClientId == string.Empty)
            {
                throw new ArgumentException("Client ID must not be empty.");
            }

            if (req.Issuer == string.Empty)
            {
                throw new ArgumentException("Issuer must not be empty.");
            }
            else if (req.Issuer != null && !IsWellFormedUriString(req.Issuer))
            {
                throw new ArgumentException($"Malformed issuer string: {req.Issuer}");
            }

            if (req.ResponseType?.Code == true && string.IsNullOrEmpty(req.ClientSecret))
            {
                throw new ArgumentException("Client Secret must not be null or empty for code response type");
            }

            return(req);
        }