Search in sources :

Example 1 with AuthenticationException

use of io.trino.server.security.AuthenticationException in project trino by trinodb.

the class FormWebUiAuthenticationFilter method handleProtocolLoginRequest.

private static void handleProtocolLoginRequest(Authenticator authenticator, ContainerRequestContext request) {
    Identity authenticatedIdentity;
    try {
        authenticatedIdentity = authenticator.authenticate(request);
    } catch (AuthenticationException e) {
        // authentication failed
        sendWwwAuthenticate(request, firstNonNull(e.getMessage(), "Unauthorized"), e.getAuthenticateHeader().map(ImmutableSet::of).orElse(ImmutableSet.of()));
        return;
    }
    if (redirectFormLoginToUi(request)) {
        return;
    }
    setAuthenticatedIdentity(request, authenticatedIdentity);
}
Also used : AuthenticationException(io.trino.server.security.AuthenticationException) ServletSecurityUtils.setAuthenticatedIdentity(io.trino.server.ServletSecurityUtils.setAuthenticatedIdentity) Identity(io.trino.spi.security.Identity)

Example 2 with AuthenticationException

use of io.trino.server.security.AuthenticationException in project trino by trinodb.

the class OAuth2Authenticator method needAuthentication.

@Override
protected AuthenticationException needAuthentication(ContainerRequestContext request, String message) {
    UUID authId = UUID.randomUUID();
    URI initiateUri = request.getUriInfo().getBaseUri().resolve(getInitiateUri(authId));
    URI tokenUri = request.getUriInfo().getBaseUri().resolve(getTokenUri(authId));
    return new AuthenticationException(message, format("Bearer x_redirect_server=\"%s\", x_token_server=\"%s\"", initiateUri, tokenUri));
}
Also used : AuthenticationException(io.trino.server.security.AuthenticationException) UUID(java.util.UUID) URI(java.net.URI)

Aggregations

AuthenticationException (io.trino.server.security.AuthenticationException)2 ServletSecurityUtils.setAuthenticatedIdentity (io.trino.server.ServletSecurityUtils.setAuthenticatedIdentity)1 Identity (io.trino.spi.security.Identity)1 URI (java.net.URI)1 UUID (java.util.UUID)1