Here I want to share a JWT Auth Rest API with you
Below I will show the master.key file content, and yes I know that we never can share this, but as this project do not will be in production I will share it with you all guys.
config/master.key (d8e69fa08807a6b75d01af19af3b5dec)
$ rails db:create db:migrate db:seed
The seed creates a default user and password, follow the data below:
email: '[email protected]'
password: '[email protected]'
Now you can use this on [POST] /v1/auth/sign_in
endpoint.
$ rails server
Auth
[POST] /v1/auth/sign_in
Payload:
{
"login": "your-email-here",
"password": "your-password-here"
}
Returns:
{
"is_valid": true
}
[POST] /v1/auth/renew
Payload:
{
"token": "your-token-here"
}
Returns:
{
"is_valid": true
}
[POST] /v1/auth/valid
Payload
{
"token": "your-token-here"
}
Returns:
{
"is_valid": true
}
There is a Rails Scaffold called User that can only be accessed with a valid token on Athorization header.