No commit activity in last 3 years
No release in over 3 years
Htauthentication lets you authenticate users by an htpasswd file.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 4.0.0
 Project Readme

Htauthentication

Htauthentication lets you authenticate users by a htpasswd file.

Installation

Running fast:

gem install htauthentication

Or hook up your Gemfile:

gem 'htauthentication', '~> 1.0.0'

Classes

class User < ActiveRecord::Base
  has_htpasswd_login
end

Constant

HTPASSWD_PATH = "/path/to/htpasswd"

Usage

@user = User.new(username: params[:username])
@user.authenticate_by_htpasswd(params[:password])

The second line returns true or false, depending on whether the authentication by the htpasswd file was successful. If true: sets @user.htpasswd_logged_in = true, otherwise = false.

By default Htauthentication uses the attribute "username" to authenticate. If you want to use an alternative attribute you can add its name as another parameter.

@user.authenticate_by_htpasswd(params[:password], "email")