Interface SecurityPolicy
-
- All Superinterfaces:
Policy
public interface SecurityPolicy extends Policy
SecurityPolicyis aPolicythat can be used for securing a plan that can require a subscription. Implementing aSecurityPolicyrequires 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:order(): to define the priority compared to other security policiessupport(RequestExecutionContext): to check if the current request can be handled or notrequireSubscription(): to indicate if it require a valid subscription or notonInvalidSubscription(RequestExecutionContext): to defined what to do in case of invalid subscription
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_ORDER
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default io.reactivex.CompletableonInvalidSubscription(RequestExecutionContext ctx)Defines if the subscription associated must be checked and the action to execute when the subscription is not valid.default intorder()Defines the priority order of the security policy compared to others.default booleanrequireSubscription()Security policy can be used together with a plan that requires a subscription.io.reactivex.Single<Boolean>support(RequestExecutionContext ctx)Indicates whether the security policy can handle the request execution context or not.-
Methods inherited from interface io.gravitee.gateway.jupiter.api.policy.Policy
id, onMessage, onMessageFlow, onRequest, onResponse
-
-
-
-
Field Detail
-
DEFAULT_ORDER
static final int DEFAULT_ORDER
- See Also:
- Constant Field Values
-
-
Method Detail
-
support
io.reactivex.Single<Boolean> support(RequestExecutionContext ctx)
Indicates whether the security policy can handle the request execution context or not. The policy can extract any information from the execution context to determine if the current request can be handled or not (ex: specific request header, body extraction, ...).- Parameters:
ctx- the current execution context that can be used to determine if this security policy can handle the current request execution or not.- Returns:
trueif the policy can handle the current request execution,falseotherwise.
-
requireSubscription
default boolean requireSubscription()
Security policy can be used together with a plan that requires a subscription. By enabling the subscription requirement, the gateway will automatically validate the subscription associated with the current request and reject the request if the subscription is invalid.- Returns:
trueto indicates to check the subscription after the security policy has been successfully executed,falseelse.
-
onInvalidSubscription
default io.reactivex.Completable onInvalidSubscription(RequestExecutionContext ctx)
Defines if the subscription associated must be checked and the action to execute when the subscription is not valid. Usually, it allows to the security policy to interrupt the execution with an error status code and some response headers. Returningnullindicates that the subscription does have to be verified after the policy completes successfully.- Returns:
- a
Completablecorresponding to the actions to execute when the gateway has detected an invalid subscription ornullto disable subscription check.
-
order
default int order()
Defines the priority order of the security policy compared to others. By default, it is set toDEFAULT_ORDER. The lower is the order, the highest is the priority of the policy compared to other. The order is not guaranteed when 2SecurityPolicyhave the same order.- Returns:
- the order of the security policy when multiple security policies can be involved.
-
-