Skip to content

Commit

Permalink
Merge pull request #2931 from bgeuken/auth_method
Browse files Browse the repository at this point in the history
[api] Remove unused @auth_method accessor from application controller
  • Loading branch information
evanrolfe committed Apr 4, 2017
2 parents d68bff0 + 658fb7c commit 23cf1b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/api/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ApplicationController < ActionController::Base
:extract_user_public,
:require_login,
:require_admin,
:auth_method,
to: :authenticator

def authenticator
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/person_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def internal_register
note = xml.elements["/unregisteredperson/note"].text if xml.elements["/unregisteredperson/note"]
status = xml.elements["/unregisteredperson/state"].text if xml.elements["/unregisteredperson/status"]

if auth_method == :proxy
if authenticator.proxy_mode?
if request.env['HTTP_X_USERNAME'].blank?
raise ErrRegisterSave.new "Missing iChain header"
end
Expand Down
12 changes: 6 additions & 6 deletions src/api/lib/authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AdminUserRequiredError < APIException
setup('put_request_no_permission', 403)
end

attr_reader :request, :session, :auth_method, :user_permissions, :http_user
attr_reader :request, :session, :user_permissions, :http_user

def initialize(request, session)
@request = request
Expand All @@ -32,13 +32,14 @@ def initialize(request, session)
@user_permissions = nil
end

def proxy_mode?
CONFIG['proxy_auth_mode'] == :on || CONFIG['ichain_mode'] == :on
end

def extract_user
mode = CONFIG['proxy_auth_mode'] || CONFIG['ichain_mode'] || :basic
if mode == :on
if proxy_mode?
extract_proxy_user
else
@auth_method = :basic

extract_basic_auth_user

@http_user = User.find_with_credentials @login, @passwd if @login
Expand Down Expand Up @@ -80,7 +81,6 @@ def require_admin
private

def extract_proxy_user
@auth_method = :proxy
proxy_user = request.env['HTTP_X_USERNAME']
if proxy_user
Rails.logger.info "iChain user extracted from header: #{proxy_user}"
Expand Down

0 comments on commit 23cf1b3

Please sign in to comment.