Class: CASRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/rack-cas/cas_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ CASRequest

Returns a new instance of CASRequest


6
7
8
# File 'lib/rack-cas/cas_request.rb', line 6

def initialize(request)
  @request = request
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request


4
5
6
# File 'lib/rack-cas/cas_request.rb', line 4

def request
  @request
end

Instance Method Details

#logout?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/rack-cas/cas_request.rb', line 22

def logout?
  @request.path_info == '/logout'
end

#path_matches?(strings_or_regexps) ⇒ Boolean

Returns:

  • (Boolean)

38
39
40
41
42
43
44
45
46
# File 'lib/rack-cas/cas_request.rb', line 38

def path_matches?(strings_or_regexps)
  Array(strings_or_regexps).any? do |matcher|
    if matcher.is_a? Regexp
      !!(@request.path_info =~ matcher)
    elsif matcher.to_s != ''
      @request.path_info[0...matcher.to_s.length] == matcher.to_s
    end
  end
end

#service_urlObject


18
19
20
# File 'lib/rack-cas/cas_request.rb', line 18

def service_url
  RackCAS::URL.parse(@request.url).remove_param('ticket').to_s
end

#single_sign_out?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'lib/rack-cas/cas_request.rb', line 26

def single_sign_out?
  !!@request.params['logoutRequest']
end

#ticketObject


10
11
12
13
14
15
16
# File 'lib/rack-cas/cas_request.rb', line 10

def ticket
  @ticket ||= if single_sign_out?
    sso_ticket
  elsif ticket_validation?
    ticket_param
  end
end

#ticket_validation?Boolean

Returns:

  • (Boolean)

30
31
32
33
34
35
36
# File 'lib/rack-cas/cas_request.rb', line 30

def ticket_validation?
  # The CAS protocol specifies that services must support tickets of
  # *up to* 32 characters in length (including ST-), and recommendes
  # that services accept tickets up to 256 characters long.
  # http://www.jasig.org/cas/protocol
  !!(@request.get? && ticket_param && ticket_param.to_s =~ /\AST\-[^\s]{1,253}\Z/)
end