-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[CLI] add the ability to specify a description for tokens generated with awx login
#6122
Comments
my current workaround is to use awx login and do delete every token with desc "Tower CLI" after ci/cd tower job has run but that means if someone has created an Oauth token via awx login by hand, the next ci/cd run will remove this token if ci/cd is triggered lokal with the users ad user which created first the token |
Are you just trying to generate an OAuth2.0 token, given some username and password? ~ env | grep TOWER_
TOWER_VERIFY_SSL=f
TOWER_HOST=https://example.awx.org:8043
TOWER_USERNAME=ryan
TOWER_PASSWORD=ryan
~/dev/awx awx login
{
"token": "Ym1QA9RMzSolp1XCXC0SE9U0gHGUfK"
}
~ unset TOWER_USERNAME
~ unset TOWER_PASSWORD
~ TOWER_TOKEN=Ym1QA9RMzSolp1XCXC0SE9U0gHGUfK awx me | jq '.results[].username'
"ryan" |
|
as i already said, awx login has no option to specify the description of the token so i can hang up on description = "Tower CLI" because this is the description awx login is adding but that means that if i remove the autogenerated OAuth Tokens after ci/cd finished the tower job, i will remove all OAuth Tokens for the user with description == "Tower CLI" so if a user triggers a manual awx login + job, the next automated ci/cd run for this user will remove his manual created token by awx login so i wanted to create a oauth token with another description then "Tower CLI" from input username:password but this is only possible if i have issued a valid oauth token via awx login .. /reopen |
what i do is basically the following:
so if i use awx login lokal to get a token thats why i want a method to issue a valid oauth token with a custom description from input: --> username:password |
Ah, so you just want to customize the description for the generated token? |
yep that would be a fix for my usecase, sorry for my bad first approach to explain the problem but also a fix would be to make "awx tokens create" support --conf.username TEXT --conf.password TEXT AND i wanted to point out that, maybe this behavior needs a rethink: actually what i want is to ensure that 100 ci/cd runs (with 100x awx login) will not leave 100 valid access tokens behind on awx |
Generally speaking, we don't intend people to constantly run I think this PR might give you what you need. Mind giving it a shot? |
awx login
works for me, closing |
how do you ensure that an ldap user which got disabled yesterday is not able to use awx with a token he ingested last week? the only safe way at the moment to ensure that the user has valid rights for using awx is to log him in via username // password in an ldap setup (i tested the patch with a custom dockerfile which applys those changes via sed onto the dockerhub images, also works for me) |
https://docs.ansible.com/ansible-tower/latest/html/administration/oauth2_token_auth.html
By default, AWX doesn't allow LDAP users to create tokens for this very reason; if at all possible, you may want to consider managing explicit service accounts with tokens in your AWX install instead of user/pass auth. |
ISSUE TYPE
SUMMARY
ENVIRONMENT
STEPS TO REPRODUCE
use cli like the following:
awx --conf.username user --conf.password password tokens create test --scope write --description "automated token generation" -k
EXPECTED RESULTS
successfull token creation
ACTUAL RESULTS
ADDITIONAL INFORMATION
i cant use awx login, because there i can not specify a description for the token
and another problem is, awx login creates everytime a new token, so with a jenkins which triggers a container run which has the awx cli login implemented via user // password, every jenkins trigger will result in a new Oauth token on the account, so somehow i have to delete the token after i created and used it for his purpose, therefore i want to get ids where description == automated tokens and delete those tokens found by id, so i thought i could to this over awx token create, but there the --conf.username --conf.password params are not recognized
on the other side, using only oauth token for ci/cd is not an option, because it has an expire date, so ci/cd will stop working after ~months because oauth token is expired
The text was updated successfully, but these errors were encountered: