Module: Maestrano

Includes:
Preset
Defined in:
lib/maestrano/preset.rb,
lib/maestrano.rb,
lib/maestrano/sso.rb,
lib/maestrano/version.rb,
lib/maestrano/api/util.rb,
lib/maestrano/sso/user.rb,
lib/maestrano/sso/group.rb,
lib/maestrano/api/object.rb,
lib/maestrano/open_struct.rb,
lib/maestrano/sso/session.rb,
lib/maestrano/account/bill.rb,
lib/maestrano/account/user.rb,
lib/maestrano/api/resource.rb,
lib/maestrano/saml/request.rb,
lib/maestrano/account/group.rb,
lib/maestrano/connec/client.rb,
lib/maestrano/saml/response.rb,
lib/maestrano/saml/settings.rb,
lib/maestrano/sso/base_user.rb,
lib/maestrano/auto_configure.rb,
lib/maestrano/sso/base_group.rb,
lib/maestrano/api/list_object.rb,
lib/maestrano/api/operation/base.rb,
lib/maestrano/api/operation/list.rb,
lib/maestrano/sso/base_membership.rb,
lib/maestrano/api/error/base_error.rb,
lib/maestrano/api/operation/create.rb,
lib/maestrano/api/operation/delete.rb,
lib/maestrano/api/operation/update.rb,
lib/maestrano/saml/attribute_value.rb,
lib/maestrano/saml/validation_error.rb,
lib/maestrano/account/recurring_bill.rb,
lib/maestrano/api/error/connection_error.rb,
lib/maestrano/xml_security/signed_document.rb,
lib/maestrano/api/error/authentication_error.rb,
lib/maestrano/api/error/invalid_request_error.rb

Overview

Only supports SAML 2.0

Defined Under Namespace

Modules: API, Account, AutoConfigure, Connec, Preset, SSO, Saml, XMLSecurity Classes: Configuration, OpenStruct

Constant Summary collapse

VERSION =
'1.0.6'

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Preset

included

Class Attribute Details

.configsObject

Returns the value of attribute configs.



70
71
72
# File 'lib/maestrano.rb', line 70

def configs
  @configs
end

Class Method Details

.authenticate(app_id, api_key) ⇒ Object

Check that app_id and api_key passed in argument match



90
91
92
# 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) ⇒ Object



124
125
126
127
128
# 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 {|| ... } ⇒ Object

Maestrano Configuration block

Yields:

  • ()


80
81
82
83
84
85
86
# 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) ⇒ Object



130
131
132
# 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) ⇒ Object

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)



100
101
102
103
104
105
106
107
# 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) ⇒ Object

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



120
121
122
# File 'lib/maestrano.rb', line 120

def self.param(parameter)
  (self.configs[preset] || Configuration.new).param(parameter)
end

.reset!Object

Reset Maesrtano configuration



74
75
76
77
# File 'lib/maestrano.rb', line 74

def self.reset!
  self.configs = {}
  return self
end

.unmask_user(user_uid) ⇒ Object

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



111
112
113
# File 'lib/maestrano.rb', line 111

def self.unmask_user(user_uid)
  user_uid.split(".").first
end