
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Rackish authentication for Rack apps.
There is no simple authentication gem in existence. Current ones implement more than what's required, provide poor access to basic auth data, and have too many dependencies.
While I say this general thing about most software, it rings true for this gem. rack-auth
provides a simple addition to Rack::Request
that handles reading the Authorization
header. Nothing more. rack-auth
doesn't try to handle persistence, token generation, nor token granting.
rack/auth
also beats its competitors on amount of code. There's ~60 SLOC in rack/auth
and closer to 500 for other gems.
rack-auth
uses token handlers to allow a developer to write their own token lookup code.
Token handlers are optional, defined by token type and return a hash containing auth information:
# If a handler is not given
# Rack::Request#auth will return client-provided
# auth data in a hash
Rack::Request::AuthHandlers.bearer do |token|
# Look up `token`
end
Rack::Request::AuthHandlers.mac do |token|
# Look up `token`
end
# You probably don't need this handler.
Rack::Request::AuthHandlers.basic do |username, password|
# Look up username and password
end
You can put handlers anywhere, as long as the class variable is assigned before Rack::Request#auth
is called. I'd put them inside a class definition like below. (You should put it anywhere global/semi-global)
class MyApp
### put handlers here
def call env
[200, {}, ["Hello world!"]]
end
end
Then you can access auth information on each Rack::Request
:
r = Rack::Request.new env
r.auth # gets auth from `authenticator` block
r.authenticated! # raises TokenPresenceError if auth is nil (invalid)
r.authenticated?
rack-auth
throws errors:
Rack::TokenPresenceError
- The request is unauthorized.Rack::TokenValidityError
- The authorization is bad.You can catch them and/or use things like Sansom's Sansomable#error
method or Sinatra's error catching contraption
Add this line to your application's Gemfile:
gem 'rack-auth'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-auth
TODO: Write usage instructions here
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that rack-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.