githubpushpersonal-access-token

Github - Pushing code with Personal Access Token for both Username and Password works


When I was using my PAT (Personal Access Token) in the Username field and in Password field as well, the code was pushed successfully.

Is it an Issue or a Hidden feature in Github to use PAT for both Username and Password?

PS: I would love to use this approach for some reasons since I use multiple Github accounts which cannot be added in system config. But worried if it would cost a security measures.

EDIT 1:

When using PAT, the username field is simply ignored. Tested by providing wrong username with right PAT. It worked.

Could someone explain why would someone implement a feature in such a way?


Solution

  • It is intentional that GitHub allows you to place tokens in the username field as well as the password field, because sometimes people do this and it's nice to make it work. The token is itself sufficient to identify you and the access granted, so a username is strictly not needed (and, if a token is provided, is ignored). You can in fact specify the token in the username with any password as well.

    However, there are several reasons why you should always put it in the password field:

    So I wouldn't classify it as either an issue or a hidden feature. It is intentional that it works, but because many other programs are less fastidious about the security of usernames, it's probably best to avoid it.