Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Added option to remove email domain from usernames #126

Closed
wants to merge 1 commit into from

Conversation

dandelo
Copy link

@dandelo dandelo commented Apr 25, 2018

It's often the case that people will have their email addresses as their IAM usernames and I'd say it's pretty much always the case that they wouldn't want that as part of their local EC2 username.

This allows the option of stripping the domain from their username so user.name@email.com will become simply user.name.
Note that to reverse-engineer the remainder of the username, we look up the IAM users via the cli. This means usernames must be unique, exclusive of the email domain. E.g. my.user@email.com and my.user@anotherEmail.com will not be differentiated and will not be able to use this method.

I'd suggest this become the default behaviour, but have not made that the case in this PR in order to maintain backwards compatibility.

Copy link
Contributor

@michaelwittig michaelwittig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added one inline comment because the current implementation does not get all users, only the first page.

My other concern here is that getting the list of all users additionally will take time which slows down the login procedure (and we already have users complaining about the long waiting times during login).

raw_username=${raw_username//".comma."/","}

if [ "${STRIP_EMAILS_FROM_USERNAME}" -eq 1 ]; then
iam_username=$(aws iam list-users --query "Users[*].[UserName]" --output text | fgrep "$raw_username@")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will only get the first page of users. So with many IAM users, not all users will be returned on the first page.

@davehewy
Copy link

davehewy commented Aug 9, 2018

@michaelwittig do you have any plans to complete the work started here? If not, I could have a go at rehashing? Think enough people would find this useful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants