Class: IMS::LTI::Services::AuthenticationService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iss:, aud:, sub:, secret:) ⇒ AuthenticationService

Returns a new instance of AuthenticationService.



8
9
10
11
12
13
14
15
16
# File 'lib/ims/lti/services/authentication_service.rb', line 8

def initialize(iss:, aud:, sub:, secret:)
  @iss = iss
  @aud = aud
  @sub = sub
  @secret = secret
  @additional_claims = {}
  @additional_params = {}
  @grant_type = 'urn:ietf:params:oauth:grant-type:jwt-bearer'
end

Instance Attribute Details

#additional_claimsObject

Returns the value of attribute additional_claims.



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

def additional_claims
  @additional_claims
end

#additional_paramsObject

Returns the value of attribute additional_params.



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

def additional_params
  @additional_params
end

#audObject

Returns the value of attribute aud.



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

def aud
  @aud
end

#connectionObject

Returns the value of attribute connection.



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

def connection
  @connection
end

#grant_typeObject

Returns the value of attribute grant_type.



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

def grant_type
  @grant_type
end

#issObject

Returns the value of attribute iss.



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

def iss
  @iss
end

#secretObject

Returns the value of attribute secret.



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

def secret
  @secret
end

#subObject

Returns the value of attribute sub.



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

def sub
  @sub
end

Instance Method Details

#access_tokenObject



22
23
24
# File 'lib/ims/lti/services/authentication_service.rb', line 22

def access_token
  access_token_request['access_token']
end

#expirationObject



26
27
28
29
# File 'lib/ims/lti/services/authentication_service.rb', line 26

def expiration
  expires_in = access_token_request['expires_in'].to_i
  @_response_time + expires_in
end

#expired?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/ims/lti/services/authentication_service.rb', line 31

def expired?
  expiration < Time.now
end

#invalidate!Object



35
36
37
38
# File 'lib/ims/lti/services/authentication_service.rb', line 35

def invalidate!
  @_access_token_request = nil
  @_response_time = nil
end