-
Notifications
You must be signed in to change notification settings - Fork 171
[proxy] split proxy:call() into rewrite and access phase #556
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
Conversation
a5e1346 to
78d3ed4
Compare
gateway/src/apicast/proxy.lua
Outdated
| service = _M.set_service(service or ngx.ctx.service) | ||
|
|
||
| self.oauth = service:oauth() | ||
| function _M:handle_oauth(service) |
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 think we should make this local
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.
Yeah, probably hood idea.
gateway/src/apicast/proxy.lua
Outdated
| self.oauth = service:oauth() | ||
| function _M:handle_oauth(service) | ||
| local oauth = service:oauth() | ||
| self.oauth = oauth |
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.
Maybe this assignment is not needed then.
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.
It is, unless we change something.
There's self.oauth:transform_credentials at the end of rewrite().
We should check if it's possible to move that block of code to handle_oauth.
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.
Yep. It was needed for transform_credentials. Now it returns oauth and is assigned in the :rewrite.
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.
Better 👍
|
Looks good 👍 |
78d3ed4 to
d59864b
Compare
d59864b to
65424b7
Compare
| service.backend_version = 2 | ||
| ngx.var.http_app_key = 'key' | ||
| assert.falsy(proxy:access(service)) | ||
| assert.falsy(proxy:rewrite(service)) |
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.
kind of strange to find rewrite() in describe(':access')
so policies can change the context to add credentials/usage before the authorize call to 3scale backend
65424b7 to
6000cf0
Compare
fixes #495
This allows policy authors to modify
usagein the rewrite phase as it is being used later in theaccessphase. That can be used to for example report custom metrics matched by the policy.