module Maestrano

When included, this module allows another module to be called setting a default preset

Examples: Maestrano::Settings.new # Uses 'production' preset Maestrano::Settings.new # Uses 'mypreset'

Only supports SAML 2.0

Constants

VERSION

Attributes

configs[RW]

Public Class Methods

authenticate(app_id,api_key) click to toggle source

Check that app_id and api_key passed in argument match

# File lib/maestrano.rb, line 90
def self.authenticate(app_id,api_key)
  self.param(:app_id) == app_id && self.param(:api_key) == api_key
end
auto_configure(config_file_path = nil) click to toggle source
# File lib/maestrano.rb, line 124
def self.auto_configure(config_file_path = nil)
  AutoConfigure.get_marketplace_configurations(config_file_path)
rescue => e
  raise "Error while fetching dynamic configuration: #{e}. Backtrace: #{e.backtrace}"
end
configure() { |configs| ... } click to toggle source

Maestrano Configuration block

# File lib/maestrano.rb, line 80
def self.configure
  self.configs ||= {}
  self.configs[preset] ||= Configuration.new
  yield(configs[preset])
  self.configs[preset].post_initialize
  return self
end
find_by_app_id_and_app_key(app_id, app_key) click to toggle source
# File lib/maestrano.rb, line 130
def self.find_by_app_id_and_app_key(app_id, app_key)
  Maestrano.configs.find { |_,v| v.param('api.id') == app_id && v.param('api.key') == app_key }.first rescue nil
end
mask_user(user_uid,group_uid) click to toggle source

Take a user uid (either real or virtual) and a group id and return the user uid that should be used within the app based on the user_creation_mode parameter: 'real': then the real user uid is returned (usr-4d5sfd) 'virtual': then the virtual user uid is returned (usr-4d5sfd.cld-g4f5d)

# File lib/maestrano.rb, line 100
def self.mask_user(user_uid,group_uid)
  sanitized_user_uid = self.unmask_user(user_uid)
  if self.param('sso.creation_mode') == 'virtual'
    return "#{sanitized_user_uid}.#{group_uid}"
  else
    return sanitized_user_uid
  end
end
param(parameter) click to toggle source

Get configuration parameter value E.g: Maestrano.param('api.key') Maestrano.param(:api_key) Maestrano.param('api.key')

# File lib/maestrano.rb, line 120
def self.param(parameter)
  (self.configs[preset] || Configuration.new).param(parameter)
end
reset!() click to toggle source

Reset Maesrtano configuration

# File lib/maestrano.rb, line 74
def self.reset!
  self.configs = {}
  return self
end
unmask_user(user_uid) click to toggle source

Take a user uid (either real or virtual) and return the real uid part

# File lib/maestrano.rb, line 111
def self.unmask_user(user_uid)
  user_uid.split(".").first
end