Class: KeySet

Inherits:
Object
  • Object
show all
Defined in:
lib/omniauth/azure_adv2/key_set.rb

Overview

KeySet takes a list of active key objects and supplies a method to find a key given it’s ID.

Key objects should be hashes with at least the following structure:

'kid': 'ID',
'n': 'modulus',
'e': 'exponent',

Instance Method Summary collapse

Constructor Details

#initialize(keys:) ⇒ KeySet

Returns a new instance of KeySet.



11
12
13
# File 'lib/omniauth/azure_adv2/key_set.rb', line 11

def initialize(keys:)
  @keys = keys
end

Instance Method Details

#find(key_id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/omniauth/azure_adv2/key_set.rb', line 15

def find(key_id)
  key = find_key_or_raise_error(key_id)

  generate_public_key(
    modulus: decode_and_convert_to_number(key['n']),
    exponent: decode_and_convert_to_number(key['e']),
  )
end