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

feat: add order of the JWT source header/cookie/query as config #71

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

simonpahl
Copy link
Contributor

With this PR it is posible to control the order how the JWT is resolved from header, cookie or query parameter.

@simonpahl simonpahl force-pushed the jwtSourcePrirority branch 2 times, most recently from 0698236 to 0bfb9ae Compare June 28, 2024 12:09
Copy link
Member

@eshepelyuk eshepelyuk left a comment

Choose a reason for hiding this comment

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

  1. First issue is missing unit tests.
  2. Second I'd like propose a deeper change, instead of having several parameters to configure order and source of token extraction - i think about boling it down to one parameter that could look like
JwtSources:
- bearer:MyAuth # value from http header in format Bearer: TOKEN
- header:MyJwt # plain value of http header
- cookie:MyCookie # plain value of cookie
- query:MyQuery # plain value of query string parameter

WDYT ?

@simonpahl simonpahl force-pushed the jwtSourcePrirority branch from 0bfb9ae to 72addc1 Compare June 29, 2024 07:12
@simonpahl
Copy link
Contributor Author

simonpahl commented Jun 29, 2024

I like the idea and i am working on it. I've pushed my progress so far. One problem is preserving the order, als pure maps can't do that. The current idea for the config is

JwtSources:
  - type: bearer
    key: Authorization
  - type: cookie
    key: ...

@simonpahl simonpahl force-pushed the jwtSourcePrirority branch 2 times, most recently from 42dc5c9 to ed7fc6d Compare June 29, 2024 09:35
@simonpahl
Copy link
Contributor Author

Ok, i think it is done.

Copy link
Member

@eshepelyuk eshepelyuk left a comment

Choose a reason for hiding this comment

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

  1. can you mark deprecated parameters also in plugin code, i think godoc should have some sort of deprecation tags.
  2. should not the default value of order be initialized in CreateConfig function ?

@simonpahl simonpahl force-pushed the jwtSourcePrirority branch from ed7fc6d to 339b7af Compare June 29, 2024 13:09
The config field is called JwtSources,
the format is [{type: ...., key: ...},]
Possible types are bearer, header, cookie, query.
The order of the list enty is the order in wich the JWT wil be tried to
retrieved.
@simonpahl simonpahl force-pushed the jwtSourcePrirority branch from 339b7af to cbc7555 Compare June 29, 2024 13:20
@simonpahl
Copy link
Contributor Author

  1. I have marked it like described here https://go.dev/wiki/Deprecated
  2. I don't think i could implement the backwards copatibility to JwtCookieKey and JwtQueryKey this way

@eshepelyuk
Copy link
Member

  1. I have marked it like described here https://go.dev/wiki/Deprecated
  2. I don't think i could implement the backwards copatibility to JwtCookieKey and JwtQueryKey this way

understood, thanks

@eshepelyuk eshepelyuk merged commit 7b34924 into traefik-plugins:main Jun 29, 2024
1 check passed
@eshepelyuk
Copy link
Member

Thanks for anither great contributions, availablein 0.9.0 version.

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