1221
This commit is contained in:
parent
ad7dce8d4e
commit
a878d838d1
|
@ -138,8 +138,8 @@
|
|||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<package id="System.IdentityModel.Tokens.Jwt" version="7.6.0" targetFramework="net461" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net461" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net461" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net461" />
|
||||
<package id="System.Text.Encodings.Web" version="4.7.2" targetFramework="net461" />
|
||||
<package id="System.Text.Json" version="4.7.2" targetFramework="net461" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net461" />
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
using BLL;
|
||||
using BLL.Common;
|
||||
using Microsoft.IdentityModel.Logging;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Org.BouncyCastle.Utilities.Encoders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
|
@ -16,6 +22,7 @@ namespace FineUIPro.Web
|
|||
private string code = string.Empty;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.code = Request.Params["code"];
|
||||
BLL.ErrLogInfo.WriteLog($"获取code={this.code}");
|
||||
if (string.IsNullOrEmpty(this.code))
|
||||
|
@ -23,7 +30,7 @@ namespace FineUIPro.Web
|
|||
Response.Redirect("~/login.aspx");
|
||||
return;
|
||||
}
|
||||
var token = GetAccessToken(this.code);
|
||||
var token = GetAccessToken(this.code);
|
||||
var userInfo = getUserInfo(token);
|
||||
if (userInfo == null)
|
||||
{
|
||||
|
@ -65,29 +72,30 @@ namespace FineUIPro.Web
|
|||
|
||||
private Model.Sys_User getUserInfo(AccessTokenModel token)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var handler = new JwtSecurityTokenHandler();
|
||||
var jwtToken = handler.ReadJwtToken(token.id_token);
|
||||
string username = string.Empty;
|
||||
var result = jwtToken.Claims.Where(t => t.Type == "cn").FirstOrDefault();
|
||||
if (result != null)
|
||||
string[] toke_split= token.id_token.Split('.');
|
||||
var header = Encoding.UTF8.GetString(Base64UrlEncoder.DecodeBytes(toke_split[0]));
|
||||
var clamis= Encoding.UTF8.GetString(Base64UrlEncoder.DecodeBytes(toke_split[1]));
|
||||
BLL.ErrLogInfo.WriteLog("clamis=" + clamis);
|
||||
JObject jo = JObject.Parse(clamis);
|
||||
if (jo["cn"] != null)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog("cn="+result?.Value);
|
||||
username = result?.Value;
|
||||
username = jo["cn"].ToString();
|
||||
}
|
||||
else{
|
||||
username = jwtToken.Claims.Where(t => t.Type == "preferred_username").FirstOrDefault()?.Value;
|
||||
BLL.ErrLogInfo.WriteLog("username=" + username);
|
||||
if (!string.IsNullOrEmpty(username))
|
||||
else
|
||||
{
|
||||
if (jo["preferred_username"] != null)
|
||||
{
|
||||
username = username.Split('@')[0];
|
||||
}
|
||||
string preferred_username = jo["preferred_username"].ToString();
|
||||
username = preferred_username.Split('@')[0];
|
||||
}
|
||||
}
|
||||
var info = Funs.DB.Sys_User.Where(t => t.Account == username && t.IsPost == true).FirstOrDefault();
|
||||
if (info != null)
|
||||
{
|
||||
FormsAuthentication.SetAuthCookie(username, false);
|
||||
Session[SessionName.CurrUser] = info;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue