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