cli icon indicating copy to clipboard operation
cli copied to clipboard

add username flag for token command

Open billiford opened this issue 2 years ago • 5 comments

This PR allows us to pass the username as a flag to the rancher token command so it does not need to be input each time. This is helpful in Kubernetes configs when defining the login command for a given cluster.

Example

$ ranch token --server=my-server --user=my-user --cluster=my-cluster --auth-provider=activeDirectoryProvider --username=my-username
Enter credentials for activeDirectoryProvider

Enter password:

As we can see it no longer asks for a username if one is passed in.

billiford avatar Mar 14 '24 17:03 billiford

In our environment there is no relation. It is setup so the userId is the name of the cluster and is therefore the same for everyone connecting to that cluster. Since we're using an auth provider, the username is what's passed to Active Directory to identify the client during login.

billiford avatar Mar 18 '24 12:03 billiford

Does it make sense to support --password or RANCHER_PASSWORD env variable. I think this is valid in non-interactive process like CICD.

elaijuh avatar Apr 18 '24 14:04 elaijuh

Why not support both? The --password flag is useful for my kubectl config login command.

billiford avatar Apr 18 '24 14:04 billiford

@billiford will you add password support as well? maybe name them --authUser and --authPassword to differentiate from --user

elaijuh avatar Apr 18 '24 16:04 elaijuh

I'd be happy to change this to --authUser in this PR, but I think anything involving a password should take place in a separate PR.

billiford avatar Apr 18 '24 22:04 billiford