Package io.stargate.auth.jwt
Class AuthnJwtService
- java.lang.Object
-
- io.stargate.auth.jwt.AuthnJwtService
-
- All Implemented Interfaces:
AuthenticationService
public class AuthnJwtService extends Object implements AuthenticationService
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringCLAIMS_FIELDprotected static StringROLE_FIELDprotected static StringSTARGATE_PREFIX
-
Constructor Summary
Constructors Constructor Description AuthnJwtService(com.nimbusds.jwt.proc.ConfigurableJWTProcessor<? extends com.nimbusds.jose.proc.SecurityContext> jwtProcessor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcreateToken(String key, String secret, Map<String,String> headers)StringcreateToken(String key, Map<String,String> headers)Authenticator.SaslNegotiatorgetSaslNegotiator(Authenticator.SaslNegotiator wrapped, ClientInfo clientInfo)AuthenticationSubjectvalidateToken(String token)Validates a token in the form of a JWT to ensure that 1) it's not expired, 2) it's correctly signed by the provider, and 3) contains the proper role for the given DB.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.stargate.auth.AuthenticationService
validateToken, validateToken
-
-
-
-
Field Detail
-
STARGATE_PREFIX
protected static final String STARGATE_PREFIX
- See Also:
- Constant Field Values
-
ROLE_FIELD
protected static final String ROLE_FIELD
- See Also:
- Constant Field Values
-
CLAIMS_FIELD
protected static final String CLAIMS_FIELD
- See Also:
- Constant Field Values
-
-
Method Detail
-
createToken
public String createToken(String key, String secret, Map<String,String> headers)
- Specified by:
createTokenin interfaceAuthenticationService
-
createToken
public String createToken(String key, Map<String,String> headers)
- Specified by:
createTokenin interfaceAuthenticationService
-
validateToken
public AuthenticationSubject validateToken(String token) throws UnauthorizedException
Validates a token in the form of a JWT to ensure that 1) it's not expired, 2) it's correctly signed by the provider, and 3) contains the proper role for the given DB.- Specified by:
validateTokenin interfaceAuthenticationService- Parameters:
token- A JWT created by an auth provider.- Returns:
- A
AuthenticationSubjectcontaining the role name the request is authenticated to use. - Throws:
UnauthorizedException- An UnauthorizedException if the JWT is expired, malformed, or not properly signed.
-
getSaslNegotiator
public Authenticator.SaslNegotiator getSaslNegotiator(Authenticator.SaslNegotiator wrapped, ClientInfo clientInfo)
- Specified by:
getSaslNegotiatorin interfaceAuthenticationService
-
-