示例#1
0
        /// <inheritdoc/>
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> results = new List <ValidationResult>
            {
                ScopeValidation.ScopeValidate(this.Scope),
            };

            return(results);
        }
示例#2
0
        /// <inheritdoc/>
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> results = new List <ValidationResult>
            {
                ScopeValidation.ScopeValidate(this.Scope),
            };

            if (this.CodeChallengeMethod != CodeChallengeMethods.None && string.IsNullOrEmpty(this.CodeChallenge))
            {
                results.Add(new ValidationResult($"{nameof(this.CodeChallenge)} is not valid: You're using code_challenge_method='{CommonAuthentication.ParseCodeChallengeMethod(this.CodeChallengeMethod)}' but no code_challenge is present"));
            }

            if (this.CodeChallengeMethod != CodeChallengeMethods.None && string.IsNullOrEmpty(this.CodeVerifier))
            {
                results.Add(new ValidationResult($"{nameof(this.CodeVerifier)} is not valid: You're using code_challenge_method='{CommonAuthentication.ParseCodeChallengeMethod(this.CodeChallengeMethod)}' but no code_verifier is present"));
            }

            if (this.ResponseType == ResponseTypes.IdToken && this.ResponseType == ResponseTypes.TokenAndIdToken && string.IsNullOrEmpty(this.Nonce))
            {
                results.Add(new ValidationResult($"{nameof(this.Nonce)} is not valid: Nonce is required when using Implicit Grant (id_token or token id_token response types)"));
            }

            return(results);
        }