Module: Console::Auth::RemoteUser

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/console/auth/remote_user.rb

Overview

The simplest possible security strategy - this controller mixin will look for user info as a header on the request, and pass that info down to the broker. The broker should be configured to authenticate with those headers.

Defined Under Namespace

Classes: RemoteUser

Instance Method Summary collapse

Instance Method Details

#authenticate_user!Object

This method should test authentication and handle if the user is unauthenticated



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/console/auth/remote_user.rb', line 45

def authenticate_user!
  @authenticated_user ||= begin
      name = request.env[Console.config.remote_user_header]
      raise Console::AccessDenied unless name
      display_name = request.env[Console.config.remote_user_name_header] unless Console.config.remote_user_name_header.nil?
      name = display_name || name
      logger.debug "  Identified user #{name} from headers"
      RemoteUser.new(
        name,
        Console.config.remote_user_copy_headers.inject({}) do |h, name|
          value = request.headers[name]
          h[name] = value if value.present?
          h
        end)
    end
end

#current_userObject

return the current authenticated user or nil



39
40
41
# File 'app/controllers/console/auth/remote_user.rb', line 39

def current_user
  @authenticated_user
end

#previously_signed_in?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/controllers/console/auth/remote_user.rb', line 66

def previously_signed_in?
  cookies[:prev_login] ? true : false
end

#user_signed_in?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/controllers/console/auth/remote_user.rb', line 62

def user_signed_in?
  not current_user.nil?
end