Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP/HTTPS basic authentication: colon in username

Tags:

http

https

This may be a basic question, but is it possible to have colon (":") in username when there is HTTP or HTTPS basic authentication ? If not, is there a way we can escape colon ?

like image 422
Chris Avatar asked Jul 23 '12 12:07

Chris


People also ask

What is HTTP auth username?

HTTP basic authentication is a simple challenge and response mechanism with which a server can request authentication information (a user ID and password) from a client. The client passes the authentication information to the server in an Authorization header. The authentication information is in base-64 encoding.

How do I pass username and password in HTTP header?

1 Answer. It is indeed not possible to pass the username and password via query parameters in standard HTTP auth. Instead, you use a special URL format, like this: http://username:[email protected]/ -- this sends the credentials in the standard HTTP "Authorization" header.

How do I encode basic authentication?

To encode your credentials, type your username and password into this form, using the format username:password . Your encoded credentials will appear underneath. The encoding script runs in your browser, and none of your credentials are seen or stored by this site.


2 Answers

the RFC https://www.rfc-editor.org/rfc/rfc2617#section-2 states clearly that the username must not include a colon:

To receive authorization, the client sends the userid and password, separated by a single colon (":") character, within a base64 [7] encoded string in the credentials.`

basic-credentials = base64-user-pass

base64-user-pass = <base64 [4] encoding of user-pass, except not limited to 76 char/line>

user-pass = userid ":" password

userid = * <TEXT excluding ":">

password = *TEXT

Based on this, there is no way to use a colon within the username.

like image 127
chrobs Avatar answered Sep 19 '22 12:09

chrobs


Looking at RFC - https://www.rfc-editor.org/rfc/rfc2617#section-2 and around the web, there doesn't seem to be escaping technique for colon in username. The only place extra you can have it is in password field.

If it is an option, you maybe can replace : with @ in auth level and ask users to do this.

like image 27
Jure C. Avatar answered Sep 22 '22 12:09

Jure C.