Project

zero_auth

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Zero configuration authentication starter for Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.5
>= 0
~> 3.0
>= 0

Runtime

~> 3.1.7
 Project Readme

ZeroAuth Build Status Inline docs

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