MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / execute

Method execute

keepercommander/commands/scim.py:131–177  ·  view source on GitHub ↗
(self, params, node=None, **kwargs)

Source from the content-addressed store, hash-verified

129 return scim_create_parser
130
131 def execute(self, params, node=None, **kwargs):
132 if not node:
133 logging.warning('\"--node\" option is required for \"create\" command')
134 return
135 nodes = list(self.resolve_nodes(params, node))
136 if len(nodes) > 1:
137 logging.warning('Node name \'%s\' is not unique. Use Node ID.', node)
138 return
139 elif len(nodes) == 0:
140 logging.warning('Node name \'%s\' is not found', node)
141 return
142
143 matched_node = nodes[0]
144 if not matched_node.get('parent_id'):
145 logging.warning('Root node cannot be used for SCIM endpoint')
146 return
147 token = base64.urlsafe_b64encode(os.urandom(32)).decode().rstrip('=')
148 rq = {
149 'command': 'scim_add',
150 'scim_id': self.get_enterprise_id(params),
151 'node_id': matched_node['node_id'],
152 'token': token,
153 }
154 prefix = kwargs.get('prefix')
155 if prefix:
156 rq['prefix'] = prefix
157 if kwargs.get('unique_groups', '') == 'on':
158 rq['unique_groups'] = True
159
160 api.communicate(params, rq)
161 api.query_enterprise(params)
162 scim_url = get_scim_url(params, matched_node['node_id'])
163 node_id = matched_node['node_id']
164 logging.info('')
165 logging.info('SCIM ID: %d', rq['scim_id'])
166 logging.info('SCIM URL: %s', scim_url)
167 logging.info('Provisioning Token: %s', token)
168 logging.info('')
169 return {
170 'scim_id': rq['scim_id'],
171 'scim_url': scim_url,
172 'provisioning_token': token,
173 'node_name': self.get_node_path(params, node_id),
174 'node_id': node_id,
175 'prefix': prefix or '',
176 'unique_groups': kwargs.get('unique_groups', '') == 'on',
177 }
178
179
180def find_scim(param, name): # type: (KeeperParams, any) -> dict

Callers

nothing calls this directly

Calls 9

get_scim_urlFunction · 0.85
warningMethod · 0.80
resolve_nodesMethod · 0.80
get_enterprise_idMethod · 0.80
communicateMethod · 0.80
get_node_pathMethod · 0.80
getMethod · 0.45
query_enterpriseMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected