public string CreateHtmlBody(IOpenIdConnectRequest openIdConnectRequest) { var languageCode = openIdConnectRequest.GetLanguage(); if (string.IsNullOrEmpty(languageCode)) { languageCode = DefaultLanguageCode; } return(_options.SupportsPartialRecaptcha(openIdConnectRequest) ? CreatePartialHtmlBody(languageCode, openIdConnectRequest.GetDevice()) : CreateFullHtmlBody(languageCode, openIdConnectRequest.GetDevice())); }
public static bool IsExcluded(this IOpenIdConnectRequestOptions options, IOpenIdConnectRequest openIdConnectRequest) { var username = openIdConnectRequest.GetUsername(); if (!string.IsNullOrEmpty(username) && options.ExcludedUsernameExpression != null && options.ExcludedUsernameExpression.IsMatch(username)) { return(true); } var tenant = openIdConnectRequest.GetTenant(); if (!string.IsNullOrEmpty(tenant) && options.ExcludedTenantExpression != null && options.ExcludedTenantExpression.IsMatch(tenant)) { return(true); } var osVersion = openIdConnectRequest.GetOsVersion(); if (!string.IsNullOrEmpty(osVersion) && options.ExcludedOsVersionExpression != null && options.ExcludedOsVersionExpression.IsMatch(osVersion)) { return(true); } var device = openIdConnectRequest.GetDevice(); if (!string.IsNullOrEmpty(device?.DeviceType) && options.ExcludedDeviceExpression != null && options.ExcludedDeviceExpression.IsMatch(device.DeviceType)) { return(true); } return(options.ExcludedSubnets.Any(excludedSubnet => excludedSubnet.Contains(openIdConnectRequest.GetRemoteIpAddress()))); }
public static RecaptchaUserContext ToRecaptchaUserContext(this IOpenIdConnectRequest request) { if (request == null) { return(new RecaptchaUserContext()); } var device = request.GetDevice(); return(new RecaptchaUserContext { Username = request.GetUsername(), UserAgent = request.GetUserAgent(), Device = new RecaptchaUserDevice { Id = device?.DeviceId, Name = device?.DeviceName, Token = device?.DeviceToken, Type = device?.DeviceType }, IpAddress = request.GetRemoteIpAddress().ToString(), Tenant = request.GetTenant() }); }