Skip to content

Wrap HTTP authentication in more tender UIs via Rack middleware

License

Notifications You must be signed in to change notification settings

foca/rack-unbasic

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rack::Unbasic

Wraps HTTP authentication in more friendly workflows.

Usage

require "rack-unbasic"

use Rack::Unbasic do |on|
  on.bad_request '/login'
  on.unauthorized '/login'
end

A response with a 401 or 400 status code will be redirected to the routes you specify in the config, with the \env['rack-unbasic.code'] set to whatever the original status code was, and \env['rack-unbasic.return-to'] set to whatever the requested URI was.

When a request comes in with :username and :password params, those will be mapped to basic auth credentials, and the appropriate headers will be added.

Once authorized, the appropriate credentials will be stashed in the session. Subsequent requests will use the credentials in the session for authorization.

Install

gem install rack-unbasic

Or cloning the git source repository:

git clone git://github.com/foca/rack-unbasic.git

Credits

Idea

Pat Nakajima (github)

Initial implementation

Nicolás Sanguinetti (github)

License

MIT. See attached LICENSE file.

About

Wrap HTTP authentication in more tender UIs via Rack middleware

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Ruby 100.0%