發表文章

目前顯示的是有「security」標籤的文章

OAuth 2 - The first sight

圖片
傳統client-server的服務架構,取得受保護資源通常需要向server提供username/password做Authentication。若server又要提供第三方資源給client, 則可以導入Authorization,進而給予不同程度的授權。 Authentication的安全性問題可以讓client預先設定redirection URI或者是讓resource owner確認client身份。 Client 可由  authorization_code  password  client_credentials  refresh_token 其中一中grant_type去取得 Access token 核發Access Token 會帶有以下內容  access_token  token_type e.g.: Bearer  expired_in 幾秒過期  scope 授權範圍  refresh_token refresh_token 可用來申請新的access token,於過期、權限不足...等狀況中使用。在換發新的access token 同時, 因安全考量server也必須將舊的refresh token撤銷。 reference: https://blog.yorkxin.org/posts/oauth2-1-introduction.html

JWT - The first sight

圖片
JWT 是JSON web Token的縮寫,format輕巧又易於跨domain間傳輸,適合restful API這種stateless原則。 JWT 是一個字串,透過.切分成三個 base 64編碼 Header: Token總類與演算法,include token type, hash algorithm, payload: 使用者相關資訊user information,可以設定expired time, 簽發token時間 Signature: 簽章calculate from header, payload and self generated key 驗證流程如下 Client 經由任何一種方式跟Auth Service做驗證 Auth service 回傳JWT token給Client Client 能用該JWT 去call 其他有授權給該token的service 加密的細節在於,Auth service會用自己的private key對user 傳來的header, payload做加密。因此即便使用者解開jwt token並修改payload內容,除了沒有auth service上的private key可以重新encrypt, 加密出來的結果不會ㄓvalidate。不過Token一但被竊取就會被盜用,因此需要搭配expired time來減少風險,並且使用情境減少與安全議題相關的授權操作。 reference: https://jwt.io/introduction

Network Security - The first sight

圖片
為什麼HTTPS相較於HTTP更為安全?使用者是如何與網路服務做加密的傳輸? 示意圖 主流瀏覽器會存著各家廠商Root CA的public key,所以會信任由Root CA簽發digital certificate的網站, Root CA的private key 不會離開Root CA。 所以瀏覽器本身自己就有那些Root CA的public key, 所以才能認證這些有授權的網站。