/// <summary> /// 登录退出 /// </summary> /// <returns></returns> public ActionResult LogOff() { try { string currentUserId = CurrentUserContext.UserID; if (SSOAuthorization.IsLogin) { string msg = SSOAuthorization.Logout(); } } catch { } //单点登录判断 if (appConfig.SSOEnable && appConfig.SSOType != 1) { return(Redirect(appConfig.SSOServerUrl + "?app_regid=" + appConfig.SSORegisterID + "&action=logoff")); } else { //设置从注销返回登录页面标记 if (HttpContext.Application.Get("LogoutFlg") == null) { HttpContext.Application.Set("LogoutFlg", "true"); } return(Redirect(appConfig.LoginAction)); } }
/// <summary> /// 单点登录验证中心登录验证入口 /// </summary> /// <param name="ticket"></param> /// <param name="app_reurl"></param> /// <returns></returns> public ActionResult SSOLoginVerified(string ticket, string app_reurl) { try { var result = SSOAuthorization.SSOLogin(ticket); if (result.Status == LoginingStatus.Success) { WriteLog(string.Format("用户名:{0}在{1}成功登录系统!", CurrentUserContext.UserInfo.UserDisplayName, DateTime.Now.ToString())); if (string.IsNullOrEmpty(app_reurl)) { return(Redirect(appConfig.IndexAction)); } else { return(Redirect(HttpUtility.UrlDecode(app_reurl))); } } else { WriteLog(string.Format("票据:{0}在{1}登录系统失败!原因:{2}", ticket, DateTime.Now.ToString(), result.Message)); return(Content("<script>alert('" + result.Message + "'); location.href='" + appConfig.SSOServerUrl + "?app_regid=" + appConfig.SSORegisterID + "&action=logoff&app_reurl=" + HttpUtility.UrlEncode(app_reurl) + "';</script>")); } } catch (Exception ex) { WriteLog(string.Format("票据:{0}在{1}登录系统失败!原因:{2}", ticket, DateTime.Now.ToString(), ex.Message)); return(Content("<script>alert('系统错误,登录跳转失败,错误信息请查看日志文件!'); location.href='" + appConfig.SSOServerUrl + "?app_regid=" + appConfig.SSORegisterID + "&action=logoff&app_reurl=" + HttpUtility.UrlEncode(app_reurl) + "';</script>")); } }
/// <summary> /// 登录退出 /// </summary> /// <returns></returns> public ActionResult LogOff() { try { string currentUserId = CurrentUserContext.UserID; if (SSOAuthorization.IsLogin) { string msg = SSOAuthorization.Logout(); } } catch { } //单点登录判断 if (appConfig.SSOEnable && appConfig.SSOType != 1) { return(Redirect(appConfig.SSOServerUrl + "?app_regid=" + appConfig.SSORegisterID + "&action=logoff&app_reurl=" + System.Web.HttpUtility.UrlEncode((HttpContext.Request.Url.ToString() ?? "").ToLower().Replace("/admin/logoff", "")))); } else { //设置从注销返回登录页面标记 if (HttpContext.Application.Get("LogoutFlg") == null) { HttpContext.Application.Set("LogoutFlg", "true"); } return(Redirect(appConfig.LoginAction)); } }
public JsonResult LogOn(LogOnModel model) { var result = SSOAuthorization.Login(model.UserName, model.Password); if (result.Status == LoginingStatus.Success) { //if (string.IsNullOrEmpty(model.ReUrl)) model.ReUrl = appConfig.IndexAction; WriteLog(string.Format("用户名:{0}在{1}成功登录系统!", model.UserName, DateTime.Now.ToString())); return(Json(AjaxResult.Success(model.ReUrl, "登录成功!"))); } else { WriteLog(string.Format("用户名:{0}在{1}登录系统失败!原因:{2}", model.UserName, DateTime.Now.ToString(), result.Message)); return(Json(AjaxResult.Error(result.Message))); } }
public void InstallServices(IServiceCollection services, AppSettings appSettings, IConfiguration configuration, IHostEnvironment hostEnvironment) { var appName = AppStrings.ATASecurityAppKeyName; services.AddAuthentication(options => { options.DefaultAuthenticateScheme = "SSO Scheme"; options.DefaultChallengeScheme = "SSO Scheme"; }) .AddCustomAuthentication(o => { }); services.AddSingleton(new HttpClient()); services.AddMvc(config => { config.Filters.Add(SSOAuthorization.GetAuthorizeFilter(appName)); }); }