Project

groot

0.0
No commit activity in last 3 years
No release in over 3 years
Simple token authentication and authorization solution for Rails with JWT.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3

Runtime

>= 3.1.7, ~> 3.1
>= 1.5.6, ~> 1.5
>= 5.0.0, ~> 5.0
 Project Readme

Groot

Groot is a simple gem to help you authenticate using JWT.

Installation

Add it to your Gemfile:

gem 'groot'

Run the following command to install it:

bundle install

Run the generator:

rails generate groot:install

Usage

In the following command you should replace MODEL with your user application class

rails generate groot:auth MODEL

Take a look at the MODEL and if you want, you can add any additional configuration to it. Add the following line to your routes.rb file (assuming your model is 'Admin'):

    auth_for :admins 

It will create the routes to Groot controllers.

Filter and Helpers

Groot will create a filter for user authentication, to configure it just add the following line to your controller: (assuming again that your model is Admin):

before_action :authenticate_admin!

Groot will also create some helpers to make your life easier.

To get the current signed-in user:

current_admin

To verify if there is a user signed in:

admin_signed_in?

ORMs

So far Groot only supports ActiveRecord.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/alissonbrunosa/groot.

License

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