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/metadata.rb,
lib/maestrano/saml/response.rb,
lib/maestrano/saml/settings.rb,
lib/maestrano/sso/base_user.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, Connec, Preset, SSO, Saml, XMLSecurity Classes: Configuration, OpenStruct
Constant Summary collapse
- VERSION =
'0.12.5'
Class Attribute Summary collapse
-
.configs ⇒ Object
Returns the value of attribute configs.
Class Method Summary collapse
-
.authenticate(app_id, api_key) ⇒ Object
Check that app_id and api_key passed in argument match.
-
.configure {|| ... } ⇒ Object
Maestrano Configuration block.
-
.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).
-
.param(parameter) ⇒ Object
Get configuration parameter value E.g: Maestrano.param(‘api.key’) Maestrano.param(:api_key) Maestrano.param(‘api.key’).
-
.to_metadata ⇒ Object
Return a hash describing the current Maestrano configuration.
-
.unmask_user(user_uid) ⇒ Object
Take a user uid (either real or virtual) and return the real uid part.
Methods included from Preset
Class Attribute Details
.configs ⇒ Object
Returns the value of attribute configs.
67 68 69 |
# File 'lib/maestrano.rb', line 67 def configs @configs end |
Class Method Details
.authenticate(app_id, api_key) ⇒ Object
Check that app_id and api_key passed in argument match
81 82 83 |
# File 'lib/maestrano.rb', line 81 def self.authenticate(app_id,api_key) self.param(:app_id) == app_id && self.param(:api_key) == api_key end |
.configure {|| ... } ⇒ Object
Maestrano Configuration block
71 72 73 74 75 76 77 |
# File 'lib/maestrano.rb', line 71 def self.configure self.configs ||= {} self.configs[preset] ||= Configuration.new yield(configs[preset]) self.configs[preset].post_initialize return self 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)
91 92 93 94 95 96 97 98 |
# File 'lib/maestrano.rb', line 91 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’)
111 112 113 |
# File 'lib/maestrano.rb', line 111 def self.param(parameter) (self.configs[preset] || Configuration.new).param(parameter) end |
.to_metadata ⇒ Object
Return a hash describing the current Maestrano configuration. The metadata will be remotely fetched by Maestrano Exclude any info containing an api key
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/maestrano.rb', line 119 def self. hash = {} hash['environment'] = self.param('environment') config_groups = ['app','api','sso','webhook'] blacklist = ['api.key','api.token'] config_groups.each do |cgroup_name| cgroup = self.configs[preset].send(cgroup_name) attr_list = cgroup.attributes.map(&:to_s) attr_list += Configuration::EVT_CONFIG[hash['environment']].keys.select { |k| k =~ Regexp.new("^#{cgroup_name}\.") }.map { |k| k.gsub(Regexp.new("^#{cgroup_name}\."),'') } attr_list.uniq! attr_list.each do |first_lvl| if cgroup.send(first_lvl).is_a?(OpenStruct) c2group = cgroup.send(first_lvl) c2group.attributes.each do |secnd_lvl| full_param = [cgroup_name,first_lvl,secnd_lvl].join('.') unless blacklist.include?(full_param) hash[cgroup_name.to_s] ||= {} hash[cgroup_name.to_s][first_lvl.to_s] ||= {} hash[cgroup_name.to_s][first_lvl.to_s][secnd_lvl.to_s] = self.param(full_param) end end else full_param = [cgroup_name,first_lvl].join('.') unless blacklist.include?(full_param) hash[cgroup_name.to_s] ||= {} hash[cgroup_name.to_s][first_lvl.to_s] = self.param(full_param) end end end end return hash end |
.unmask_user(user_uid) ⇒ Object
Take a user uid (either real or virtual) and return the real uid part
102 103 104 |
# File 'lib/maestrano.rb', line 102 def self.unmask_user(user_uid) user_uid.split(".").first end |