mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-18 17:48:01 +08:00
优化SSO登录
This commit is contained in:
@@ -9,8 +9,10 @@
|
||||
// File: CheckController.cs
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Cache;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.SSO;
|
||||
|
||||
@@ -24,6 +26,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
|
||||
public class CheckController : Controller
|
||||
{
|
||||
private AuthorizeApp _app;
|
||||
private ObjCacheProvider<UserAuthSession> _objCacheProvider = new ObjCacheProvider<UserAuthSession>();
|
||||
public CheckController()
|
||||
{
|
||||
_app = AutofacExt.GetFromFac<AuthorizeApp>();
|
||||
@@ -31,7 +34,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
|
||||
|
||||
public bool GetStatus(string token = "", string requestid = "")
|
||||
{
|
||||
if (new UserAuthSessionService().GetCache(token))
|
||||
if (_objCacheProvider.GetCache(token) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -52,7 +55,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
|
||||
|
||||
public string GetUserName(string token, string requestid = "")
|
||||
{
|
||||
var user = new UserAuthSessionService().Get(token);
|
||||
var user = _objCacheProvider.GetCache(token);
|
||||
if (user != null)
|
||||
{
|
||||
return user.UserName;
|
||||
@@ -66,5 +69,19 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(SSOAuthUtil.Parse(request));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool Logout(string token, string requestid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_objCacheProvider.Remove(token);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -51,21 +51,5 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
|
||||
TempData[AppInfo] = _appInfoService.Get(model.AppKey);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public bool Logout(string token, string requestid)
|
||||
{
|
||||
try
|
||||
{
|
||||
new UserAuthSessionService().Remove(token);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,11 +8,25 @@
|
||||
<section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration" />
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
|
||||
<sectionGroup name="enyim.com">
|
||||
<section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching"/>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<connectionStrings>
|
||||
<add name="OpenAuthDBContext" connectionString="Data Source=.;Initial Catalog=OpenAuthDB;Persist Security Info=True;User ID=sa;Password=000000;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
|
||||
<!--<add name="OpenAuthDBContext" connectionString="server=127.0.0.1;user id=root;persistsecurityinfo=True;database=openauth;password=123456" providerName="MySql.Data.MySqlClient" />-->
|
||||
</connectionStrings>
|
||||
|
||||
<enyim.com>
|
||||
<memcached protocol="Binary">
|
||||
<servers>
|
||||
<add address="127.0.0.1" port="11211"/>
|
||||
</servers>
|
||||
</memcached>
|
||||
</enyim.com>
|
||||
|
||||
<appSettings>
|
||||
<add key="webpages:Version" value="3.0.0.0" />
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
|
Reference in New Issue
Block a user