/// <summary> /// Verification Token /// </summary> /// <param name="actionContext"></param> public static void VerificationToken(HttpActionContext actionContext) { if (actionContext.Request.Headers.Authorization == null || actionContext.Request.Headers.Authorization.Scheme != "Bearer") { RCS.Models.JwtAuthActionFilterAttribute.SetErrorResponse(actionContext, "驗證錯誤,請重新登入!"); } else { try { PAYLOAD jwtObject = DecodeToken(actionContext.Request.Headers.Authorization.Parameter); } catch (Exception ex) { RCS.Models.JwtAuthActionFilterAttribute.SetErrorResponse(actionContext, "不合法的登入方式,請重新登入!"); } } }
/// <summary> /// Encode token /// </summary> /// <param name="payload"></param> /// <returns></returns> public static string EncodeToken(PAYLOAD payload) { return(Jose.JWT.Encode(payload, Encoding.UTF8.GetBytes(IniFile.GetConfig("System", JwtAuthActionFilterAttribute.secret)), JwsAlgorithm.HS256)); }
public string GetBase64Encoding() { return($"{HEADER.GetBase64Encoding()}." + $"{PAYLOAD.GetBase64Encoding()}." + $"{SIGNATURE.GetBase64Encoding()}"); }
public void put(PAYLOAD s) { Put(s); }