public Task <Resp> AppAuthCheck(HttpContext context, AppIdentity appinfo) { if (appinfo.SourceMode == AppSourceMode.ServerSign) { var key = ConfigHelper.GetSection("KnockAppSecrets:" + appinfo.app_id)?.Value; const int expireSecs = 60 * 60 * 2; if (!appinfo.CheckSign(key, expireSecs).IsSuccess()) { return(Task.FromResult(new Resp(RespTypes.SignError, "签名错误!"))); } } return(Task.FromResult(new Resp())); }
public static Resp CheckAppSign(AppIdentity appInfo, HttpContext context) { var authTicketStr = context.Request.Headers[ServerSignModeHeaderName]; appInfo.FromTicket(authTicketStr); if (!AppInfoHelper.FormatAppIdInfo(appInfo)) { return(new Resp(RespTypes.OperateFailed, "未知应用来源!")); } var key = ConfigHelper.GetSection("KnockAppSecrets:" + appInfo.app_id)?.Value; const int expireSecs = 60 * 60 * 2; return(appInfo.CheckSign(key, expireSecs)); }
private static async Task <Resp> CheckAppAuthIdentity(HttpContext context, IAppAuthProvider provider, AppIdentity appInfo) { var secretKeyRes = await provider.IntialAuthAppConfig(context, appInfo); if (!secretKeyRes.IsSuccess()) { return(secretKeyRes); } const int expireSecs = 60 * 60 * 2; if (!appInfo.CheckSign(secretKeyRes.data.AppSecret, expireSecs).IsSuccess() || !AppInfoHelper.FormatAppIdInfo(appInfo)) { return(new Resp(RespTypes.SignError, "签名错误!")); } return(secretKeyRes); }