0.0
No release in over 3 years
Low commit activity in last 3 years
JWT based authorization that includes current_user helper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

~> 3.1.7
>= 0
~> 6.0.2
 Project Readme

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.