前言

你經常在網路上搜尋到很多文章標題寫:What is the difference between Authentication and Authorization。

Authentication 意思為驗證;Authorization 意思為授權。這篇文章會大致說明這兩件事情的差異

說明

If you can't prove your identity, you won't be allowed into a resource. (401)

And even if you can prove your identity, if you are not authorized for that resource, you will still be denied access. (403)

實際行為

  1. 使用者使用 User Credentials (帳號密碼) 登入 ⇒ 驗證
  2. 伺服器發送 Token 給 客戶端,客戶端把 token 收好好
  3. 客戶端之後想跟伺服器互動,都得帶著 Token 識別你的身分授權

來源