JWT is now become the de-facto standard for authenticating Modern APIs.
This guide will make it dead simple for you to understand JWT:
1. JWT stands for JSON Web Token
2. It's a token that is used to authenticate and authorize users in an application.
"authenticate" means who they're.
"authorize" means what they can access.
The token itself contains, all the necessary information about the user, like user ID and role, etc, in a JSON.
3. JWT tokens are typically generated by the server and sent to the client after a successful login.
The client can then use the JWT token (with each request) to authenticate and authorize itself to the server.
Typically the token looks like this:
4. JWT has three parts:
a) Header (highlighted in red below)
b) Payload (highlighted in pink below)
c) Signature (highlighted in blue below)
On left you can see the encoded token, on right we can see decoded JSON object with 3 parts.
The header typically consists of two parts: the type of the token, which is usually JWT, and the signing algorithm being used, such as HMAC SHA256 or RSA.
The payload contains the claims, which are statements about an entity (typically, the user) and additional metadata.
Claims are typically represented as key-value pairs and can include information such as the user's ID, name, email, and roles.
The signature is used to verify that the sender of the JWT is who it says it is and to ensure that the message has not been tampered with.
Mastering docker will be your best decision as a backend engineer.
But getting started with docker, can be super intimidating.
Here's a 2 min guide, to quickly understand docker and why is it used so widely:
𝟭. 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 𝗦𝗼𝗹𝘃𝗲𝗱 𝗯𝘆 𝗗𝗼𝗰𝗸𝗲𝗿
- Building and Deploying an application is always a challenge for programmers. Specially if you're programming on different OS and deploying on server with different OS.
- There's always a chance of human error causing our application to not work on remote servers.
- This problem becomes even worse when we're working on real world application with tons of module, DB, third party integrations, environment specific configuration.
- This is where docker enters into the picture:
𝟮. 𝗗𝗲𝗳𝗶𝗻𝗶𝘁𝗶𝗼𝗻
- Docker allows developers to build, package, and deploy applications in a consistent and efficient way.
- It provides an easy way to create isolated environments for applications, which can help to avoid conflicts and compatibility issues.
It is a technique, using which we can improve search performance in our database.
When we search for any record in DB, it goes to the index, finds the exact location of the record, skips the unnecessary records in between, and quickly gives us the results.
2. Example
As shown in the diagram, consider a table PRODUCT with ID as the primary key.
Let's say you want to find a product with the 'ID' of 104.
Without indexing, the database would look through each row, one by one, until it finds the product that will fetch results slowly