-
Notifications
You must be signed in to change notification settings - Fork 8
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
Technical Question: should we use a JWT
for AUTH_API_KEY
?
#268
Comments
I don't think it makes much sense to have info like However, the A similar thing happens when working with OpenID Connect. If I have a client, a server and an identity provider like Keycloak, for example, the server uses in deployment a key as env variable that the identity provider issues, so it knows the server is legitimate. This key doesn't need to be a JWT. However, if I were to use an OIDC (OpenID Connect) flow for users to authenticate in the server... the interactions between the client and the server are made through JWT tokens. But the web server securely communicates with the identity provider to check if the issued ID tokens and Access Tokens (part of the OIDC authentication flow) are legitimate. And the only reason the identity provider is the provider for the server, is because it gave the server "a key" so it knows it's a legitimate application to be communicated with. This happens during deployment and does not necessarily mean the key is a JWT. tldr:
|
@LuchoTurtle thanks for your insightful reply. 👌 To the person using Hmm ... I'm still not "sold" on this in terms of cost-benefit. 🤔 |
I'm adding a bit more context as it took me a bit of time to understand the question: To be able to use the The auth/lib/auth_web/controllers/app_controller.ex Lines 14 to 30 in 83c286a
Which calls Lines 96 to 108 in 83c286a
Which then calls Lines 36 to 38 in 83c286a
Finally Lines 27 to 29 in 83c286a
@spec encrypt(any) :: String.t()
def encrypt(plaintext) do
Lines 65 to 77 in 83c286a
But to come back to the auth api key we see that it is created using Now when a user authenticate the
Now to come back to the error describe above #268 (comment)
It is defined here: auth/lib/auth_web/controllers/auth_controller.ex Lines 17 to 30 in 83c286a
By calling auth/lib/auth_web/controllers/auth_controller.ex Lines 81 to 95 in 83c286a
I think the error message could be better, something like "the auth_api_key used with auth_plug is not linked to any applications on the auth app"?
Lines 44 to 52 in 83c286a
Looked again and the But I don't think it makes sense to use jwt for the auth api key. I can't see a use case where we want to define an expired time to be then checked on the application with Let me know if all this makes sense. |
Thanks for the comprehensive explanation @SimonLab , makes much more sense now. I had some run-ins with this error but now knowing how it works helps a lot! |
Thanks for both your feedback on this. Very good that we're all thinking on similar lines. 💭 |
@SimonLab thanks for stepping through the existing code to give context. |
Since some of this discussion was migrated to #277, should this issue be closed? The usage of the very existence of an Although it's confirmed in #277 (comment) that we'll have an |
Indeed. Not using |
At present an
AUTH_API_KEY
has the format:The reason I wet with this and still like it is because it's human-readable
and immediately obvious which environment (
auth instance
) it's for; in this case:authdemo.fly.dev
So if I see this key in my
.env
file or environment variable, I know exactly what it's for. 👌I think this has a pretty major advantage in terms of Developer Experience ... 💭
But equally it has a disadvantage: no embedded info like
expiry
.We outlined the benefits of
JWTs
in our mega-popular doc: https://github.com/dwyl/learn-json-web-tokensAnd we are using them in
auth
for session tokens:auth/lib/auth_web/controllers/auth_controller.ex
Line 200 in 83c286a
So my question is: should the next version of
auth
(andauth_plug
) use aJWT
as theAUTH_API_KEY
?Will having a
JWT
for theAUTH_API_KEY
and a differentJWT
for session token be confusing to devs? 🤷♂️Are we missing something?
Please let me know your thoughts ... 💭 🙏
The text was updated successfully, but these errors were encountered: