Sha256: 151ff13e9a4cbce212fcaf97022cb746c3cc33e1b01e9db9ebce0a5d8177d5f7

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require 'rubygems'
require 'openshift-origin-controller'
require 'date'

module OpenShift
  class RemoteUserAuthService < OpenShift::AuthService

    def initialize
      super

      @trusted_header = @auth_info[:trusted_header]
    end

    # The base_controller will actually pass in a password but it can't be
    # trusted.  REMOTE_USER must only be set if the web server has verified the
    # password.
    def authenticate(request, login=nil, password=nil)
      if request.headers['User-Agent'] == "OpenShift"
        # password == iv, login == key
        return validate_broker_key(password, login)
      else
        authenticated_user = request.env[@trusted_header]
        raise OpenShift::AccessDeniedException if authenticated_user.nil?
        return {:username => authenticated_user, :auth_method => :login}
      end
    end

    # This is only called by the legacy controller and should be removed as
    # soon as all clients have been ported.
    def login(request, params, cookies)
      if params['broker_auth_key'] && params['broker_auth_iv']
        return validate_broker_key(params['broker_auth_iv'], params['broker_auth_key'])
      else
        username = request.env[@trusted_header]
        Rails.logger.debug("Found" + username)
        return authenticate(request, username)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openshift-origin-auth-remote-user-1.3.2 lib/openshift/remote_user_auth_service.rb
openshift-origin-auth-remote-user-1.3.1 lib/openshift/remote_user_auth_service.rb
openshift-origin-auth-remote-user-1.2.3 lib/openshift/remote_user_auth_service.rb