Skip to content

iparsrc/log-in-system-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-log-in-system-jwt

In this simple JWT authorization system, you can create an in-memory user and get a valid JWT for one hour.
If you have the valid access token, then you can get the user information. Otherwise you will get an error.
There are only three endpoints:

/ping  
/users/create  
/users/profile  

/ping

Send a GET request.
Returns a text/plain:

pong

This is simply to check if the server is running or not.

/users/create

Send a POST request with a json body:

{  
  "name": "Parsa Akbari",  
  "email": "[email protected]",  
  "password": "12345"  
}  

Returns an application/json and saves the JWT as a cookie:
If succeed:

{  
  "id": "<user-id>",  
  "name": "<user-name>",  
  "email": "<user-email>"  
}  

If the user already exists:

{  
  json containing the error.  
}  

/users/profile

Send a GET request.
Returns an application/json:
If jwt is valid:

{  
  "id": "<user-id>",  
  "name": "<user-name,  
  "email": "<user-email>"  
}  

Else:

{  
  json containing the error.  
}    

About

Simple JWT authentication and authorization.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages