Project

tok

0.0
No commit activity in last 3 years
No release in over 3 years
The token-based authentication library for the ambitious.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.1
~> 1.7
~> 0.17
~> 10.0

Runtime

>= 0
~> 4.0
~> 0.2
 Project Readme

Tok

No-frills token-based authentication for modern Rails applications.

Installation

Tok works with (and is tested against) Rails > 4.0. To install, add this line to your Gemfile:

gem 'tok'

Then run bundle install. You can always install the gem yourself by executing:

$ gem install tok

Usage

First, run the generator by executing:

$ rails generate tok:install

The generator by default does the following:

  • Inserts Tok::Authentication into User model (or creates one if not available)
  • Inserts Tok::Controller into your ApplicationController
  • Creates a number of default routes signup, login, and logout
  • Creates an initializer at config/initializers/tok.rb to allow further configuration

A custom model can be specified by passing --model (or just -m) as an option to the generator:

$ rails generate tok:install -m Account
$ rails generate tok:install --model=Account

In this case, the generator will also create a migration in order to create a table with the specified model pluralized.

Next, run migrations by executing:

$ rake db:migrate

Configure

To configure Tok, you can override defaults in your config/initializers/tok.rb. Be sure to check the initializer for further details into what values are used by default.

# Use the following configuration block to adjust Tok.
Tok.configure do |config|
  config.model = Account
  config.bcrypt_cost = 8 
  config.signup_route = "sign_up"
  config.login_route = "sign_in"
  config.logout_route = "sign_out"
end

Contributing

  1. Fork it ( https://github.com/[my-github-username]/tok/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request