JSON Web Token is a proposed Internet standard for creating data with optional signature and/or optional encryption whose payload holds JSON that asserts some number of claims. The tokens are signed either using a private secret or a public/private key
-
Ruby is installed (v 3.0.0)
-
Rails is installed (v 7.0.3)
-
MySQL is installed
-
Git is installed
-
GitHub account is created
-
Setup a new Rails app
-
Database configuration setup (using MySQL)
-
Initialize a local repository using git
-
gitignore file created to add configuration.yml
-
configuration.yml file created to initialize environment variables
-
Create a new remote repository using GitHub
-
Change README.md and documentation added
-
Code Commited and Pushed to GitHub repository
- Go to the config directory
- Create a new file with name configuration.yml
Here are the variables we need to define in this file:
JWT_DB_DEVELOPMENT: development_db_name
JWT_DB_DEVELOPMENT_USERNAME: development_db_username
JWT_DB_DEVELOPMENT_PASSWORD: development_db_password
JWT_DB_PRODUCTION: production_db_name_xxx
JWT_DB_PRODUCTION_USERNAME: production_db_username_xxx
JWT_DB_PRODUCTION_PASSWORD: production_db_password_xxx
JWT_DB_TEST: test_db_name
Start Project
$ rails new jwt -d mysql
After you create the jwt application, Go to the project directory
$ cd jwt
Start server
$ rails server
or
$ rails s
Create Controller
$ rails g controller users index new show edit
Create Model
$ rails g model email password_digest
gem "bcrypt"
Jwt gem File
gem 'jwt'
bundle install