Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 24, 2019. It is now read-only.

bschaeffer/zero_auth

Repository files navigation

Zero configuration authentication starter for your Rails project.

Installation

Add this line to your application's Gemfile:

gem 'zero_auth'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zero_auth

Usage

Models

ZeroAuth::Model::Password

class User
 include ZeroAuth::Model::Password
 attr_accessor :password_salt, :password_hash
end
user = User.new
user.password = 'password'
user.password_salt # => BCrypt::Engine.generate_salt
user.password_hash # => BCrypt::Password
user.has_password?('password') # => true
user.has_password?('pa$$w0rD') # => false
user.authenticate!('password') # => true
user.authenticate!('pa$$word') # => raises ZeroAuth::Unauthorized
Rails Setup
# migration
change_table :users do |t|
 t.string :password_salt, null: false, default: ""
 t.string :password_hash, null: false, default: ""
end
# model
class User < ActiveRecord::Base
 include ZeroAuth::Model::Password
end
MongoMapper Setup
class User < ActiveRecord::Base
 include MongoMapper::Document
 include ZeroAuth::Model::Password
 key :password_salt, String
 key :password_hash, String
end

Contributing

  1. Fork it (http://github.com/bschaeffer/zero_auth/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 new Pull Request

About

Low configuration authentication modules for Ruby.

Resources

License

Stars

Watchers

Forks

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /