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/api/resource.rb,
lib/maestrano/saml/request.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, SSO, Saml, XMLSecurity Classes: Configuration, OpenStruct

Constant Summary collapse

VERSION =
'0.8.3'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



58
59
60
# File 'lib/maestrano.rb', line 58

def config
  @config
end

Class Method Details

.authenticate(app_id, api_key) ⇒ Object

Check that app_id and api_key passed in argument match



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

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:



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

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)



81
82
83
84
85
86
87
88
# File 'lib/maestrano.rb', line 81

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)



100
101
102
# File 'lib/maestrano.rb', line 100

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



108
109
110
111
112
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
# File 'lib/maestrano.rb', line 108

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



92
93
94
# File 'lib/maestrano.rb', line 92

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