Class: HasHelpers::ServiceTrust::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/has_helpers/service_trust/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/has_helpers/service_trust/configuration.rb', line 23

def initialize
  @issuer = nil
  @environment = defined?(Rails) ? Rails.env : "development"
  @private_key_env = "SERVICE_TRUST_PRIVATE_KEY"
  @kid_env = "SERVICE_TRUST_KEY_ID"
  @key_environment_env = "SERVICE_TRUST_KEY_ENVIRONMENT"
  @token_ttl = 60.seconds
  @max_token_ttl = 5.minutes
  @clock_skew = 30.seconds
  @trusted_issuer_block = nil
  @replay_cache_redis = -> { RedisConf.current }
  @rate_limit_per_issuer = { requests: 100, per: 1.minute }
  @audit_log_retention = 30.days
  @audit_async = false
  @jwks_cache_ttl = 1.hour
  @jwks_stale_ttl = 5.minutes
end

Instance Attribute Details

#audit_asyncObject

Returns the value of attribute audit_async.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def audit_async
  @audit_async
end

#audit_log_retentionObject

Returns the value of attribute audit_log_retention.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def audit_log_retention
  @audit_log_retention
end

#clock_skewObject

Returns the value of attribute clock_skew.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def clock_skew
  @clock_skew
end

#environmentObject

Returns the value of attribute environment.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def environment
  @environment
end

#issuerObject

Returns the value of attribute issuer.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def issuer
  @issuer
end

#jwks_cache_ttlObject

Returns the value of attribute jwks_cache_ttl.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def jwks_cache_ttl
  @jwks_cache_ttl
end

#jwks_stale_ttlObject

Returns the value of attribute jwks_stale_ttl.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def jwks_stale_ttl
  @jwks_stale_ttl
end

#key_environment_envObject

Returns the value of attribute key_environment_env.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def key_environment_env
  @key_environment_env
end

#kid_envObject

Returns the value of attribute kid_env.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def kid_env
  @kid_env
end

#max_token_ttlObject

Returns the value of attribute max_token_ttl.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def max_token_ttl
  @max_token_ttl
end

#private_key_envObject

Returns the value of attribute private_key_env.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def private_key_env
  @private_key_env
end

#rate_limit_per_issuerObject

Returns the value of attribute rate_limit_per_issuer.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def rate_limit_per_issuer
  @rate_limit_per_issuer
end

#replay_cache_redisObject

Returns the value of attribute replay_cache_redis.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def replay_cache_redis
  @replay_cache_redis
end

#token_ttlObject

Returns the value of attribute token_ttl.



8
9
10
# File 'lib/has_helpers/service_trust/configuration.rb', line 8

def token_ttl
  @token_ttl
end

Instance Method Details

#envObject



54
55
56
# File 'lib/has_helpers/service_trust/configuration.rb', line 54

def env
  environment.respond_to?(:to_sym) && defined?(ActiveSupport::StringInquirer) ? ActiveSupport::StringInquirer.new(environment.to_s) : environment
end

#trusted?(issuer_name) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/has_helpers/service_trust/configuration.rb', line 46

def trusted?(issuer_name)
  trusted_issuer(issuer_name).present?
end

#trusted_issuer(issuer_name) ⇒ Object



50
51
52
# File 'lib/has_helpers/service_trust/configuration.rb', line 50

def trusted_issuer(issuer_name)
  resolved_trusted_issuers[issuer_name.to_s]
end

#trusted_issuers(&block) ⇒ Object



41
42
43
44
# File 'lib/has_helpers/service_trust/configuration.rb', line 41

def trusted_issuers(&block)
  @trusted_issuer_block = block if block
  resolved_trusted_issuers
end