Search in sources :

Example 11 with AthenzPrincipal

use of com.yahoo.vespa.athenz.api.AthenzPrincipal in project vespa by vespa-engine.

the class UserAuthWithAthenzPrincipalFilter method rewriteUserPrincipalToAthenz.

private void rewriteUserPrincipalToAthenz(DiscFilterRequest request) {
    Principal userPrincipal = request.getUserPrincipal();
    log.log(LogLevel.DEBUG, () -> "Original user principal: " + userPrincipal.toString());
    UserId userId = new UserId(userPrincipal.getName());
    AthenzUser athenzIdentity = AthenzUser.fromUserId(userId.id());
    request.setRemoteUser(athenzIdentity.getFullName());
    NToken nToken = Optional.ofNullable(request.getHeader(principalHeaderName)).map(NToken::new).orElse(null);
    request.setUserPrincipal(new AthenzPrincipal(athenzIdentity, nToken));
}
Also used : UserId(com.yahoo.vespa.hosted.controller.api.identifiers.UserId) NToken(com.yahoo.vespa.athenz.api.NToken) AthenzPrincipal(com.yahoo.vespa.athenz.api.AthenzPrincipal) AthenzUser(com.yahoo.vespa.athenz.api.AthenzUser) Principal(java.security.Principal) AthenzPrincipal(com.yahoo.vespa.athenz.api.AthenzPrincipal)

Aggregations

AthenzPrincipal (com.yahoo.vespa.athenz.api.AthenzPrincipal)11 DiscFilterRequest (com.yahoo.jdisc.http.filter.DiscFilterRequest)5 Test (org.junit.Test)5 NToken (com.yahoo.vespa.athenz.api.NToken)3 AthenzUser (com.yahoo.vespa.athenz.api.AthenzUser)2 PrincipalToken (com.yahoo.athenz.auth.token.PrincipalToken)1 Method (com.yahoo.jdisc.http.HttpRequest.Method)1 AthenzDomain (com.yahoo.vespa.athenz.api.AthenzDomain)1 AthenzIdentity (com.yahoo.vespa.athenz.api.AthenzIdentity)1 UserId (com.yahoo.vespa.hosted.controller.api.identifiers.UserId)1 InvalidTokenException (com.yahoo.vespa.hosted.controller.api.integration.athenz.InvalidTokenException)1 Path (com.yahoo.vespa.hosted.controller.restapi.Path)1 Principal (java.security.Principal)1 PublicKey (java.security.PublicKey)1 ForbiddenException (javax.ws.rs.ForbiddenException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1