Class: Post911SOB::DGIB::AuthenticationTokenService

Inherits:
Object
  • Object
show all
Defined in:
lib/post911_sob/dgib/authentication_token_service.rb

Constant Summary collapse

ALGORITHM_TYPE =
'RS256'
TYP =
'JWT'
KID =
'sob'
USE =
'sig'
SIGNING_KEY =
Settings.dgi.post911_sob.jwt.private_key_path
RSA_PRIVATE =
OpenSSL::PKey::RSA.new(File.read(SIGNING_KEY))
DECODING_KEY =
Settings.dgi.post911_sob.jwt.public_key_path
RSA_PUBLIC =
OpenSSL::PKey::RSA.new(File.read(DECODING_KEY))

Class Method Summary collapse

Class Method Details

.callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/post911_sob/dgib/authentication_token_service.rb', line 15

def self.call
  payload = {
    nbf: Time.now.to_i,
    exp: Time.now.to_i + (5 * 60),
    realm_access: {
      roles: ['SOB']
    }
  }

  header_fields = { kid: KID, typ: TYP }

  JWT.encode(payload, RSA_PRIVATE, ALGORITHM_TYPE, header_fields)
end