Skip to content
A lightweight authorization library for Ruby on Rails that protects your routes with a simple password form.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Balrog logo

Balrog is a lightweight authorization library for Ruby on Rails written by Pixie Labs that can protect your routes with a single username & password combination.

Balrog is an alternative to http_basic_authentication_with that provides some advantages:

  • Uses a password hash instead of a plaintext password.
  • Provides a lightweight HTML form instead of inconsistent basic authentication.
  • Better support for password managers (which often don't support basic authentication dialog boxes).


Balrog is designed to be used with Ruby on Rails applications, and has been tested against Ruby on Rails 5.


Add the gem to your Gemfile:

gem 'balrog'

Run the installer to generate an initializer:

$ bundle exec rails generate balrog:install
Enter New Password:
Confirm New Password:
      create  config/initializers/balrog.rb

Regenerating a password hash

If you need to create a new password, modify the hash in the Balrog initializer. You can generate a new hash with the provided Rake task:

$ bundle exec rails balrog:generate_hash
New password: *******
Type again: *******


Copy this hash into config/initializers/balrog.rb

Restricting access in a controller

class AdminController < ApplicationController
  before_action :authenticate_with_balrog!


Before contributing, please read the code of conduct.

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Please try not to mess with the package.json, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so we can cherry-pick around it.


  • Restricting access via routes.rb
  • Logout
  • Test coverage
  • Check it's OK with Ruby on Rails 6
  • Expire sessions
You can’t perform that action at this time.