Skip to content
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

[proxy] split proxy:call() into rewrite and access phase #556

Merged
merged 1 commit into from
Jan 31, 2018

Conversation

mikz
Copy link
Contributor

@mikz mikz commented Jan 18, 2018

fixes #495

This allows policy authors to modify usage in the rewrite phase as it is being used later in the access phase. That can be used to for example report custom metrics matched by the policy.

@mikz mikz force-pushed the proxy-split-rewrite-access branch 2 times, most recently from a5e1346 to 78d3ed4 Compare January 22, 2018 12:46
@mikz mikz mentioned this pull request Jan 31, 2018
service = _M.set_service(service or ngx.ctx.service)

self.oauth = service:oauth()
function _M:handle_oauth(service)
Copy link
Contributor

@davidor davidor Jan 31, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably hood idea.

self.oauth = service:oauth()
function _M:handle_oauth(service)
local oauth = service:oauth()
self.oauth = oauth
Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better 👍

@davidor
Copy link
Contributor

davidor commented Jan 31, 2018

Looks good 👍

@mikz mikz force-pushed the proxy-split-rewrite-access branch from 78d3ed4 to d59864b Compare January 31, 2018 14:27
@mikz mikz changed the title [wip] split proxy:call() into rewrite and access phase [proxy] split proxy:call() into rewrite and access phase Jan 31, 2018
@mikz mikz force-pushed the proxy-split-rewrite-access branch from d59864b to 65424b7 Compare January 31, 2018 14:43
@@ -61,7 +29,7 @@ describe('Proxy', function()
service.credentials = { location = 'headers' }
service.backend_version = 2
ngx.var.http_app_key = 'key'
assert.falsy(proxy:access(service))
assert.falsy(proxy:rewrite(service))
Copy link
Contributor

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
@mikz mikz force-pushed the proxy-split-rewrite-access branch from 65424b7 to 6000cf0 Compare January 31, 2018 15:20
@mikz mikz merged commit 6cbb2e3 into master Jan 31, 2018
@mikz mikz deleted the proxy-split-rewrite-access branch January 31, 2018 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Policies should be able to extend credentials
2 participants