public virtual void ProcessRequest(HttpContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var state = ReadStateQueryParameter(context); if (!(GetValue(context, state, AuthServiceProvider.ProviderParameter) is string providerName)) { return; } AuthenticationElement authenticationElement = GetAuthenticationElement(); AuthServiceProvider provider = GetServiceProvider(providerName); if (provider == null) { return; } AuthLoginOptions loginOptions = ConvertUtilities.ChangeType(GetValue(context, state, AuthServiceProvider.OptionsParameter), AuthLoginOptions.None); int attempt = 0; UserData userData = null; while (attempt < authenticationElement.MaximumRetryCount) { try { userData = provider.GetUserData(context); break; } catch (Exception ex) { if (!OnGetUserDataError(context, ex, attempt)) { break; } attempt++; if (authenticationElement.RetryInterval > 0) { Thread.Sleep(authenticationElement.RetryInterval); } } } if (userData == null) { Authenticate(context, provider, loginOptions); } else { Authenticate(context, provider, loginOptions, userData); } }
protected virtual void RedirectSuccess(HttpContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } string url = null; var state = ReadStateQueryParameter(context); if (state != null && state.ContainsKey(AuthServiceProvider.UrlParameter)) { url = state[AuthServiceProvider.UrlParameter] as string; } else { url = context.Request[AuthServiceProvider.UrlParameter].Nullify(trim: true); } if (string.IsNullOrEmpty(url)) { string providerName = GetValue(context, state, AuthServiceProvider.ProviderParameter) as string; if (providerName != null) { AuthenticationElement authenticationElement = GetAuthenticationElement(); AuthServiceProvider provider = GetServiceProvider(providerName); if (provider != null) { url = provider.SuccessUrl; } } } if (string.IsNullOrEmpty(url)) { url = AuthServiceProvider.GetAbsoluteApplicationPath(); } url = HttpUtility.UrlDecode(url); context.Response.Redirect(url, false); }
protected virtual bool Authenticate(HttpContext context, AuthServiceProvider provider, AuthLoginOptions options, UserData userData) { return(true); }