Class: Minato::Rails::Auth::JWT::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/minato/rails/auth/jwt/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



14
15
16
17
18
19
20
21
22
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 14

def initialize
  @verify_token_signature = true
  @algorithms = 'RS256'
  @verify_iss = true
  @hmac_secret = nil
  @decode_params = nil
  @additional_params = {}
  @jwks = nil
end

Instance Attribute Details

#additional_paramsObject

Returns the value of attribute additional_params.



11
12
13
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 11

def additional_params
  @additional_params
end

#algorithmsObject

Returns the value of attribute algorithms.



11
12
13
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 11

def algorithms
  @algorithms
end

#decode_paramsObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 26

def decode_params
  return @decode_params.merge(additional_params || {}) if @decode_params.present?

  {
    algorithms: algorithms,
    iss:        issuer,
    verify_iss: verify_iss,
    jwks:       jwks
  }.merge(additional_params || {})
end

#hmac_secretObject

Returns the value of attribute hmac_secret.



11
12
13
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 11

def hmac_secret
  @hmac_secret
end

#issuerObject

Returns the value of attribute issuer.



11
12
13
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 11

def issuer
  @issuer
end

#jwksObject



41
42
43
44
45
46
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 41

def jwks
  return @jwks if @jwks.present?

  jwks_raw = Net::HTTP.get URI(jwks_uri)
  JSON.parse(jwks_raw, symbolize_names: true)
end

#jwks_uriObject

Returns the value of attribute jwks_uri.



11
12
13
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 11

def jwks_uri
  @jwks_uri
end

#verify_issObject

Returns the value of attribute verify_iss.



11
12
13
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 11

def verify_iss
  @verify_iss
end

#verify_token_signatureObject

Returns the value of attribute verify_token_signature.



11
12
13
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 11

def verify_token_signature
  @verify_token_signature
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



37
38
39
# File 'lib/minato/rails/auth/jwt/configuration.rb', line 37

def configure
  yield(self) if block_given?
end