HTTP Authentication

First Authentication and Authorization are different two concept.

 

Http Base Auth

Put user name and password in header which in base64 encoding.

 

 

HTTP Digest Auth

Like Http Base, user name and password encrpt with MD5 digest.

HTTPS Client Authentication

HTTPs & SSL. Client-certificate authentication is a more secure method of authentication than either BASIC or FORM authentication. 

Http OAuth

Instead of user name and password in authorization header, it's put token there.

Form base auth

      User input username and password, GET/POST command contains the content in request body instead of header. Server side check and response with session ID, the follow communication client's request will contain the ID in header.

    • Token Auth

       Almost same as Cookie auth, but server response a token instead of sessionID. 

Base64 details below:

I believe no one use below base64 authentication  in public web site.

Server side

When the server wants the user agent to authenticate itself towards the server, the server must respond appropriately to unauthenticated requests.

To unauthenticated requests, the server should return a response whose header contains a HTTP 401 Unauthorized status and a WWW-Authenticate field.

The WWW-Authenticate field for basic authentication is constructed as following:

WWW-Authenticate: Basic realm="User Visible Realm"

The server may choose to include the charset parameter from RFC 7617:

WWW-Authenticate: Basic realm="User Visible Realm" charset="UTF-8"

Client side

When the user agent wants to send authentication credentials to the server, it may use the Authorization field.

The Authorization field is constructed as follows:

  1. The username and password are combined with a single colon. (:). This means that the username itself cannot contain a colon.
  2. The resulting string is encoded into an octet sequence. The character set to use for this encoding is by default unspecified, as long as it is compatible with US-ASCII, but the server may suggest use of UTF-8.[7]
  3. The resulting string is encoded using a variant of Base64.
  4. The authorization method and a space (e.g. "Basic ") is then prepended to the encoded string.

For example, if the browser uses Aladdin as the username and OpenSesame as the password, then the field's value is the base64-encoding of Aladdin:OpenSesame, or QWxhZGRpbjpPcGVuU2VzYW1l. Then the Authorization header will appear as:

Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

Authentication Schema

Basic Access Authentication

    base64-encoded, e.g. Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

Digest Access Authentication

  MD5 , e.g. WWW-Authenticate: Digest realm="testrealm@host.com", qop="auth,auth-int", nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41“

 

转载于:https://www.cnblogs.com/full-stack-engineer/p/8372432.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值