public async Task ReturnResponse(IOwinContext context, IIdentityServerRecaptchaOptions options) { var identityServerChallengeResource = new IdentityServerBadRequestChallengeResource { Message = CreateResponseMessage(), ChallengeHtml = _recaptchaPage.CreateHtmlBody() }; await context.ReturnResponse(HttpStatusCode.BadRequest, identityServerChallengeResource); }
public async Task ReturnResponse(IOwinContext context, IIdentityServerRecaptchaOptions options) { await context.ReturnResponse(HttpStatusCode.Unauthorized, new IdentityServerUnauthorizedChallengeResource { ChallengeHtml = _recaptchaPage.CreateHtmlBody(), LinkToChallenge = options.LinkToChallenge, Description = CreateResponseMessage() }, $@"recaptcha url=""{options.LinkToChallenge}"""); }
public static bool SupportsPartialRecaptcha(this IIdentityServerRecaptchaOptions openIdConnectRequestOptions, IOpenIdConnectRequest openIdConnectRequest) { var basicAuthenticationHeaderValue = openIdConnectRequest.GetBasicAuthenticationHeaderValue(); if (string.IsNullOrEmpty(basicAuthenticationHeaderValue)) { return(true); } var basicAuthenticationHeaders = openIdConnectRequestOptions.WebClients.Select(client => Convert.ToBase64String(Encoding.UTF8.GetBytes($"{client.ClientId}:{client.Secret}"))) .Select(authorizationValue => new AuthenticationHeaderValue("Basic", authorizationValue)); return(basicAuthenticationHeaders .Any(authenticationHeaderValue => { return authenticationHeaderValue.ToString() == basicAuthenticationHeaderValue; })); }
private static void UseRequestedChallengeType(this IAppBuilder app, IIdentityServerRecaptchaOptions options) { switch (options.HttpChallengeStatusCode) { case HttpStatusCode.OK: app.UsePerOwinContext <IHttpRecaptchaChallenge>( () => new HttpRecaptchaOkChallenge(new RecaptchaPage(options))); break; case HttpStatusCode.Unauthorized: app.UsePerOwinContext <IHttpRecaptchaChallenge>( () => new HttpRecaptchaUnauthorizedChallenge(new RecaptchaPage(options))); break; default: app.UsePerOwinContext <IHttpRecaptchaChallenge>( () => new HttpRecaptchaBadRequestChallenge(new RecaptchaPage(options))); break; } }
public RecaptchaPage(IIdentityServerRecaptchaOptions options) { _options = options; }