5 changed files with 107 additions and 4 deletions
-
1EuroTran/EasyBL.WEBAPP/EasyBL.WEBAPP.csproj
-
54EuroTran/EasyBL.WEBAPP/SETokenUtil.cs
-
1EuroTran/Entity/Entity.csproj
-
32EuroTran/Entity/SEToken.cs
-
23EuroTran/WebApp/Controllers/FavoriteController.cs
@ -0,0 +1,54 @@ |
|||
using Entity; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace EasyBL.WEBAPP |
|||
{ |
|||
public static class SETokenUtil |
|||
{ |
|||
|
|||
public static SEToken GetToken(HttpRequestMessage message) { |
|||
|
|||
SEToken seToken = new SEToken(); |
|||
|
|||
IEnumerable<string> headerValues; |
|||
if (message.Headers.TryGetValues("authtoken", out headerValues)) |
|||
{ |
|||
var token = headerValues.FirstOrDefault(); |
|||
|
|||
seToken = Decrypt(token); |
|||
|
|||
} |
|||
|
|||
return seToken; |
|||
|
|||
} |
|||
|
|||
public static SEToken Decrypt(string data) { |
|||
|
|||
SEToken seToken = new SEToken(); |
|||
|
|||
if (!string.IsNullOrEmpty(data)) { |
|||
|
|||
var authtoken = EasyNet.SecurityUtil.Decrypt(data); |
|||
var saAuthtoken = authtoken.Split(','); |
|||
|
|||
seToken.OrgID = saAuthtoken[0].Split(':')[1]; |
|||
seToken.Email = saAuthtoken[1].Split(':')[1]; |
|||
seToken.MemberID = saAuthtoken[1].Split(':')[1]; |
|||
seToken.SignToken = saAuthtoken[2].Split(':')[1]; |
|||
|
|||
} |
|||
|
|||
return seToken; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
using System; |
|||
|
|||
namespace Entity |
|||
{ |
|||
public class SEToken |
|||
{ |
|||
/// <summary>
|
|||
/// 組織ID
|
|||
/// </summary>
|
|||
public string OrgID { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户ID
|
|||
/// </summary>
|
|||
public string MemberID { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户Email
|
|||
/// </summary>
|
|||
public string Email { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户名对应签名Token
|
|||
/// </summary>
|
|||
public string SignToken { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Token过期时间
|
|||
/// </summary>
|
|||
public DateTime ExpireTime { get; set; } |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue