public Task <IAuthenticationResult> AuthenticateAsync(IEnumerable <Type> authenticators, bool saveResult) { return(Task.Run <IAuthenticationResult>(() => { HttpContext httpContext = httpContextAccessor.HttpContext; AuthenticationInternalResult result = null; foreach (Type authenticator in authenticators) { if (AuthenticationHelper.IsValidAuthenticator(httpContext.RequestServices.GetRequiredService <IAuthenticatorMethodCache>(), authenticator, out AuthenticatorMetadata authenticateMethod)) { result = AuthenticationHelper.ExecuteAuthenticator(httpContext, authenticateMethod); if (result != null && result.KeepUnauthenticated == false && result.User != null) { IAuthenticationResult authentication = AuthenticationResult.CAS(result.User); if (saveResult) { accessor.Result = authentication; } return authentication; } } } return AuthenticationResult.Unauthenticated(); })); }
public Task <IAuthenticationResult> CASAsync(bool saveResult) { return(Task.Run <IAuthenticationResult>(() => { HttpContext httpContext = httpContextAccessor.HttpContext; AuthenticationInternalResult result = AuthenticationHelper.ExecuteCAS(httpContext); if (result != null && result.KeepUnauthenticated == false && result.User != null) { IAuthenticationResult authentication = AuthenticationResult.CAS(result.User); if (saveResult) { accessor.Result = authentication; } return authentication; } return AuthenticationResult.Unauthenticated(); })); }