Class: SimpleJwtAuth::Secrets
- Inherits:
-
Object
- Object
- SimpleJwtAuth::Secrets
- Defined in:
- lib/simple_jwt_auth/secrets.rb
Instance Method Summary collapse
-
#initialize(secrets) ⇒ Secrets
constructor
A new instance of Secrets.
-
#issuers ⇒ Array
Get all configured issuers.
-
#secret_for(issuer) ⇒ String
Get secret for a specific issuer Used when decoding, to retrieve the secret for an issuer.
Constructor Details
#initialize(secrets) ⇒ Secrets
Returns a new instance of Secrets.
5 6 7 |
# File 'lib/simple_jwt_auth/secrets.rb', line 5 def initialize(secrets) @secrets = secrets end |
Instance Method Details
#issuers ⇒ Array
Get all configured issuers
13 14 15 |
# File 'lib/simple_jwt_auth/secrets.rb', line 13 def issuers secrets.keys end |
#secret_for(issuer) ⇒ String
Get secret for a specific issuer Used when decoding, to retrieve the secret for an issuer
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/simple_jwt_auth/secrets.rb', line 27 def secret_for(issuer) raise( Errors::UndefinedIssuer, 'issuer has not been configured' ) unless issuer raise( Errors::UnknownIssuer, "issuer `#{issuer}` is not recognized" ) unless secrets.key?(issuer) secrets.fetch(issuer) end |