Search in sources :

Example 1 with InternalPrincipal

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

the class InternalAuthenticationManager method handleInternalRequest.

public void handleInternalRequest(ContainerRequestContext request) {
    String subject;
    try {
        subject = parseJwt(request.getHeaders().getFirst(TRINO_INTERNAL_BEARER));
    } catch (JwtException e) {
        log.error(e, "Internal authentication failed");
        request.abortWith(Response.status(UNAUTHORIZED).type(TEXT_PLAIN_TYPE.toString()).build());
        return;
    } catch (RuntimeException e) {
        throw new RuntimeException("Authentication error", e);
    }
    Identity identity = Identity.forUser("<internal>").withPrincipal(new InternalPrincipal(subject)).build();
    setAuthenticatedIdentity(request, identity);
}
Also used : JwtException(io.jsonwebtoken.JwtException) ServletSecurityUtils.setAuthenticatedIdentity(io.trino.server.ServletSecurityUtils.setAuthenticatedIdentity) Identity(io.trino.spi.security.Identity) InternalPrincipal(io.trino.server.security.InternalPrincipal)

Aggregations

JwtException (io.jsonwebtoken.JwtException)1 ServletSecurityUtils.setAuthenticatedIdentity (io.trino.server.ServletSecurityUtils.setAuthenticatedIdentity)1 InternalPrincipal (io.trino.server.security.InternalPrincipal)1 Identity (io.trino.spi.security.Identity)1