Skip to content

Instantly share code, notes, and snippets.

@etdsoft
Created September 1, 2011 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etdsoft/1186686 to your computer and use it in GitHub Desktop.
Save etdsoft/1186686 to your computer and use it in GitHub Desktop.
Restrict Dradis Pro signups with HTTP Basic authentication
require 'digest/sha2'
class UsersController < ApplicationController
before_filter :login_required, :except => [:new, :create]
before_filter :basicauth, :only => [:new, :create]
protected
def basicauth
if authenticate_with_http_basic { |user, password| !( user.nil? || password.nil? || ::Digest::SHA512.hexdigest(password) != Configuration.password ) }
Rails.logger.debug 'foo'
else
request_http_basic_authentication('Dradis Pro')
end
end
public
def new
@user = User.new
end
# [...]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment