internal static AuthenticationInternalResult AuthenticateRazorPage(CompiledPageActionDescriptor actionDescriptor, HttpContext httpContext) { // first, check if the url contains ticket CheckRequestUrl(httpContext, out AuthenticationInternalResult result); if (result != null) { return(result); } // then, check if the action needs authorization IAuthenticationDeclarationCache cache = httpContext.RequestServices.GetRequiredService <IAuthenticationDeclarationCache>(); AuthenticationDeclarationInfo declarationInfo = cache.Get(actionDescriptor); AuthenticationDeclaration declaration = declarationInfo.Declaration; if (declaration == AuthenticationDeclaration.No) { return(new AuthenticationInternalResult(true, null, null, null)); } ICustomAttributeProvider attributeProvider = null; if (declaration == AuthenticationDeclaration.HandlerMethod) { attributeProvider = actionDescriptor.HandlerMethods[0].MethodInfo; } else { attributeProvider = actionDescriptor.ModelTypeInfo; } return(Authenticate(httpContext, declarationInfo.Attribute, attributeProvider)); }
public AuthenticationDeclarationInfo(AuthenticationDeclaration declaration, AuthenticationRequiredAttribute attribute) { Declaration = declaration; Attribute = attribute; }