-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow setting a token name template on auth methods #19135
Conversation
518da3b
to
8311489
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.
Hi @jorgemarey and thanks for raising this PR, it's looking great. I have taken a first glance over the approach and wanted to discuss a potential change before diving into a full code review. Please let me know if you want me to take over any aspects of the work, which I would be happy to do to get this merged.
This approach uses Go template syntax, however, we also have the option of HIL available which is also used within the binding rule functionality. We could use this existing function which would move the token name format in your example to look something like ${auth_type}-${auth_name}-${claims.user}-${timestamp}
.
I would also like to keep the number of "special" variables down to a minimum and remove the timestamp. ACL tokens already have a creation time parameter, so we should refer to this as the canonical way to view creation times.
It would be nice to get some tests added which exercise the new functionality, so we can ensure we do not break it when making changes in the future.
Thanks also for ensuring the current behaviour is maintained when the user does not supply a format!
Hi @jrasell.
I can do this, no problem.
Yeah, that makes sense, I'll change the template to a HIL format
OK! I'll remove the timestamp
Sure |
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.
This is looking great @jorgemarey and I tested this successfully with Auth0 just now resulting in my tokens being named like OIDC-auth0-jamesrasell
using the token name format. Most of the comments and suggestions are nit-picky and style changes.
I did wonder about your thoughts on the HIL rendering failure not being terminal, and rather log the error and fallback to using the OIDC-Auth0
default format? It feels better that formatting the token name doesn't stop ACL logins entirely, when a template syntax error occurs. Open to discuss this point. Thanks again!
Hi @jrasell I made the requested changes. With respect to the HIL rendering failure, I don't know what to do. On one hand, the operator expects the token to have that format and maybe it's important for them that all tokens have it. On the other hand, not allowing access to someone that has a correct binding just for that don't know if it's the right decision. We could check the HIL in the auth method creation, but that doesn't solve all problems as the claims configured in the name format could not be present in the JWT. I think that I'm leaning towards let this fail and not login the user (a incorrect bindName will do the same) but I leave the final decision to you, let me know. |
1 similar comment
Hi @jrasell I made the requested changes. With respect to the HIL rendering failure, I don't know what to do. On one hand, the operator expects the token to have that format and maybe it's important for them that all tokens have it. On the other hand, not allowing access to someone that has a correct binding just for that don't know if it's the right decision. We could check the HIL in the auth method creation, but that doesn't solve all problems as the claims configured in the name format could not be present in the JWT. I think that I'm leaning towards let this fail and not login the user (a incorrect bindName will do the same) but I leave the final decision to you, let me know. |
Hi again @jrasell I added the changes to the documentation. I don't know if I should change also the auth-method.js files accordingly. |
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.
LGTM, thanks so much for this addition @jorgemarey!
One final item I just thought about; when upgrading a cluster with existing auth methods, the token name format will be an empty string. I think we will need to handle this within the formatting function, so that an empty string is returns a token name that is the default and existing behaviour.
Hi @jrasell,
You're right, I'll make the change for that. |
…omad into f-token-name-template
Hi @jrasell I made that change. There's only a thing that I don't know if we should change. If you make a request to the API the token format will be empty if it was created previously, should we change that? |
I am happy with that behaviour existing; if anyone really has a reason to change that, we can do that on a follow up. It also works quite well in the CLI in my opinion, making it obvious there is not format set:
|
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.
LGTM and amazing work @jorgemarey, thanks so much!
I've tested this change in standalone and via an upgrade path to confirm the behaviour works as expected.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Fixes #19134 by allowing the set a token-name-template when creating auth methods
Documentation is pending this is set given an OK.
As an example. Currently this is the nomad auth:
With this change users can do the following: