/// <summary> /// /// </summary> /// <param name="userOption"></param> public UserAuthAttribute(UserAuthOption userOption) { if (userOption?.UserProvider == null) throw new Exception("UserAuthOption 中 UserProvider 接口对象必须提供!"); Order = -10; _userOption = userOption; }
private static Task<Resp> CheckFunc(HttpContext context, AppIdentity appInfo, UserAuthOption opt) { var userInfo = CoreUserContext.Identity; if (userInfo == null // 非需授权认证请求 || opt.FuncProvider == null || userInfo.auth_type == PortalAuthorizeType.SuperAdmin) return _successResp; var askFunc = appInfo.ask_func; return opt.FuncProvider.FuncAuthorize(context, userInfo, askFunc); }
private static async Task<Resp> FormatUserIdentity(AuthorizationFilterContext context, AppIdentity appInfo, UserAuthOption opt) { var identityRes = await opt.UserProvider.GetIdentity(context.HttpContext, appInfo); if (!identityRes.IsSuccess()) return identityRes; CoreUserContext.SetIdentity(identityRes.data); return identityRes; }