I read everywhere (and see in practice) that usernames should not be changeable. When I ask why, ‘security’ is given as a reason.
I’ve been searching for a definitive answer as to why changing a username is insecure, but I can’t seem to find the answer.
Could any of the security experienced people here answer this question?
Note: if you do not know the answer, please refrain from speculation. I’ve thought of a number of reasons myself, but I don’t know the actual answer, hence the question.
UPDATE:
1: By userId I meant to refer to some sort of unique identifier, be it a database record id or some other unique id. I’ve been told several times that changing the username is bad for security, even if the username is not the primary/unique identifier for the system itself.
2: I do allow users to change their ‘public name’. This is the name that is used to identify the user to the other (non-privileged) users.
for example:
userId: 1234
username: john02
public name: John Jameson
email: j.jameson@dev.null
3: As pointed out by Jason and The Rook, consistency seems the only good reason. I’ve the feeling this ‘best practice’ might be a leftover from somewhere in the past when usernames where actually used within the system to uniquely identify users.
There are a number of reasons from a security aspect that you may not wish to allow users to change their names. However, as an all-out “NEVER do this” – I don’t necessarily agree. But, allowing name changes creates quite a bit of extra work. If you are going to allow users to change their identities, you have to be very careful due to the reasons below.
Anyway, as I said – I don’t believe it’s necessarily a bad thing to allow users to change their names. However, it does create quite a bit more work for you, the developer. User names now can’t be unique IDs in a database and user names now don’t necessarily relate to someone (because they can be changed later), so you have to have a different system in place for expressing “uniqueness.”