Skip to content

Commit

Permalink
Added 301 Redirect option to Basic Auth module
Browse files Browse the repository at this point in the history
  • Loading branch information
kn0 committed Feb 24, 2014
1 parent e4a0578 commit f1e71b7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/auxiliary/server/capture/http_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def initialize(info={})
register_options(
[
OptPort.new('SRVPORT', [ true, "The local port to listen on.", 80 ]),
OptString.new('REALM', [ true, "The authentication realm you'd like to present.", "Secure Site" ])
OptString.new('REALM', [ true, "The authentication realm you'd like to present.", "Secure Site" ]),
OptString.new('RedirectURL', [ false, "The page to redirect users to after they enter basic auth creds"])
], self.class)
end

Expand Down Expand Up @@ -73,7 +74,14 @@ def on_request_uri(cli, req)
)

print_good("#{cli.peerhost} - Credential collected: \"#{user}:#{pass}\" => #{req.resource}")
send_not_found(cli)
if datastore['RedirectURL']
print_status("Sending redirect to client")
response = create_response(301, "Moved Permanently")
response.headers['Location'] = datastore['RedirectURL']
cli.send_response(response)
else
send_not_found(cli)
end
else
print_status("Sending 401 to client")
response = create_response(401, "Unauthorized")
Expand Down

0 comments on commit f1e71b7

Please sign in to comment.