Class: Aker::CasCli

Inherits:
Object
  • Object
show all
Includes:
Aker::Cas::ConfigurationHelper
Defined in:
lib/aker/cas_cli.rb,
lib/aker/cas_cli/version.rb

Constant Summary collapse

CLI_SERVICE =
'https://cas-cli.example.edu'
VERSION =
"1.0.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, mechanize_options = {}) ⇒ CasCli

Creates a new instance.

Parameters:

  • configuration (Aker::Configuration)

    the Aker configuration to use. This configuration should have the :cas authority (or an appropriate substitute) configured into its authority chain.

  • mechanize_options (Hash) (defaults to: {})

    attribute values for the mechanize agent used to do the scraping. Use this, e.g., to specify the SSL CA to use.



29
30
31
32
33
34
35
36
37
# File 'lib/aker/cas_cli.rb', line 29

def initialize(configuration, mechanize_options={})
  @configuration = configuration
  @agent = Mechanize.new do |a|
    mechanize_options.each do |attr, value|
      a.send("#{attr}=", value)
    end
    a.redirect_ok = false
  end
end

Instance Attribute Details

#configurationAker::Configuration (readonly)

Returns the Aker parameters governing this instance.

Returns:

  • (Aker::Configuration)

    the Aker parameters governing this instance.



17
18
19
# File 'lib/aker/cas_cli.rb', line 17

def configuration
  @configuration
end

Instance Method Details

#authenticate(username, password) ⇒ Aker::User?

Attempts to verify the provided credentials. Verification is attempted through screen-scraping the login form provided by the CAS server configured in #configuration.

Returns:

  • (Aker::User, nil)

    the authenticated user, or nil if the credentials are invalid.



46
47
48
49
50
51
52
53
# File 'lib/aker/cas_cli.rb', line 46

def authenticate(username, password)
   = (username, password)
  return unless 

  if st = extract_service_ticket_if_successful()
    configuration.composite_authority.valid_credentials?(:cas, st, CLI_SERVICE)
  end
end