Skip to content

Repository files navigation

SimpleJwtAuth

This gem provides simple jwt authorization for rails API projects by giving you access to POST for users and sessions. Aswell as a current_user helper method.

Installation

Add this line to your application's Gemfile:

gem 'simple_jwt_auth'

And then execute:

$ bundle

Or install it yourself as:

$ gem install simple_jwt_auth

Usage

Models

After installation run

$ rails simple_jwt_auth:setup

this will create a user model in your rails application. As well as creating a file for adding associations and user model methods at app/models/user.rb

then run

$ rails db:migrate

Creating Users

Users can be created by making a POST request to https://localhost:3000/auth/users With name, email, password, and password_confirmation as params

Creating Sessions

Sessions can be created by making a POST request to https://localhost:3000/auth/sessions with email and password as params.

Logged in

Add header called "Authorization" and set it to "Bearer #your-jwt-token-here" include this in any request you want the user to be logged in for. A GET request can then be made to https://localhost:3000/auth/user to return the current user object.

License

The gem is available as open source under the terms of the MIT License.

About

Ruby Gem to add JWT based auth.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages