TanmoySG / wunder-identity-provider

ID Provider for Wunder Platform. Authentication & Authorization Server for all wunder products
3 stars 0 forks source link

[Sub Component] JWT Based-Authentication #54

Closed TanmoySG closed 2 years ago

TanmoySG commented 2 years ago

JWT or JSON Web Tokens are used to authenticate APIs and are provisioned when a user logs-in with Email and Password. JWT is used to remove or reduce the use of Password for authentication for all tasks.

Refer to this and Check Issue #53's Comments

[Parent Component]

[Checkpoints]

[Resources]

[Code Snippet for PyJWT Library]

A sample JWT implementation using pyJWT.

import jwt

encoded_jwt = jwt.encode({"Name": "User"}, "secret", algorithm="HS256")
print(encoded_jwt)

decoded_info = jwt.decode(encoded_jwt, "secret", algorithms=["HS256"])
print(decoded_info)

Returns

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJOYW1lIjoiVXNlciJ9.uXewJOSSW5TQ6JtVHrhX-1joVkrK38OGG6T5rrHVFuM
{'Name': 'User'}
TanmoySG commented 2 years ago

Using pyjwt

Documentation https://pyjwt.readthedocs.io/en/stable/installation.html

TanmoySG commented 2 years ago

Using HS512 as default Algorithm. Using default_random_secret for sample secret.