Skip to content

Commit

Permalink
[webui] Get rid if proxy_auth_mode :simualte in the app
Browse files Browse the repository at this point in the history
  • Loading branch information
hennevogel committed Oct 26, 2015
1 parent 4a12edf commit 79701cd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
9 changes: 3 additions & 6 deletions src/api/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,11 @@ def extract_ldap_user

end

def extract_proxy_user(mode)
def extract_proxy_user
@auth_method = :proxy
proxy_user = request.env['HTTP_X_USERNAME']
if proxy_user
logger.info "iChain user extracted from header: #{proxy_user}"
elsif mode == :simulate
proxy_user = CONFIG['proxy_auth_test_user']
logger.debug "iChain user extracted from config: #{proxy_user}"
end

# we're using a login proxy, there is no need to authenticate the user from the credentials
Expand Down Expand Up @@ -236,8 +233,8 @@ def extract_basic_auth_user

def extract_user
mode = CONFIG['proxy_auth_mode'] || CONFIG['ichain_mode'] || :basic
if mode == :on || mode == :simulate # configured in the the environment file
extract_proxy_user mode
if mode == :on
extract_proxy_user
else
@auth_method = :basic

Expand Down
2 changes: 0 additions & 2 deletions src/api/app/controllers/webui/user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def do_login
case mode
when :on
user = User.find_by(login: request.env['HTTP_X_USERNAME'])
when :simulate
user = User.find_by(login: CONFIG['proxy_auth_test_user'])
when :basic, :off
user = User.find_with_credentials(params[:username], params[:password])
end
Expand Down
17 changes: 1 addition & 16 deletions src/api/app/controllers/webui/webui_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,9 @@ def require_login
def do_backend_login
mode = CONFIG['proxy_auth_mode'] || :off
logger.debug "Authenticating with iChain mode: #{mode}"
if mode == :on || mode == :simulate
mode = CONFIG['proxy_auth_mode'] || :off
if mode == :on
proxy_user = request.env['HTTP_X_USERNAME']
proxy_email = request.env['HTTP_X_EMAIL']
if mode == :simulate
proxy_user ||= CONFIG['proxy_auth_test_user'] || CONFIG['proxy_test_user']
proxy_email ||= CONFIG['proxy_auth_test_email']
end
if proxy_user
session[:login] = proxy_user
session[:email] = proxy_email
Expand Down Expand Up @@ -269,16 +264,6 @@ def check_user
password: fakepw,
password_confirmation: fakepw)
end
elsif mode == :simulate
logger.debug "Authenticating with iChain mode: #{mode}"
user_login = CONFIG['proxy_auth_test_user'] || CONFIG['proxy_test_user']
if user_login
User.find_or_create_by!(login: user_login,
email: CONFIG['proxy_auth_test_email'],
realname: "Cool Guy",
password: 'password',
password_confirmation: 'password')
end
else
if session[:login]
user_login = session[:login]
Expand Down

0 comments on commit 79701cd

Please sign in to comment.