Class: IMS::LTI::Services::MessageAuthenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/ims/lti/services/message_authenticator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(launch_url, params, secret) ⇒ MessageAuthenticator

Returns a new instance of MessageAuthenticator.



6
7
8
9
10
11
12
13
# File 'lib/ims/lti/services/message_authenticator.rb', line 6

def initialize(launch_url, params, secret)
  @launch_url = launch_url
  @params = params
  @options, @parsed_params = parse_params(params)
  @consumer_key = @options[:consumer_key]
  @signature = @parsed_params.delete(:oauth_signature)
  @secret = secret
end

Instance Attribute Details

#consumer_keyObject (readonly)

Returns the value of attribute consumer_key.



4
5
6
# File 'lib/ims/lti/services/message_authenticator.rb', line 4

def consumer_key
  @consumer_key
end

#launch_urlObject (readonly)

Returns the value of attribute launch_url.



4
5
6
# File 'lib/ims/lti/services/message_authenticator.rb', line 4

def launch_url
  @launch_url
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/ims/lti/services/message_authenticator.rb', line 4

def message
  @message
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/ims/lti/services/message_authenticator.rb', line 4

def params
  @params
end

#signatureObject (readonly)

Returns the value of attribute signature.



4
5
6
# File 'lib/ims/lti/services/message_authenticator.rb', line 4

def signature
  @signature
end

#simple_oauth_headerObject (readonly)

Returns the value of attribute simple_oauth_header.



4
5
6
# File 'lib/ims/lti/services/message_authenticator.rb', line 4

def simple_oauth_header
  @simple_oauth_header
end

Instance Method Details

#base_stringObject



44
45
46
# File 'lib/ims/lti/services/message_authenticator.rb', line 44

def base_string
  simple_oauth_header.send(:signature_base)
end

#signed_paramsObject



48
49
50
# File 'lib/ims/lti/services/message_authenticator.rb', line 48

def signed_params
  simple_oauth_header.signed_attributes.merge(params)
end

#valid_signature?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ims/lti/services/message_authenticator.rb', line 16

def valid_signature?
   message.jwt ? valid_jwt? : simple_oauth_header.valid?(signature: signature)
end