Sha256: da6260ee1698f3fa95c4047f0f5a3125ffcdab382f3fbe9ee5dcac0c419eb457

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

module JWTKeeper
  class Configuration < OpenStruct
    DEFAULTS = {
      algorithm:       'HS512',
      secret:           nil,
      expiry:           24.hours,
      issuer:           nil,
      audience:         nil,
      redis_connection: nil,
      version:          nil,
      cookie_lock:      false,
      cookie_secure:    true,
      cookie_domain:    :all
    }.freeze

    # Creates a new Configuration from the passed in parameters
    # @param params [Hash] configuration options
    # @return [Configuration]
    def initialize(params = {})
      super(DEFAULTS.merge(params))
    end

    # @!visibility private
    def base_claims
      {
        iss: JWTKeeper.configuration.issuer,               # issuer
        aud: JWTKeeper.configuration.audience,             # audience
        exp: JWTKeeper.configuration.expiry.from_now.to_i, # expiration time
        ver: JWTKeeper.configuration.version               # Version
      }
    end

    # @!visibility private
    def cookie_options
      {
        domain: JWTKeeper.configuration.cookie_domain,
        secure: JWTKeeper.configuration.cookie_secure,
        httponly: true
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jwt_keeper-6.1.2 lib/jwt_keeper/configuration.rb
jwt_keeper-6.1.1 lib/jwt_keeper/configuration.rb
jwt_keeper-6.1.0 lib/jwt_keeper/configuration.rb
jwt_keeper-6.0.0 lib/jwt_keeper/configuration.rb
jwt_keeper-5.0.1 lib/jwt_keeper/configuration.rb