Revision 34f64353
Added by Ohad Levy over 12 years ago
- ID 34f64353a05fd0aa987ea18e8d2e36b1b4894efd
app/controllers/application_controller.rb | ||
---|---|---|
helper 'layout'
|
||
|
||
before_filter :require_ssl, :require_login
|
||
before_filter :welcome, :detect_notices, :only => :index, :unless => :request_json?
|
||
before_filter :welcome, :detect_notices, :only => :index, :unless => :api_request?
|
||
before_filter :authorize, :except => :login
|
||
|
||
protected
|
||
... | ... | |
# User is not found or first login
|
||
if SETTINGS[:login] and SETTINGS[:login] == true
|
||
# authentication is enabled
|
||
if request_json?
|
||
if api_request?
|
||
# JSON requests (REST API calls) use basic http authenitcation and should not use/store cookies
|
||
user = authenticate_or_request_with_http_basic { |u, p| User.try_to_login(u, p) }
|
||
User.current = user.is_a?(User) ? user : nil
|
||
... | ... | |
error "Unable to find internal system admin account - Recreating . . ."
|
||
User.current = User.create_admin
|
||
end
|
||
session[:user] = User.current.id unless request_json?
|
||
session[:user] = User.current.id unless api_request?
|
||
end
|
||
end
|
||
end
|
||
... | ... | |
false
|
||
end
|
||
|
||
def request_json?
|
||
request.format.json?
|
||
def api_request?
|
||
request.format.json? or request.format.yaml?
|
||
end
|
||
|
||
# this method sets the Current user to be the Admin
|
Also available in: Unified diff
fixes #1056 - Rundeck url doesn't work when ldap auth is active