Interface KafkaSecurityPolicy
- All Superinterfaces:
BasePolicy,BaseSecurityPolicy,KafkaPolicy
KafkaSecurityPolicy is a KafkaPolicy that can be used for securing a plan that can require a subscription.
Implementing a KafkaSecurityPolicy requires to implement some additional behavior in order to be used by the gateway during the security chain execution that will identify which plan the consumer is using:
BaseSecurityPolicy.order(): to define the priority compared to other security policiesBaseSecurityPolicy.requireSubscription(): to indicate if it require a valid subscription or notextractSecurityToken(KafkaConnectionContext ctx): to extract theSecurityTokenfrom the kafka connection contextauthenticate(KafkaConnectionContext ctx): to validate theSecurityTokenextracted from the kafka connection context
- Author:
- Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com), GraviteeSource Team
-
Field Summary
Fields inherited from interface io.gravitee.gateway.reactive.api.policy.base.BaseSecurityPolicy
DEFAULT_ORDER -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.CompletableDefine the actions to perform during the connection.io.reactivex.rxjava3.core.Maybe<SecurityToken>Extracts theSecurityTokenfrom the kafka connection context.Methods inherited from interface io.gravitee.gateway.reactive.api.policy.base.BasePolicy
idMethods inherited from interface io.gravitee.gateway.reactive.api.policy.base.BaseSecurityPolicy
order, requireSubscriptionMethods inherited from interface io.gravitee.gateway.reactive.api.policy.kafka.KafkaPolicy
onInitialize, onMessageRequest, onMessageResponse, onRequest, onResponse
-
Method Details
-
extractSecurityToken
Extracts theSecurityTokenfrom the kafka connection context. Relevant information is basically extracted from the array ofCallbackavailable in the context. If no relevantSecurityTokenis found, it returns an empty Maybe, so that policy won't be executed.- Parameters:
ctx- the current kafka connection context.- Returns:
- the
SecurityTokenfound in the kafka connection context
-
authenticate
Define the actions to perform during the connection. Theauthenticate(KafkaConnectionContext)method will be called during the connection between the kafka client and the gateway. In this method, the "Gravitee" security is checked before going further. For example, for an APIKey plan, the extracted apikey (extracted in theextractToken(KafkaConnectionContext)method) is searched in the gateway cache. If the apikey is found and is valid, then the relevantCallbackhas to be updated.- Parameters:
ctx- the current kafka connection context allowing to access the callbacks and the SASL mechanism used.- Returns:
- a
Completablethat must complete when all the actions have been performed.
-