public ActionResult Process(HttpContextBase context, AuthenticateCallbackData model) { return new ViewResult { ViewName = "AuthenticateCallback", ViewData = new ViewDataDictionary(model) }; }
public ActionResult Process(HttpContextBase context, AuthenticateCallbackData model) { return new ViewResult { ViewName = "AuthenticateCallback", ViewData = new ViewDataDictionary(new AuthenticateCallbackViewModel { AuthenticatedClient = model.AuthenticatedClient, Exception = model.Exception }) }; }
public ActionResult AuthenticateCallback(string providerkey) { if (string.IsNullOrEmpty(providerkey)) { throw new ArgumentException("No provider key was supplied on the callback."); } // Determine which settings we need, based on the Provider. var settings = AuthenticationService.GetAuthenticateServiceSettings(providerkey, Request.Url, Url.CallbackFromOAuthProvider()); // Pull the "ToKeep" token from the cookie and the "ToSend" token from the query string var keptToken = DeserializeToken(Request); var recievedToken = Request.QueryString["state"]; if (string.IsNullOrEmpty(recievedToken)) { throw new InvalidOperationException( "No state/recievedToken was retrieved from the provider. Are you sure you passed any state/token data to provider .. and .. that the provider can send it back to us? We need this to prevent any Cross site request forgery."); } // Validate the token against the recieved one and grab extra data string extraData = _antiForgery.ValidateToken(keptToken, recievedToken); var model = new AuthenticateCallbackData(); try { // Grab the authenticated client information. model.AuthenticatedClient = AuthenticationService.GetAuthenticatedClient(settings, Request.QueryString); } catch (Exception exception) { model.Exception = exception; } // If we have a redirect Url, lets grab this :) // NOTE: We've implimented the extraData part of the tokenData as the redirect url. if (!string.IsNullOrEmpty(extraData)) { model.RedirectUrl = new Uri(extraData); } // Finally! We can hand over the logic to the consumer to do whatever they want. return(CallbackProvider.Process(HttpContext, model)); }
//authentication/redirect public ActionResult AuthenticateCallback(string providerkey) { if (string.IsNullOrEmpty(providerkey)) { throw new ArgumentException("No provider key was supplied on the callback."); } var existingState = (Session[StateKey] as string) ?? string.Empty; var model = new AuthenticateCallbackData(); try { model.AuthenticatedClient = _authenticationService.GetAuthenticatedClient(providerkey, Request.QueryString, existingState); } catch (Exception exception) { model.Exception = exception; } return _callbackProvider.Process(HttpContext, model); }
public ActionResult AuthenticateCallback(string providerkey) { if (string.IsNullOrEmpty(providerkey)) { throw new ArgumentException("No provider key was supplied on the callback."); } // Determine which settings we need, based on the Provider. var settings = AuthenticationService.GetAuthenticateServiceSettings(providerkey, Request.Url, Url.CallbackFromOAuthProvider()); // Pull the "ToKeep" token from the cookie and the "ToSend" token from the query string var keptToken = DeserializeToken(Request); var recievedToken = Request.QueryString["state"]; if (string.IsNullOrEmpty(recievedToken)) { throw new InvalidOperationException( "No state/recievedToken was retrieved from the provider. Are you sure you passed any state/token data to provider .. and .. that the provider can send it back to us? We need this to prevent any Cross site request forgery."); } // Validate the token against the recieved one and grab extra data string extraData = _antiForgery.ValidateToken(keptToken, recievedToken); var model = new AuthenticateCallbackData(); try { // Grab the authenticated client information. model.AuthenticatedClient = AuthenticationService.GetAuthenticatedClient(settings, Request.QueryString); } catch (Exception exception) { model.Exception = exception; } // If we have a redirect Url, lets grab this :) // NOTE: We've implimented the extraData part of the tokenData as the redirect url. if (!string.IsNullOrEmpty(extraData)) { model.RedirectUrl = new Uri(extraData); } // Finally! We can hand over the logic to the consumer to do whatever they want. return CallbackProvider.Process(HttpContext, model); }
public ActionResult AuthenticateCallback(string providerkey) { if (string.IsNullOrEmpty(providerkey)) { throw new ArgumentException("No provider key was supplied on the callback."); } // Determine which settings we need, based on the Provider. var settings = AuthenticationService.GetAuthenticateServiceSettings(providerkey, Request.Url); // Make sure we use our 'previous' State value. var token = DeserializeToken(Request); settings.State = token; TokenData tokenData = null; if (!string.IsNullOrEmpty(token)) { tokenData = _antiForgery.ValidateToken(token); } var model = new AuthenticateCallbackData(); try { // Grab the authenticated client information. model.AuthenticatedClient = AuthenticationService.GetAuthenticatedClient(settings, Request.QueryString); } catch (Exception exception) { model.Exception = exception; } // If we have a redirect Url, lets grab this :) // NOTE: We've implimented the extraData part of the tokenData as the redirect url. if (tokenData != null && !string.IsNullOrEmpty(tokenData.ExtraData)) { model.RedirectUrl = new Uri(tokenData.ExtraData); } // Finally! We can hand over the logic to the consumer to do whatever they want. return CallbackProvider.Process(HttpContext, model); }