2016年2月18日 星期四

Basic access authentication

For detail information, we can check https://en.wikipedia.org/wiki/Basic_access_authentication


In the context of an HTTP transaction, basic access authentication is a method for an HTTP user agent to provide a user name and password when making a request.
 

Client side

When the user agent wants to send the server authentication credentials it may use the Authorization field.[7]
The Authorization field is constructed as follows:[8][9][10]
  1. The username and password are combined into a string separated by a colon, e.g.: username:password
  2. The resulting string is encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line.
  3. The authorization method and a space i.e. "Basic " is then put before the encoded string.
For example, if the user agent uses Aladdin as the username and OpenSesame as the password then the field is formed as follows:
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

For Base64 encoding detail information, it can check https://en.wikipedia.org/wiki/Base64.  For Base64 implementation, it can use Convert.ToBase64String with C#, and CryptBinaryToString with C++.