Module: KeycloakConnectRuby

Defined in:
lib/keycloak-connect-ruby.rb,
lib/keycloak-connect-ruby/token.rb,
lib/keycloak-connect-ruby/errors.rb,
lib/keycloak-connect-ruby/version.rb,
lib/keycloak-connect-ruby/configuration.rb

Defined Under Namespace

Modules: Errors Classes: Token

Constant Summary collapse

VERSION =
'1.0.0'
CONFIG_OPTIONS =
[
  'url',
  'realm',
  'client_id',
  'client_secret',
  'logger',
  'proxy'
]

Class Method Summary collapse

Class Method Details

.configObject



20
21
22
# File 'lib/keycloak-connect-ruby/configuration.rb', line 20

def self.config
  @configuration
end

.configure {|options| ... } ⇒ Object

Yields:

  • (options)


13
14
15
16
17
18
# File 'lib/keycloak-connect-ruby/configuration.rb', line 13

def self.configure
  options = OpenStruct.new
  yield options
  validate_options(options)
  @configuration ||= options
end

.loggerObject



24
25
26
# File 'lib/keycloak-connect-ruby/configuration.rb', line 24

def self.logger
  config.logger
end

.validate_options(options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/keycloak-connect-ruby/configuration.rb', line 28

def self.validate_options(options)
  keys = options.each_pair.to_a.map { |p| p[0].to_s }

  keys.each do |key|
    unless CONFIG_OPTIONS.include?(key)
      raise KeycloakConnectRuby::Errors::Configuration::UnknownOptionError, "Unknown option: #{key}. The config options are: #{CONFIG_OPTIONS.join(', ')}"
    end
  end

  missing_options = CONFIG_OPTIONS - keys

  if missing_options.any?
    raise KeycloakConnectRuby::Errors::Configuration::MissingOptionsError, "Missing options: #{missing_options.join(', ')}. The config options are: #{CONFIG_OPTIONS.join(', ')}"
  end
end