class GcpIapWarden::KeyStore
Constants
- GOOGLE_PUBLIC_KEY_URL
Attributes
keys[RW]
Public Class Methods
new()
click to toggle source
# File lib/gcp_iap_warden/key_store.rb, line 9 def initialize @keys = {} end
Public Instance Methods
fetch(key_id)
click to toggle source
# File lib/gcp_iap_warden/key_store.rb, line 13 def fetch(key_id) return if key_id.nil? key = keys[key_id] return key if key update_keys!(key_id) keys.fetch(key_id) end
Private Instance Methods
load_keys()
click to toggle source
# File lib/gcp_iap_warden/key_store.rb, line 32 def load_keys ::JSON.parse(open(GOOGLE_PUBLIC_KEY_URL).read) end
update_keys!(key_id)
click to toggle source
# File lib/gcp_iap_warden/key_store.rb, line 26 def update_keys!(key_id) new_keys = load_keys raise "Can't find key with id: #{key_id}" unless new_keys.key?(key_id) self.keys = new_keys end