Class: KrakendOpenAPI::Plugins::AuthValidatorTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/transformers/plugins/auth_validator_transformer.rb

Overview

Transforms Auth Validator plugin definition

Instance Method Summary collapse

Instance Method Details

#transform_to_hash(roles:, config:) ⇒ Object

Raises:

  • (StandardError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/transformers/plugins/auth_validator_transformer.rb', line 7

def transform_to_hash(roles:, config:)
  raise(StandardError, 'Roles are empty') if roles.empty?

  {
    name: 'auth/validator',
    value: {
      'alg': config['alg'],
      'jwk_url': config['jwk_url'],
      'cache': config['cache'],
      'operation_debug': config['operation_debug'],
      'roles_key_is_nested': config['roles_key_is_nested'],
      'roles_key': config['roles_key'],
      'roles': roles
    }.compact
  }
end