Example #1
0
        /// <summary>
        /// Is Valid OIDC Authentication Request.
        /// </summary>
        public static void Validate(this AuthenticationRequest request, bool isImplicitFlow = false)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            (request as AuthorizationRequest).Validate();

            if (request.Scope.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(request.Scope), request.GetTypeName());
            }
            if (isImplicitFlow && request.Nonce.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(request.Nonce), request.GetTypeName());
            }

            request.ResponseMode.ValidateMaxLength(IdentityConstants.MessageLength.ResponseModeMax, nameof(request.ResponseMode), request.GetTypeName());
            request.Nonce.ValidateMaxLength(IdentityConstants.MessageLength.NonceMax, nameof(request.Nonce), request.GetTypeName());
            request.Display.ValidateMaxLength(IdentityConstants.MessageLength.DisplayMax, nameof(request.Display), request.GetTypeName());
            request.Prompt.ValidateMaxLength(IdentityConstants.MessageLength.PromptMax, nameof(request.Prompt), request.GetTypeName());
            request.UiLocales.ValidateMaxLength(IdentityConstants.MessageLength.UiLocalesMax, nameof(request.UiLocales), request.GetTypeName());
            request.IdTokenHint.ValidateMaxLength(IdentityConstants.MessageLength.IdTokenMax, nameof(request.IdTokenHint), request.GetTypeName());
            request.LoginHint.ValidateMaxLength(IdentityConstants.MessageLength.LoginHintMax, nameof(request.LoginHint), request.GetTypeName());
            request.AcrValues.ValidateMaxLength(IdentityConstants.MessageLength.AcrValuesMax, nameof(request.AcrValues), request.GetTypeName());
        }