|
@@ -15,7 +15,7 @@ namespace TEAMModelOS.SDK.Extension
|
|
{
|
|
{
|
|
public static class JwtAuthExtension
|
|
public static class JwtAuthExtension
|
|
{
|
|
{
|
|
- public static string CreateAuthToken(string issuer, string id, string name, string picture, string salt, string scope, string Website, string areaId = "", string schoolID = "", string standard = "", string[] roles = null, string[] permissions = null, int expire = 1)
|
|
|
|
|
|
+ public static string CreateAuthToken(string issuer, string id, string name, string picture, string salt, string scope, string Website, string areaId = "", string schoolID = "", string standard = "", string[] roles = null, string[] permissions = null, int expire = 1,int year=-1)
|
|
{
|
|
{
|
|
// 設定要加入到 JWT Token 中的聲明資訊(Claims)
|
|
// 設定要加入到 JWT Token 中的聲明資訊(Claims)
|
|
var payload = new JwtPayload {
|
|
var payload = new JwtPayload {
|
|
@@ -32,7 +32,10 @@ namespace TEAMModelOS.SDK.Extension
|
|
{ "area",areaId==null?"":areaId},
|
|
{ "area",areaId==null?"":areaId},
|
|
{ JwtRegisteredClaimNames.Website,Website},
|
|
{ JwtRegisteredClaimNames.Website,Website},
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+ //学生入学年
|
|
|
|
+ if (year!=-1) {
|
|
|
|
+ payload.Add("year", year);
|
|
|
|
+ }
|
|
// 建立一組對稱式加密的金鑰,主要用於 JWT 簽章之用
|
|
// 建立一組對稱式加密的金鑰,主要用於 JWT 簽章之用
|
|
var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(salt));
|
|
var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(salt));
|
|
// HmacSha256 有要求必須要大於 128 bits,所以 salt 不能太短,至少要 16 字元以上
|
|
// HmacSha256 有要求必須要大於 128 bits,所以 salt 不能太短,至少要 16 字元以上
|