Class: JwtAuthEngine::Configuration

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

Overview

Runtime configuration container for auth model and token settings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



6
7
8
9
10
11
12
13
# File 'lib/jwt_auth_engine/configuration.rb', line 6

def initialize
  @jwt_secret_key = nil
  @auth_model = nil
  @identifier_field = nil
  @password_field = nil
  @access_token_expiry = nil
  @refresh_token_expiry = nil
end

Instance Attribute Details

#access_token_expiryObject



42
43
44
# File 'lib/jwt_auth_engine/configuration.rb', line 42

def access_token_expiry
  @access_token_expiry.presence || Constants::DEFAULT_ACCESS_TOKEN_EXPIRY
end

#auth_modelObject



30
31
32
# File 'lib/jwt_auth_engine/configuration.rb', line 30

def auth_model
  @auth_model.presence || Constants::DEFAULT_AUTH_MODEL
end

#identifier_fieldObject



34
35
36
# File 'lib/jwt_auth_engine/configuration.rb', line 34

def identifier_field
  @identifier_field.presence || Constants::DEFAULT_IDENTIFIER_FIELD
end

#jwt_secret_keyObject



22
23
24
25
26
27
28
# File 'lib/jwt_auth_engine/configuration.rb', line 22

def jwt_secret_key
  @jwt_secret_key.presence || (
    raise MissingSecretKey,
          'Missing JWT secret key. ' \
          "Set `config.#{JwtAuthEngine::Constants::JWT_SECRET_CONFIG_KEY}` in your initializer."
  )
end

#password_fieldObject



38
39
40
# File 'lib/jwt_auth_engine/configuration.rb', line 38

def password_field
  @password_field.presence || Constants::DEFAULT_PASSWORD_FIELD
end

#refresh_token_expiryObject



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

def refresh_token_expiry
  @refresh_token_expiry.presence || Constants::DEFAULT_REFRESH_TOKEN_EXPIRY
end