GithubHelp home page GithubHelp logo

ahazem / tok Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 333 KB

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

License: MIT License

Ruby 87.58% HTML 12.42%

tok's Introduction

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

tok's People

Contributors

ahazem avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.