Skip to content

Add the support of bypassing JWT authn for CORS preflight requests#6181

Closed
lei-tang wants to merge 2 commits intoenvoyproxy:masterfrom
lei-tang:support-bypass-jwt-authn-for-cors
Closed

Add the support of bypassing JWT authn for CORS preflight requests#6181
lei-tang wants to merge 2 commits intoenvoyproxy:masterfrom
lei-tang:support-bypass-jwt-authn-for-cors

Conversation

@lei-tang
Copy link

@lei-tang lei-tang commented Mar 6, 2019

Description: Per the spec http://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0,
CORS pre-flight requests shouldn't include user credentials. This PR adds the support of bypassing JWT authn for CORS flight requests.

Risk Level: low

Testing: test is in test/extensions/filters/http/jwt_authn/filter_integration_test.cc

Docs Changes:
Release Notes:
[Optional Fixes #Issue]
[Optional Deprecated:]

qiwzhang
qiwzhang previously approved these changes Mar 6, 2019
@lei-tang lei-tang force-pushed the support-bypass-jwt-authn-for-cors branch from b6f5993 to 180cd2d Compare March 6, 2019 00:23
Copy link
Member

Choose a reason for hiding this comment

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

nit: getStringView instead of c_str()

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

I think this bypass too much request by blindly accepting all OPTIONS method, OPTIONS are not only used for CORS, it need additional check or guarded by configuration.

Copy link
Author

Choose a reason for hiding this comment

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

Do you have a recommendation for additional check?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

btw I think this can be achieved with config change and deosn't require code change, no? @qiwzhang

Per the spec http://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0,
CORS pre-flight requests shouldn't include user credentials.

Signed-off-by: Lei Tang <32078630+lei-tang@users.noreply.github.com>
@lei-tang lei-tang force-pushed the support-bypass-jwt-authn-for-cors branch from 180cd2d to e1219af Compare March 6, 2019 00:31
Signed-off-by: Lei Tang <32078630+lei-tang@users.noreply.github.com>
@lei-tang lei-tang force-pushed the support-bypass-jwt-authn-for-cors branch from 2185d62 to ed87358 Compare March 6, 2019 00:40
@qiwzhang
Copy link
Contributor

qiwzhang commented Mar 6, 2019

@lizan you are right. We don't need to make such code change. If users want to bypass all OPTIONS, they can create a rule in the config to match all OPTIONS and bypass them.

@arpitshah29
Copy link

@qiwzhang & @lizan - Can you please help me understand what config rule are you talking about? As far as I understood the JWT Authen filter implementation - JWT verification can only be suppressed by Routes and not by Method? Please correct me if I am wrong.

@qiwzhang
Copy link
Contributor

qiwzhang commented Mar 7, 2019

@arpitshah29 you can use route_match to specify a match condition, and by not providing a jwt_requirement to bypass jwt checking. I believe you can create a route_match to match all option calls.

@arpitshah29
Copy link

@qiwzhang - Thanks for quick response, While I understand what you are saying - but IMHO route match would be handy for a one-off scenario where jwt_authn needs suppression like health checker and so on... what about the case where we can have thousands of routes? won't that be an overhead to route match each and every route for exclusion?

Appreciate your feedback.

@qiwzhang
Copy link
Contributor

qiwzhang commented Mar 7, 2019

Route match is very flexible. For example if has path_prefix, and regex, if you define your path_prefix as "/", it will match all paths.

@stale
Copy link

stale bot commented Mar 14, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Mar 14, 2019
@stale
Copy link

stale bot commented Mar 21, 2019

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot closed this Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale stalebot believes this issue/PR has not been touched recently

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants