-
Notifications
You must be signed in to change notification settings - Fork 15
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
JWT Api Key #2371
JWT Api Key #2371
Conversation
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.
Super great work @CDimonaco
I dropped a lot of comments, but most of them are nitpic.
Let me know when the PR is finished so I can do a new review, but most probably everything is alright
- I'm not sure if we should call the main
JWT
asAPP
. In reality it should beAPI
, but I understand that it makes things difficult to differentiate between api and api-key - Remove the
tab
in the docstrings
priv/repo/migrations/20240227102315_add_api_key_settings_to_settings_schema.exs
Show resolved
Hide resolved
Rename api_key_created_at to created_at and api_key_expire_at to expire_at
1174e44
to
8fa99d5
Compare
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.
Super super great @CDimonaco
Ready to merge from my side, but i put some nitpick comments as always.
alias TrentoWeb.OpenApi.V1.Schema | ||
|
||
use OpenApiSpex.ControllerSpecs | ||
plug OpenApiSpex.Plug.CastAndValidate, json_render_error_v2: true | ||
action_fallback TrentoWeb.FallbackController |
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.
well, but deprecated means that it will be removed in some future version, right?
e112969
to
ad43a43
Compare
Description
This PR includes a JWT implementation of the API KEY.
This new implementation allows the rotation of api keys as a result of configurable expiration of api keys.
Expiration could be infinite, where "infinite" is a very reasonable amount of time, because jwt standard wants an expiration timestamp.
This implies the store of JTI, used for token whitelisting and invalidation and creation and expiration date of api tokens, used for key generation, THE JWT KEY IS NOT STORED IN THE DATABASE.
Api key settings are stored into settings table, refactored with current settings as InstallationSettings, following a single table inheritance approach in the settings table.
Installation controller supports operation on the new type of settings, and returns the generated key when needed.
A new Plug for validating api key with jwt, validating issuer and JTI is enabled.
When Trento is installed a default api key with infinite expiration is created
How was this tested?
Automated tests