Interface KafkaSecurityPolicy

All Superinterfaces:
BasePolicy, BaseSecurityPolicy, KafkaPolicy

public interface KafkaSecurityPolicy extends KafkaPolicy, BaseSecurityPolicy
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:
Author:
Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com), GraviteeSource Team
  • Method Details

    • extractSecurityToken

      io.reactivex.rxjava3.core.Maybe<SecurityToken> extractSecurityToken(KafkaConnectionContext ctx)
      Extracts the SecurityToken from the kafka connection context. Relevant information is basically extracted from the array of Callback available in the context. If no relevant SecurityToken is found, it returns an empty Maybe, so that policy won't be executed.
      Parameters:
      ctx - the current kafka connection context.
      Returns:
      the SecurityToken found in the kafka connection context
    • authenticate

      io.reactivex.rxjava3.core.Completable authenticate(KafkaConnectionContext ctx)
      Define the actions to perform during the connection. The authenticate(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 the extractToken(KafkaConnectionContext) method) is searched in the gateway cache. If the apikey is found and is valid, then the relevant Callback has to be updated.
      Parameters:
      ctx - the current kafka connection context allowing to access the callbacks and the SASL mechanism used.
      Returns:
      a Completable that must complete when all the actions have been performed.