Exemple #1
0
        public override async Task ValidateClientRedirectUri(ValidateClientRedirectUriContext context)
        {
            var database = context.HttpContext.RequestServices.GetRequiredService <ApplicationContext>();

            // Retrieve the application details corresponding to the requested client_id.
            var application = await(from entity in database.Applications
                                    where entity.ApplicationID == context.ClientId
                                    select entity).SingleOrDefaultAsync(context.HttpContext.RequestAborted);

            if (application == null)
            {
                context.Rejected(
                    error: "invalid_client",
                    description: "Application not found in the database: ensure that your client_id is correct");

                return;
            }

            if (!string.IsNullOrEmpty(context.RedirectUri))
            {
                if (!string.Equals(context.RedirectUri, application.RedirectUri, StringComparison.Ordinal))
                {
                    context.Rejected(error: "invalid_client", description: "Invalid redirect_uri");

                    return;
                }
            }

            context.Validated(application.RedirectUri);
        }
Exemple #2
0
        /// <summary>
        /// Validate wether the redirect uri is valid for the specific client .
        /// </summary>
        public override async Task ValidateClientRedirectUri(ValidateClientRedirectUriContext context)
        {
            var query  = new ClientRedirectUriValidator(context.ClientId, context.RedirectUri);
            var result = await ExecuteMessage(context, query);

            if (!result.Succeeded)
            {
                context.Rejected(
                    error: "invalid_client",
                    description: "Invalid redirect uri");

                return;
            }

            context.Validated();
        }