lib/saml/kit/configuration.rb in saml-kit-1.0.6 vs lib/saml/kit/configuration.rb in saml-kit-1.0.7

- old
+ new

@@ -18,11 +18,11 @@ # configuration.entity_id = "https://www.example.com/saml/metadata" # configuration.generate_key_pair_for(use: :signing) # configuration.add_key_pair(ENV["X509_CERTIFICATE"], ENV["PRIVATE_KEY"], passphrase: ENV['PRIVATE_KEY_PASSPHRASE'], use: :encryption) # end class Configuration - USES = [:signing, :encryption] + USES = %i[signing encryption].freeze # The issuer to use in requests or responses from this entity to use. attr_accessor :entity_id # The signature method to use when generating signatures (See {Saml::Kit::Builders::XmlSignature::SIGNATURE_METHODS}) attr_accessor :signature_method # The digest method to use when generating signatures (See {Saml::Kit::Builders::XmlSignature::DIGEST_METHODS}) @@ -34,11 +34,11 @@ # The logger to write log messages to. attr_accessor :logger # The total allowable clock drift for session timeout validation. attr_accessor :clock_drift - def initialize # :yields configuration + def initialize @clock_drift = 30.seconds @digest_method = :SHA256 @key_pairs = [] @logger = Logger.new(STDOUT) @registry = DefaultRegistry.new @@ -83,11 +83,11 @@ end # Return each private for a specific use. # # @param use [Symbol] the type of key pair to return `nil`, `:signing` or `:encryption` - def private_keys(use: :signing) + def private_keys(use: nil) key_pairs(use: use).flat_map(&:private_key) end # Returns true if there is at least one signing certificate registered. def sign? @@ -95,13 +95,13 @@ end private def ensure_proper_use!(use) - unless USES.include?(use) - error_message = "Use must be either :signing or :encryption" - raise ArgumentError.new(error_message) - end + return if USES.include?(use) + + error_message = 'Use must be either :signing or :encryption' + raise ArgumentError, error_message end end end end