Class: JWTSignedRequest::KeyStore

Inherits:
Object
  • Object
show all
Defined in:
lib/jwt_signed_request/key_store.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeKeyStore

Returns a new instance of KeyStore.



13
14
15
16
# File 'lib/jwt_signed_request/key_store.rb', line 13

def initialize
  @signing_keys = {}
  @verification_keys = {}
end

Class Method Details

.find(id) ⇒ Object



5
6
7
# File 'lib/jwt_signed_request/key_store.rb', line 5

def self.find(id)
  all[id]
end

Instance Method Details

#add_signing_key(key_id:, key:, algorithm:) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/jwt_signed_request/key_store.rb', line 18

def add_signing_key(key_id:, key:, algorithm:)
  @signing_keys.store(
    key_id,
    key: key,
    algorithm: algorithm,
  )
end

#add_verification_key(key_id:, key:, algorithm:) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/jwt_signed_request/key_store.rb', line 26

def add_verification_key(key_id:, key:, algorithm:)
  @verification_keys.store(
    key_id,
    key: key,
    algorithm: algorithm,
  )
end

#get_signing_key(key_id:) ⇒ Object



34
35
36
# File 'lib/jwt_signed_request/key_store.rb', line 34

def get_signing_key(key_id:)
  @signing_keys.fetch(key_id, {})
end

#get_verification_key(key_id:) ⇒ Object



38
39
40
# File 'lib/jwt_signed_request/key_store.rb', line 38

def get_verification_key(key_id:)
  @verification_keys.fetch(key_id, {})
end