Class: OmniAuth::Strategies::CAS::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/omniauth/strategies/cas/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 http://cas.mycompany.com or http://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.

  • :disable_ssl_verification (Boolean, nil)

    disable verification for SSL cert, helpful when you developing with a fake cert.



23
24
25
# File 'lib/omniauth/strategies/cas/configuration.rb', line 23

def initialize(params)
  parse_params params
end

Instance Method Details

#disable_ssl_verification?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/omniauth/strategies/cas/configuration.rb', line 51

def disable_ssl_verification?
  @disable_ssl_verification
end

#login_url(service) ⇒ String

Build a CAS login URL from +service+.

Parameters:

  • service (String)

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

Returns:

  • (String)

    a URL like http://cas.mycompany.com/login?service=...



32
33
34
# File 'lib/omniauth/strategies/cas/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+. If +service+ has a ticket param, first remove it. URL-encode +service+ and add it and the +ticket+ as paraemters to the CAS serviceValidate URL.

Parameters:

  • service (String)

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

  • ticket (String)

    the ticket to validate

Returns:

  • (String)

    a URL like http://cas.mycompany.com/serviceValidate?service=...&ticket=...



45
46
47
48
49
# File 'lib/omniauth/strategies/cas/configuration.rb', line 45

def service_validate_url(service, ticket)
  service = service.sub(/[?&]ticket=[^?&]+/, '')
  url = append_service(@service_validate_url, service)
  url << '&ticket=' << Rack::Utils.escape(ticket)
end