Class: CasrackTheAuthenticator::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/casrack_the_authenticator/configuration.rb

Constant Summary collapse

DEFAULT_LOGIN_URL =
"%s/login"
DEFAULT_SERVICE_VALIDATE_URL =
"%s/serviceValidate"

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Configuration

Returns a new instance of Configuration.

Parameters:

  • params (Hash)

    configuration options

Options Hash (params):

  • :cas_server (String, nil)

    the CAS server root URL; probably something like ‘cas.mycompany.com’ or ‘cas.mycompany.com/cas’; optional.

  • :cas_login_url (String, nil) — default: :cas_server + '/login'

    the URL to which to redirect for logins; options if :cas_server is specified, required otherwise.

  • :cas_service_validate_url (String, nil) — default: :cas_server + '/serviceValidate'

    the URL to use for validating service tickets; optional if :cas_server is specified, requred otherwise.



22
23
24
# File 'lib/casrack_the_authenticator/configuration.rb', line 22

def initialize(params)
  parse_params params
end

Instance Method Details

#login_url(service) ⇒ String

Build a CAS login URL from service.

cas.mycompany.com/login?service=…”

Parameters:

  • service (String)

    the service (a.k.a. return-to) URL

Returns:

  • (String)

    a URL like



32
33
34
# File 'lib/casrack_the_authenticator/configuration.rb', line 32

def (service)
  append_service @login_url, service
end

#service_validate_url(service, ticket) ⇒ String

Build a service-validation URL from service and ticket.

cas.mycompany.com/serviceValidate?service=…&ticket=…”

Parameters:

  • service (String)

    the service (a.k.a. return-to) URL

  • ticket (String)

    the ticket to validate

Returns:

  • (String)

    a URL like



43
44
45
46
# File 'lib/casrack_the_authenticator/configuration.rb', line 43

def service_validate_url(service, ticket)
  url = append_service @service_validate_url, service
  url << '&ticket=' << Rack::Utils.escape(ticket)
end