Class: AzureJwtAuth::Provider
- Inherits:
-
Object
- Object
- AzureJwtAuth::Provider
- Defined in:
- lib/azure_jwt_auth/provider.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#config_uri ⇒ Object
readonly
Returns the value of attribute config_uri.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
-
#validations ⇒ Object
readonly
Returns the value of attribute validations.
Instance Method Summary collapse
-
#initialize(uid, config_uri, validations = {}) ⇒ Provider
constructor
A new instance of Provider.
- #load_keys ⇒ Object
Constructor Details
#initialize(uid, config_uri, validations = {}) ⇒ Provider
Returns a new instance of Provider.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/azure_jwt_auth/provider.rb', line 9 def initialize(uid, config_uri, validations={}) @uid = uid @config_uri = config_uri @validations = validations begin @config = JSON.parse(Net::HTTP.get(URI(config_uri))) rescue JSON::ParserError raise InvalidProviderConfig, "config_uri response is not valid for provider: #{uid}" end load_keys end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/azure_jwt_auth/provider.rb', line 7 def config @config end |
#config_uri ⇒ Object (readonly)
Returns the value of attribute config_uri.
6 7 8 |
# File 'lib/azure_jwt_auth/provider.rb', line 6 def config_uri @config_uri end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
7 8 9 |
# File 'lib/azure_jwt_auth/provider.rb', line 7 def keys @keys end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
6 7 8 |
# File 'lib/azure_jwt_auth/provider.rb', line 6 def uid @uid end |
#validations ⇒ Object (readonly)
Returns the value of attribute validations.
6 7 8 |
# File 'lib/azure_jwt_auth/provider.rb', line 6 def validations @validations end |
Instance Method Details
#load_keys ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/azure_jwt_auth/provider.rb', line 23 def load_keys uri = URI(@config['jwks_uri']) keys = JSON.parse(Net::HTTP.get(uri))['keys'] @keys = {} keys.each do |key| cert = RsaPem.from(key['n'], key['e']) rsa = OpenSSL::PKey::RSA.new(cert) @keys[key['kid']] = rsa end end |