Sha256: 8c56dfe323030b1fcc176c484ecbe7f42da4c523fed741ee87fbeb7069d63918

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

module Rack
  module SimpleAuth
    module HMAC
      ##
      # Config objects will be instantiated out of this class when using Rack::SimpleAuth::HMAC::Middleware
      # Also the public instance attributes / virtual attributes will be populated via the Middleware DSL
      #
      # @!attribute [w] tolerance
      #  @return [Fixnum|Float]
      #
      # @!attribute [w] secret
      #  @return [String]
      #
      # @!attribute [w] signature
      #  @return [String]
      #
      # @!attribute [rw] logpath
      #  @return [String]
      #
      # @!attribute [rw] request_config
      #  @return [Hash]
      #
      # @!attribute [rw] verbose
      #  @return [TrueClass|NilClass]
      #
      class Config < Hash
        attr_writer :tolerance
        attr_writer :secret, :signature

        attr_accessor :verbose
        attr_accessor :logpath, :request_config

        ##
        # Throw Runtime error for unknown attribute
        #
        # @param [Symbol] name
        # @param [Array] args
        #
        def method_missing(name, *args)
          fail "Unknown option #{name.to_s.gsub!('=', '')}"
        end

        ##
        # Tolerance Attribute with nil guard
        #
        # @return [Fixnum] tolerance
        #
        def tolerance
          @tolerance || 1000
        end

        ##
        # Secret Attribute with nil guard
        #
        # @return [String] secret
        #
        def secret
          @secret || ''
        end

        ##
        # Signature Attribute with nil guard
        #
        # @return [String] signature
        #
        def signature
          @signature || ''
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rack-simple_auth-1.0.3 lib/rack/simple_auth/hmac/config.rb
rack-simple_auth-1.0.2 lib/rack/simple_auth/hmac/config.rb
rack-simple_auth-1.0.1 lib/rack/simple_auth/hmac/config.rb
rack-simple_auth-1.0.0 lib/rack/simple_auth/hmac/config.rb