Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gravitee-io/gravitee-policy-template
https://github.com/gravitee-io/gravitee-policy-template
product-am product-apim security-scan
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gravitee-io/gravitee-policy-template
- Owner: gravitee-io
- License: apache-2.0
- Created: 2023-07-06T06:13:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-15T08:24:37.000Z (3 months ago)
- Last Synced: 2024-09-15T17:28:56.464Z (3 months ago)
- Topics: product-am, product-apim, security-scan
- Language: Java
- Size: 31.3 KB
- Stars: 0
- Watchers: 17
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.adoc
- Contributing: CONTRIBUTING.adoc
- License: LICENSE.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
= Gravitee Policy Template
== Phases
[cols="4*", options="header"]
|===
^|onRequest
^|onResponse
^|onMessageRequest
^|onMessageResponse^.^| X
^.^| X
^.^| X
^.^| X
|===== Description
A policy template to fork and use as a quick starter.
This policy will compare `X-Template-Policy` header value with its configuration `errorKey` field, if both values are equal, then the policy will interrupt the request with a failure execution error.
Implements `TemplatePolicy#onRequest(HttpExecutionContext context)` and `TemplatePolicy#onResponse(HttpExecutionContext context)` to develop your own policy.
NOTE: This policy is designed to work with at least APIM 4.0.0.
=== AM and APIM V2 API compatibility
To develop a policy working with AM or a v2 definition of an API in APIM, please follow link:./src/main/java/io/gravitee/policy/template/v3/TemplatePolicyV3.java[the v3 example implementation of the policy].
== Configuration
You can configure the policy with the following options:
[cols="5*", options=header]
|===
^| Property
^| Required
^| Description
^| Type
^| Default.^|errorKey
^.^|X
.^|Policy will fail if header `X-Template-Policy` value is equal to this field.
^.^|string
^.^|"failure"|===
Example configuration:
[source, json]
----
{
"configuration": {
"errorKey": "value-to-fail-the-policy"
}
}
----== Errors
With the provided default implementation, policy will fail if header `X-Template-Policy` value is equal to configured `errorKey` value.
|===
|Phase | Code | Error template key | Description.^| REQUEST
.^| ```400 - BAD REQUEST```
.^| POLICY_TEMPLATE_ERROR_KEY
.^| An error occurs during request.^| RESPONSE
.^| ```500 - INTERNAL SERVER ERROR```
.^| POLICY_TEMPLATE_ERROR_KEY
.^| An error occurs during response|===