reading-notes


Project maintained by Razan-am Hosted on GitHub Pages — Theme by mattgraham

Authorization/Authentication

What header(s) are used in authentication and authorization

  1. Basic Auth: Authorization header that contains the word Basic, followed by a space and a base64-encoded(non-encrypted) string username: password.

Authorization: Basic AXVubzpwQDU1dzByYM==

Base64 encoding does not mean encryption or hashing!

  1. Bearer Token: Bearer Authentication gives access to the bearer of this token.

Authorization: Bearer

  1. API Key: API key auth, you send a key-value pair to the API either in the request headers or query parameters.

GET /endpoint?api_key=abcdefgh123456789

  1. Digest Auth:Digest Authentication communicates credentials in an encrypted form by applying a hash algorithm to the username and the password, the password is converted to response and then it is sent to the server.

Authorization: Digest username=”admin” Realm=”abcxyz” nonce=”474754847743646”, uri=”/uri” response=”7cffhfr54685gnnfgerg8”

  1. OAuth 2.0: you first retrieve an access token for the API, then use that token to authenticate future requests.

Authorization: Bearer hY_9.B5f-4.1BfE //where “hY_9.B5f-4.1BfE” is your OAuth Access Token

  1. Hawk Authentication: Hawk authentication enables you to authorize requests using partial cryptographic verification.

Authorization: Hawk id=”abcxyz123”, ts=”1592459563”, nonce=”gWqbkw”, mac=”vxBCccCutXGV30gwEDKu1NDXSeqwfq7Z0sg/HP1HjOU=”

  1. AWS Signature: AWS is the authorization workflow for Amazon Web Services requests. AWS uses a custom HTTP scheme based on a keyed-HMAC Hash Message Authentication Code for authentication.

Authorization: AWS4-HMAC-SHA256 Credential=abc/20200618/us-east-1/execute-api/aws4_request, SignedHeaders=host;x-amz-date, Signature=c6c85d0eb7b56076609570f4dbdf730d0a017208d964c615253924149ce65de5

What is safe to put into a JWT

  1. Registered Claims:
    • subject: identifies the principal that is the subject of the JWT. Must be unique
    • expiration time: identifies the expiration time after which you must no longer accept this token.
  2. Public claims:
    • with public names or names registered which contain values that should be unique like email, address or phone_number
  3. Private claims to use in your own context and values can collision

How are JWTs validate


Terms


References:

@By Ankit Singh/Authorization header

@By stackoverflow/What to store in a JWT?

@By ANGULAR UNIVERSITY/JWT: The Complete Guide to JSON Web Tokens