-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Policy REST API #3302
Policy REST API #3302
Conversation
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.
Looks good, I left a few comments. After they are addressed I will take another look.
Thanks for the review @gernest. Have made suggested changes. |
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 left another comment. We also need tests to cover all the cases.
bc2cbd6
to
2c607a1
Compare
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.
Fix Linter and CI in general and looks solid 👍🏻
Co-authored-by: Geofrey Ernest <geofreyernest@live.com>
Fixes retrieving single policy
273f680
to
5716220
Compare
@@ -85,7 +85,8 @@ type PoliciesConfig struct { | |||
// If you set this value to `true`, then the id parameter in a stored policy (or imported policy using the Dashboard API), will be used instead of the internal ID. | |||
// | |||
// This option should only be used when moving an installation to a new database. | |||
AllowExplicitPolicyID bool `json:"allow_explicit_policy_id"` | |||
AllowExplicitPolicyID bool `json:"allow_explicit_policy_id"` | |||
PolicyPath string `json:"policy_path"` |
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.
Do not forget adding a comment to all fields, since it will be used to auto-generate docs.
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.
Oh didn't know that, adding it
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.
Add comment for PolicyPath
option, otherwise looks good!
* REST API for policies * amend logs in policy loader * handler for path param * fix path load * resolve review issues * tests for handler and cleanup - actually add policy to map when creating * update mutex Co-authored-by: Geofrey Ernest <geofreyernest@live.com> * Fixed retrieving a single Policy (#3315) Fixes retrieving single policy * fixed issues after rebase * fixed test lint issues * ts.run checked * code cleanup * fixed schema model * fixed failing tests for policies * added comments for docs Co-authored-by: Geofrey Ernest <geofreyernest@live.com> Co-authored-by: Sedky Abou-Shamalah <sedkyaboushamalah@gmail.com> Co-authored-by: Milan Vasic <milan.vasic.su@gmail.com> # Conflicts: # gateway/api.go
merged manually to release-4-lts |
This reverts commit 75114d0.
Description
This PR creates a way to manage policies in Tyk CE using a REST API instead of the single file approach currently. It makes policies act in very much the same way as API when using CE. A directory is specified in the Tyk config in the new
policies.policy_path
field. Policies are then stored in that folder with their ID as a filename i.e.default-policy.json
. CRUD operations can be carried out by calling{GATEWAYHOST}:{PORT}/tyk/policies
endpoint with the policy ID passed in the last part of Path.Related Issue
Fixes #2379
Motivation and Context
Means simpler way of managing policies - also unblocks development of Kubernetes Operator for the OSS Gateway.
Types of changes
Checklist
fork, don't request your
master
!master
branch (left side). Also, you should startyour branch off our latest
master
.go mod tidy && go mod vendor
go fmt -s
go vet