private String OnLogin(OAuthClient client, String state, String returnUrl) { var prov = Provider; var redirect = prov.GetRedirect(Request, returnUrl); return(client.Authorize(redirect, state)); }
private String OnLogin(OAuthClient client, String state, String returnUrl) { var prov = Provider; var redirect = prov.GetRedirect(Request, "~/Sso/LoginInfo/" + client.Name); // 请求来源,前后端分离时传front-end,重定向会带上token放到锚点 var source = GetRequest("source"); //if (state.IsNullOrEmpty() && !returnUrl.IsNullOrEmpty()) state = $"r={returnUrl}"; //if (!source.IsNullOrEmpty()) //{ // state += (state.IsNullOrEmpty() ? "" : "&") + $"s={source}"; //} //state = HttpUtility.UrlEncode(state); var log = new OAuthLog { Provider = client.Name, Action = "Login", Success = false, ResponseType = client.ResponseType, Scope = client.Scope, State = state, RedirectUri = returnUrl, Source = source }; log.Insert(); return(client.Authorize(redirect, log.Id + "")); }
public string GetAccessToken() { var oauth = new OAuthClient(authorizationServerDescription, clientId, clientSecret, new Uri(@"http://localhost:12345/oauth2callback")); oauth.Authorize(ref state, null); return(state.AccessToken); }
private void loginButton_Click(object sender, EventArgs e) { // AADB2C90118: The user has forgotten their password ==> Login with forgot password policy if (!string.IsNullOrEmpty(Request["error"]) && !string.IsNullOrEmpty(Request["error_description"]) && Request["error_description"]?.IndexOf("AADB2C90118") == -1) { // AADB2C90091: The user has cancelled entering self-asserted information. // User clicked on Cancel when resetting the password => Redirect to the login page if (Request["error_description"]?.IndexOf("AADB2C90091") > -1) { Response.Redirect(Common.Utils.GetLoginUrl(PortalSettings.Current, Request), true); } else { var errorMessage = Localization.GetString("LoginError", LocalResourceFile); errorMessage = string.Format(errorMessage, Request["error"], Request["error_description"]); _logger.Error(errorMessage); UI.Skins.Skin.AddModuleMessage(this, errorMessage, ModuleMessage.ModuleMessageType.RedError); } } else { if (Request["error_description"]?.IndexOf("AADB2C90118") > -1) { ((AzureClient)OAuthClient).Policy = AzureClient.PolicyEnum.PasswordResetPolicy; } AuthorisationResult result = OAuthClient.Authorize(); if (result == AuthorisationResult.Denied) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); } } }
private void loginButton_Click(object sender, EventArgs e) { AuthorisationResult result = OAuthClient.Authorize(); if (result == AuthorisationResult.Denied) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); } }
private String OnLogin(OAuthClient client, String state, String returnUrl) { var prov = Provider; var redirect = prov.GetRedirect(Request, "~/Sso/LoginInfo/" + client.Name); if (state.IsNullOrEmpty() && !returnUrl.IsNullOrEmpty()) { state = $"r={returnUrl}"; } return(client.Authorize(redirect, state)); }
private void loginButton_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request["error"])) { var errorMessage = Localization.GetString("LoginError", LocalResourceFile); errorMessage = string.Format(errorMessage, Request["error"], Request["error_description"]); _logger.Error(errorMessage); UI.Skins.Skin.AddModuleMessage(this, errorMessage, ModuleMessage.ModuleMessageType.RedError); } else { AuthorisationResult result = OAuthClient.Authorize(); if (result == AuthorisationResult.Denied) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); } } }
private String OnLogin(OAuthClient client, String state, String returnUrl) { var prov = Provider; var redirect = prov.GetRedirect(Request, returnUrl); // 钉钉内打开时,自动切换为应用内免登 if (client is DingTalkClient ding) { #if __CORE__ var agent = Request.Headers["User-Agent"] + ""; #else var agent = Request.UserAgent; #endif if (!agent.IsNullOrEmpty() && agent.Contains("DingTalk")) { ding.Scope = "snsapi_auth"; ding.SetMode(ding.Scope); } } return(client.Authorize(redirect, state)); }
private void loginButton_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request["error"])) { var errorMessage = Localization.GetString("LoginError", LocalResourceFile); errorMessage = string.Format(errorMessage, Request["error"], Request["error_description"]); _logger.Error(errorMessage); if (string.IsNullOrEmpty(config.OnErrorUri)) { UI.Skins.Skin.AddModuleMessage(this, errorMessage, ModuleMessage.ModuleMessageType.RedError); } else { Response.Redirect($"{config.OnErrorUri}?error={Request["error"]}&error_description={HttpContext.Current.Server.UrlEncode(Request["error_description"])}"); } } else { AuthorisationResult result = OAuthClient.Authorize(); if (result == AuthorisationResult.Denied) { if (string.IsNullOrEmpty(config.OnErrorUri)) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); } else { Response.Redirect($"{config.OnErrorUri}?error=Denied&error_description={HttpContext.Current.Server.UrlEncode(Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile))}"); } } else { if (!string.IsNullOrEmpty(((AzureClient)OAuthClient).RedirectUrl)) { RedirectURL = ((AzureClient)OAuthClient).RedirectUrl; } } } }
private void loginButton_Click(object sender, EventArgs e) { OAuthClient.CallbackUri = new Uri(OAuthClient.CallbackUri + "?state=LinkedIn"); OAuthClient.Authorize(); }
private void loginButton_Click(object sender, EventArgs e) { OAuthClient.Authorize(); }