Class: Usps::JwtAuth::Config
- Inherits:
-
Object
- Object
- Usps::JwtAuth::Config
- Defined in:
- lib/usps/jwt_auth/config.rb
Overview
Configure JWT Authentication
Constant Summary collapse
- REQUIRED_OPTIONS =
%i[audience is_admin find_member].freeze
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Returns the value of attribute algorithm.
-
#audience ⇒ Object
Returns the value of attribute audience.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#find_member ⇒ Object
Returns the value of attribute find_member.
-
#is_admin ⇒ Object
Returns the value of attribute is_admin.
-
#issuer_base ⇒ Object
Returns the value of attribute issuer_base.
-
#issuers ⇒ Object
Returns the value of attribute issuers.
-
#key_size ⇒ Object
Returns the value of attribute key_size.
-
#keys_path ⇒ Object
Returns the value of attribute keys_path.
-
#public_keys_path ⇒ Object
Returns the value of attribute public_keys_path.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Config
constructor
A new instance of Config.
- #validate! ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Config
Returns a new instance of Config.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/usps/jwt_auth/config.rb', line 13 def initialize @environment = ActiveSupport::StringInquirer.new('development') @keys_path = Pathname.new('config/keys') @public_keys_path = Pathname.new('config/public_keys') @key_size = 4096 @algorithm = 'RS512' @issuer_base = 'usps:1' @issuers = [] @audience = nil yield self if block_given? # Also support setting options on initialize end |
Instance Attribute Details
#algorithm ⇒ Object
Returns the value of attribute algorithm.
10 11 12 |
# File 'lib/usps/jwt_auth/config.rb', line 10 def algorithm @algorithm end |
#audience ⇒ Object
Returns the value of attribute audience.
10 11 12 |
# File 'lib/usps/jwt_auth/config.rb', line 10 def audience @audience end |
#environment ⇒ Object
Returns the value of attribute environment.
10 11 12 |
# File 'lib/usps/jwt_auth/config.rb', line 10 def environment @environment end |
#find_member ⇒ Object
Returns the value of attribute find_member.
10 11 12 |
# File 'lib/usps/jwt_auth/config.rb', line 10 def find_member @find_member end |
#is_admin ⇒ Object
Returns the value of attribute is_admin.
10 11 12 |
# File 'lib/usps/jwt_auth/config.rb', line 10 def is_admin @is_admin end |
#issuer_base ⇒ Object
Returns the value of attribute issuer_base.
10 11 12 |
# File 'lib/usps/jwt_auth/config.rb', line 10 def issuer_base @issuer_base end |
#issuers ⇒ Object
Returns the value of attribute issuers.
10 11 12 |
# File 'lib/usps/jwt_auth/config.rb', line 10 def issuers @issuers end |
#key_size ⇒ Object
Returns the value of attribute key_size.
10 11 12 |
# File 'lib/usps/jwt_auth/config.rb', line 10 def key_size @key_size end |
#keys_path ⇒ Object
Returns the value of attribute keys_path.
11 12 13 |
# File 'lib/usps/jwt_auth/config.rb', line 11 def keys_path @keys_path end |
#public_keys_path ⇒ Object
Returns the value of attribute public_keys_path.
11 12 13 |
# File 'lib/usps/jwt_auth/config.rb', line 11 def public_keys_path @public_keys_path end |
Instance Method Details
#validate! ⇒ Object
34 35 36 37 38 39 |
# File 'lib/usps/jwt_auth/config.rb', line 34 def validate! = REQUIRED_OPTIONS.select { public_send(it).nil? } return unless .any? raise "Missing required options: #{.join(', ')}" end |