-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add policy manifest and make existing schemas conform with it #565
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ff0c9da
policy/upstream: add descriptions to the json schema
davidor 104b55d
policy/echo: add descriptions to the json schema
davidor 34f35c0
policy/url_rewriting: add descriptions to the json schema
davidor 3bbd27b
policy/headers: add descriptions to json schema
davidor 39ab167
policy/cors: add descriptions to the json schema
davidor 6a295cb
policy/caching: add descriptions to the json schema
davidor 2311242
policy manifest and its schema
mikz 6cf0b23
policy: rename json schemas
davidor 3daf081
policy: make schemas conform with the new manifest
davidor c206f3d
CHANGELOG: add entry for policy json manifest
davidor c3f48d6
policy: replace enums with oneOfs in the schemas
davidor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"$schema": "http://apicast.io/policy-v1/schema#manifest#", | ||
"name": "Caching policy", | ||
"description": | ||
["Configures a cache for the authentication calls against the 3scale ", | ||
"backend. This policy support three kinds of caching: \n", | ||
" - Strict: it only caches authorized calls. Denied and failed calls ", | ||
"invalidate the cache entry.\n", | ||
" - Resilient: caches authorized and denied calls. Failed calls do not ", | ||
"invalidate the cache. This allows us to authorize and deny calls ", | ||
"according to the result of the last request made even when backend is ", | ||
"down.\n", | ||
"- Allow: caches authorized and denied calls. When backend is ", | ||
"unavailable, it will cache an authorization. In practice, this means ", | ||
"that when backend is down _any_ request will be authorized unless last ", | ||
"call to backend for that request returned 'deny' (status code = 4xx). ", | ||
"Make sure to understand the implications of that before using this ", | ||
"mode. It makes sense only in very specific use cases.\n", | ||
"- None: disables caching."], | ||
"version": "0.1", | ||
"configuration": { | ||
"type": "object", | ||
"properties": { | ||
"caching_type": { | ||
"description": "Caching mode", | ||
"type": "string", | ||
"oneOf": [ | ||
{ | ||
"const": "resilient", | ||
"description": "Authorize according to last request when backend is down." | ||
}, | ||
{ | ||
"const": "strict", | ||
"description": "It only caches authorized calls." | ||
}, | ||
{ | ||
"const": "allow", | ||
"description": "When backend is down, allow everything unless seen before and denied." | ||
}, | ||
{ | ||
"const": "none", | ||
"description": "Disables caching." | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"$schema": "http://apicast.io/policy-v1/schema#manifest#", | ||
"name": "CORS policy", | ||
"description": "This policy enables CORS (Cross Origin Resource Sharing) request handling.", | ||
"version": "0.1", | ||
"configuration": { | ||
"type": "object", | ||
"properties": { | ||
"allow_headers": { | ||
"description": "Allowed headers", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
"allow_methods": { | ||
"description": "Allowed methods", | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"enum": [ | ||
"GET", | ||
"HEAD", | ||
"POST", | ||
"PUT", | ||
"DELETE", | ||
"PATCH", | ||
"OPTIONS", | ||
"TRACE", | ||
"CONNECT" | ||
] | ||
} | ||
}, | ||
"allow_origin": { | ||
"description": "Origins for which the response can be shared with", | ||
"type": "string" | ||
}, | ||
"allow_credentials": { | ||
"description": "Whether the request can be made using credentials", | ||
"type": "boolean" | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"$schema": "http://apicast.io/policy-v1/schema#manifest#", | ||
"name": "Echo policy", | ||
"description": | ||
["This policy prints the request back to the client and optionally sets ", | ||
"a status code."], | ||
"version": "0.1", | ||
"configuration": { | ||
"type": "object", | ||
"properties": { | ||
"status": { | ||
"description": "HTTP status code to be returned", | ||
"type": "integer" | ||
}, | ||
"exit": { | ||
"description": "Exit mode", | ||
"type": "string", | ||
"oneOf": [ | ||
{ | ||
"const": "request", | ||
"description": "Interrupts the processing of the request." | ||
}, | ||
{ | ||
"const": "set", | ||
"description": "Only skips the rewrite phase." | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"$schema": "http://apicast.io/policy-v1/schema#manifest#", | ||
"name": "Headers policy", | ||
"description": | ||
["This policy allows to include custom headers that will be sent to the ", | ||
"upstream as well as modify or delete the ones included in the original ", | ||
"request. Similarly, this policy also allows to add, modify, and delete ", | ||
"the headers included in the response."], | ||
"version": "0.1", | ||
"configuration": { | ||
"type": "object", | ||
"definitions": { | ||
"commands": { | ||
"description": "List of operations to apply to the headers", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"op": { | ||
"description": "Operation to be applied", | ||
"type": "string", | ||
"oneOf": [ | ||
{ | ||
"const": "add", | ||
"description": "Adds a value to an existing header." | ||
}, | ||
{ | ||
"const": "set", | ||
"description": "Creates the header when not set, replaces its value when set." | ||
}, | ||
{ | ||
"const": "push", | ||
"description": "Creates the header when not set, adds the value when set." | ||
} | ||
] | ||
}, | ||
"header": { | ||
"description": "Header to be modified", | ||
"type": "string" | ||
}, | ||
"value": { | ||
"description": "Value that will be added, set or pushed in the header", | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["op", "header", "value"] | ||
} | ||
} | ||
}, | ||
"properties": { | ||
"request": { "$ref": "#/definitions/commands" }, | ||
"response": { "$ref": "#/definitions/commands" } | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"$id": "http://apicast.io/policy-v1/schema#manifest", | ||
"type": "object", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"definitions": { | ||
"schema": { | ||
"$id": "#/definitions/schema", | ||
"$ref": "http://json-schema.org/draft-07/schema#", | ||
"default": {} | ||
}, | ||
"version": { | ||
"$id": "#/definitions/version", | ||
"type": "string", | ||
"title": "The Policy Version", | ||
"description": "A semantic version of a policy.", | ||
"examples": [ | ||
"1.3.4", | ||
"0.1" | ||
], | ||
"pattern": "^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$" | ||
} | ||
}, | ||
"properties": { | ||
"name": { | ||
"$id": "/properties/name", | ||
"type": "string", | ||
"title": "The Policy Name", | ||
"description": "Name of the policy.", | ||
"examples": [ | ||
"Basic Authentication" | ||
], | ||
"minLength": 1 | ||
}, | ||
"description": { | ||
"$id": "/properties/description", | ||
"oneOf": [ | ||
{ "type": "string", | ||
"minLength": 1 }, | ||
{ "type": "array", "items": { "type": "string" }, | ||
"minItems": 1 | ||
} | ||
], | ||
"title": "The Policy Description", | ||
"description": "Longer description of what the policy does.", | ||
"examples": [ | ||
"Extract authentication credentials from the HTTP Authorization header and pass them to 3scale backend.", | ||
[ "Redirect request to different upstream: ", " - based on path", "- set different Host header"] | ||
] | ||
}, | ||
"version": { | ||
"$ref": "#/definitions/version" | ||
}, | ||
"configuration": { | ||
"$ref": "#/definitions/schema" | ||
} | ||
}, | ||
"required": ["name", "version", "configuration"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "http://apicast.io/policy-v1/schema#manifest#", | ||
"name": "Upstream policy", | ||
"description": "This policy allows to modify the host of a request based on its path.", | ||
"version": "0.1", | ||
"configuration": { | ||
"type": "object", | ||
"properties": { | ||
"rules": { | ||
"description": "list of rules to be applied", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"regex": { | ||
"description": "regular expression to be matched", | ||
"type": "string" | ||
}, | ||
"url": { | ||
"description": "new URL in case of match", | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["regex", "url"] | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to force
$schema
key in this object, so it can be easier for other libraries to use this and know what schema it is.@ddcesare would be good if you could let us know if we need to do this or it can be somehow figured out from the provided schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to force the
$schema
key, the lib figure this out.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that the
lint-schema
target is not working correctly. It's not checking thatconfiguration
complies withhttp://json-schema.org/draft-07/schema#"
.Adding
$schema
in the configuration object does not solve the issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using https://www.jsonschemavalidator.net for validation and it was ok.
But now it fails on missing
$id
in thedefinitions/id
anddefinitions/schema
.Just adding there
"$id": "#/definitions/schema",
and"$id": "#/definitions/version",
makes it validate in that online editor.What other field was not validated correctly? I tried to change the "type" column from "string" to some invalid value and that is caught.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikz When I run
make lint-schema
, the error you mention is not detected. Not sure why.I added those ids in your commit.
Another thing I noticed is that, if I remove the "type" attr from
caching_type
in the caching policy config, https://mozilla-services.github.io/react-jsonschema-form/ complains, butmake lint-schema
does not. The validator that you linked doesn't show any error either.All the rest seems to be working fine.