Created
September 1, 2011 17:20
-
-
Save etdsoft/1186686 to your computer and use it in GitHub Desktop.
Restrict Dradis Pro signups with HTTP Basic authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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