Module: Maestrano

Defined in:
lib/maestrano/saml/metadata.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/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, SSO, Saml, XMLSecurity Classes: Configuration, OpenStruct

Constant Summary collapse

VERSION =
'0.10.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



63
64
65
# File 'lib/maestrano.rb', line 63

def config
  @config
end

Class Method Details

.authenticate(app_id, api_key) ⇒ Object

Check that app_id and api_key passed in argument match



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

def self.authenticate(app_id,api_key)
  self.param(:app_id) == app_id && self.param(:api_key) == api_key
end

.configure {|config| ... } ⇒ Object

Maestrano Configuration block

Yields:



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

def self.configure
  self.config ||= Configuration.new
  yield(config)
  self.config.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)



86
87
88
89
90
91
92
93
# File 'lib/maestrano.rb', line 86

def self.mask_user(user_uid,group_uid)
  sanitized_user_uid = self.unmask_user(user_uid)
  if Maestrano.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)



105
106
107
# File 'lib/maestrano.rb', line 105

def self.param(parameter)
  self.config.param(parameter)
end

.to_metadataObject

Return a hash describing the current Maestrano configuration. The metadata will be remotely fetched by Maestrano Exclude any info containing an api key



113
114
115
116
117
118
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
# File 'lib/maestrano.rb', line 113

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.config.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



97
98
99
# File 'lib/maestrano.rb', line 97

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