Package io.strimzi.kafka.oauth.validator
Class OAuthIntrospectionValidator
java.lang.Object
io.strimzi.kafka.oauth.validator.OAuthIntrospectionValidator
- All Implemented Interfaces:
TokenValidator
This class is responsible for validating the token during session authentication by using an introspection endpoint.
It works by sending the token to the configured authorization server's introspection endpoint. The endpoint returns a response with whether the token is valid or not, and it usually also returns additional attributes, that can be used to enforce additional constraints, and prevent some otherwise valid tokens from authenticating.
-
Constructor Summary
ConstructorsConstructorDescriptionOAuthIntrospectionValidator(String id, String clientId, String clientSecret, TokenProvider bearerTokenProvider, String introspectionEndpointUri, SSLSocketFactory socketFactory, HostnameVerifier verifier, PrincipalExtractor principalExtractor, String groupsClaimQuery, String groupsClaimDelimiter, String issuerUri, String userInfoUri, String validTokenType, String audience, String customClaimCheck, int connectTimeoutSeconds, int readTimeoutSeconds, boolean enableMetrics, int retries, long retryPauseMillis, boolean includeAcceptHeader) Create a new instance. -
Method Summary
-
Constructor Details
-
OAuthIntrospectionValidator
public OAuthIntrospectionValidator(String id, String clientId, String clientSecret, TokenProvider bearerTokenProvider, String introspectionEndpointUri, SSLSocketFactory socketFactory, HostnameVerifier verifier, PrincipalExtractor principalExtractor, String groupsClaimQuery, String groupsClaimDelimiter, String issuerUri, String userInfoUri, String validTokenType, String audience, String customClaimCheck, int connectTimeoutSeconds, int readTimeoutSeconds, boolean enableMetrics, int retries, long retryPauseMillis, boolean includeAcceptHeader) Create a new instance.- Parameters:
id- A unique id to associate with this validator for the purpose of validator lifecycle and metrics trackingclientId- The clientId of the OAuth2 client representing this Kafka broker - used to authenticate to the introspection endpoint using Basic authenticationclientSecret- The secret of the OAuth2 client representing this Kafka broker - used to authenticate to the introspection endpoint using Basic authenticationbearerTokenProvider- The provider of the bearer token as an alternative to clientId and secret of the OAuth2 client representing this Kafka broker - used to authenticate to the introspection endpoint using Bearer authenticationintrospectionEndpointUri- The introspection endpoint url at the authorization serversocketFactory- The optional SSL socket factory to use when establishing the connection to authorization serververifier- The optional hostname verifier used to validate the TLS certificate by the authorization serverprincipalExtractor- The object used to extract the username from the attributes in the server's responsegroupsClaimQuery- The JsonPath query for extracting groups from introspection endpoint responsegroupsClaimDelimiter- The delimiter used to parse groups from the result of applying groupQuery to what introspection endpoint returnsissuerUri- The required value of the 'iss' claim in the introspection endpoint responseuserInfoUri- The optional user info endpoint url at the authorization server, used as a failover when user id can't be extracted from the introspection endpoint responsevalidTokenType- The optional token type enforcement - only the specified token type is accepted as validaudience- The optional audience check. If specified, the 'aud' attribute of the introspection endpoint response needs to contain the configured clientIdcustomClaimCheck- The optional JSONPath filter query for additional custom attribute checkingconnectTimeoutSeconds- The maximum time to wait for connection to authorization server to be established (in seconds)readTimeoutSeconds- The maximum time to wait for response from authorization server after connection has been established and request sent (in seconds)enableMetrics- The switch that enables metrics collectionretries- Maximum number of retries if request to the authorization server fails (0 means no retries)retryPauseMillis- Time to pause before retrying the request to the authorization serverincludeAcceptHeader- Should we send the Accept header when making outbound http requests
-
-
Method Details
-
validate
Description copied from interface:TokenValidatorValidate the passed access token return it wrapped in TokenInfo with- Specified by:
validatein interfaceTokenValidator- Parameters:
token- An access token to validate- Returns:
- TokenInfo wrapping a valid token
-
getValidatorId
Description copied from interface:TokenValidatorReturn the id of this validator- Specified by:
getValidatorIdin interfaceTokenValidator- Returns:
- A validator id
-
close
public void close()Description copied from interface:TokenValidatorClose any allocated resources like background threads- Specified by:
closein interfaceTokenValidator
-