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

Expose jwt in the policies context #718

Merged
merged 5 commits into from
May 18, 2018
Merged

Conversation

davidor
Copy link
Contributor

@davidor davidor commented May 18, 2018

This PR exposes jwt in the policies context in OAuth flows.

This is useful because it allows other policies to access those tokens. For example, the rate-limit policy ( #713 ) could benefit from this.

This PR also adds an integration test that uses OAuth and the headers policy and shows how it can set some headers with information extracted from the decoded jwt.

@davidor davidor requested a review from mikz May 18, 2018 09:35
@davidor davidor changed the title Expose jwt in the policies context [WIP] Expose jwt in the policies context May 18, 2018
@davidor davidor force-pushed the expose-jwt-tokens-context branch from 01cebd8 to 0ed50f1 Compare May 18, 2018 10:17
@davidor davidor changed the title [WIP] Expose jwt in the policies context Expose jwt in the policies context May 18, 2018
# Make fixtures policies available. There is a test that needs the "decode
# oidc token" example policy.
BEGIN {
$ENV{TEST_NGINX_APICAST_POLICY_LOAD_PATH} = 't/fixtures/policies';
Copy link
Contributor

Choose a reason for hiding this comment

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

No longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. Fixed 👍

@davidor davidor force-pushed the expose-jwt-tokens-context branch from 258c116 to 8470225 Compare May 18, 2018 10:44
{
"issuer": "https://example.com/auth/realms/apicast",
"config": {
"public_key": "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALClz96cDQ965ENYMfZzG+Acu25lpx2KNpAALBQ+catCA59us7+uLY5rjQR6SOgZpCz5PJiKNAdRPDJMXSmXqM0CAwEAAQ==",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mikz Ideas to avoid hardcoding it here?

Copy link
Contributor

@mikz mikz May 18, 2018

Choose a reason for hiding this comment

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

You can do eval filter and use Perl to read it and interpolate it.

Copy link
Contributor

Choose a reason for hiding this comment

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

this could possibly work:

 <<"JSON";
{ 
 "oidc": ...
   "public_key": "$::rsa"
}
JSON

Copy link
Contributor

@mikz mikz left a comment

Choose a reason for hiding this comment

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

👍 This is great 👍

@davidor davidor merged commit 8540a8a into master May 18, 2018
@davidor davidor deleted the expose-jwt-tokens-context branch May 18, 2018 12:39
@davidor davidor mentioned this pull request May 18, 2018
@mikz mikz mentioned this pull request Jun 12, 2018
4 tasks
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.

2 participants