pyivia 0.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyivia/__init__.py +1 -0
- pyivia/core/__init__.py +0 -0
- pyivia/core/access/__init__.py +0 -0
- pyivia/core/access/accesscontrol.py +463 -0
- pyivia/core/access/advancedconfig.py +78 -0
- pyivia/core/access/apiprotection.py +552 -0
- pyivia/core/access/attributes.py +263 -0
- pyivia/core/access/authentication.py +507 -0
- pyivia/core/access/fido2config.py +906 -0
- pyivia/core/access/fido2registrations.py +111 -0
- pyivia/core/access/mappingrules.py +196 -0
- pyivia/core/access/mmfaconfig.py +130 -0
- pyivia/core/access/pip.py +153 -0
- pyivia/core/access/pushnotification.py +264 -0
- pyivia/core/access/riskprofiles.py +170 -0
- pyivia/core/access/runtimeparameters.py +143 -0
- pyivia/core/access/scimconfig.py +246 -0
- pyivia/core/access/serverconnections.py +660 -0
- pyivia/core/access/templatefiles.py +265 -0
- pyivia/core/access/userregistry.py +286 -0
- pyivia/core/accesscontrol.py +200 -0
- pyivia/core/analysis/__init__.py +0 -0
- pyivia/core/analysis/applicationlog.py +98 -0
- pyivia/core/analysis/remotesyslog.py +154 -0
- pyivia/core/analysisdiagnostics.py +148 -0
- pyivia/core/federation/__init__.py +0 -0
- pyivia/core/federation/accesspolicy.py +140 -0
- pyivia/core/federation/aliasservice.py +159 -0
- pyivia/core/federation/attributesources.py +139 -0
- pyivia/core/federation/federations.py +1702 -0
- pyivia/core/federation/pointofcontact.py +366 -0
- pyivia/core/federation/securitytokenservice.py +502 -0
- pyivia/core/federationsettings.py +155 -0
- pyivia/core/system/__init__.py +0 -0
- pyivia/core/system/adminsettings.py +175 -0
- pyivia/core/system/advancedtuning.py +111 -0
- pyivia/core/system/clicommands.py +45 -0
- pyivia/core/system/cluster.py +282 -0
- pyivia/core/system/configuration.py +142 -0
- pyivia/core/system/containermanagement.py +37 -0
- pyivia/core/system/containers/__init__.py +0 -0
- pyivia/core/system/containers/deployments.py +161 -0
- pyivia/core/system/containers/healthcheck.py +62 -0
- pyivia/core/system/containers/images.py +130 -0
- pyivia/core/system/containers/metadata.py +65 -0
- pyivia/core/system/containers/registry.py +161 -0
- pyivia/core/system/containers/volumes.py +132 -0
- pyivia/core/system/datetime.py +49 -0
- pyivia/core/system/dns.py +68 -0
- pyivia/core/system/docker.py +57 -0
- pyivia/core/system/extensions.py +125 -0
- pyivia/core/system/filedownloads.py +81 -0
- pyivia/core/system/fips.py +68 -0
- pyivia/core/system/firststeps.py +89 -0
- pyivia/core/system/fixpacks.py +106 -0
- pyivia/core/system/general.py +58 -0
- pyivia/core/system/hostsfile.py +151 -0
- pyivia/core/system/interfaces.py +291 -0
- pyivia/core/system/licensing.py +118 -0
- pyivia/core/system/managementauthentication.py +164 -0
- pyivia/core/system/managementauthorization.py +241 -0
- pyivia/core/system/restartshutdown.py +192 -0
- pyivia/core/system/runtimedb.py +82 -0
- pyivia/core/system/snapshot.py +128 -0
- pyivia/core/system/sslcertificates.py +316 -0
- pyivia/core/system/staticroutes.py +151 -0
- pyivia/core/system/sysaccount.py +289 -0
- pyivia/core/systemsettings.py +219 -0
- pyivia/core/web/__init__.py +0 -0
- pyivia/core/web/api_access_control.py +32 -0
- pyivia/core/web/apiac/__init__.py +0 -0
- pyivia/core/web/apiac/authorization_server.py +318 -0
- pyivia/core/web/apiac/cors.py +160 -0
- pyivia/core/web/apiac/document_root.py +157 -0
- pyivia/core/web/apiac/policies.py +132 -0
- pyivia/core/web/apiac/resource_server.py +716 -0
- pyivia/core/web/apiac/utilities.py +100 -0
- pyivia/core/web/clientcertmapping.py +151 -0
- pyivia/core/web/dscadmin.py +138 -0
- pyivia/core/web/fsso.py +129 -0
- pyivia/core/web/httptransform.py +135 -0
- pyivia/core/web/junctionmapping.py +145 -0
- pyivia/core/web/kerberos.py +241 -0
- pyivia/core/web/passwordstrength.py +139 -0
- pyivia/core/web/policyadmin.py +47 -0
- pyivia/core/web/ratelimit.py +128 -0
- pyivia/core/web/reverseproxy.py +898 -0
- pyivia/core/web/rsa.py +125 -0
- pyivia/core/web/runtimecomponent.py +380 -0
- pyivia/core/web/urlmapping.py +143 -0
- pyivia/core/web/usermapping.py +148 -0
- pyivia/core/websettings.py +174 -0
- pyivia/factory.py +197 -0
- pyivia/util/__init__.py +0 -0
- pyivia/util/model.py +56 -0
- pyivia/util/policies.py +145 -0
- pyivia/util/restclient.py +241 -0
- pyivia-0.2.3.dist-info/AUTHORS.md +14 -0
- pyivia-0.2.3.dist-info/LICENSE.txt +21 -0
- pyivia-0.2.3.dist-info/METADATA +77 -0
- pyivia-0.2.3.dist-info/RECORD +103 -0
- pyivia-0.2.3.dist-info/WHEEL +5 -0
- pyivia-0.2.3.dist-info/top_level.txt +1 -0
pyivia/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .factory import AuthenticationError, Factory
|
pyivia/core/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@copyright: IBM
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
|
|
7
|
+
from pyivia.util.model import DataObject
|
|
8
|
+
from pyivia.util.restclient import RESTClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
POLICIES = "/iam/access/v8/policies"
|
|
12
|
+
POLICY_ATTACHMENTS = "/iam/access/v8/policyattachments"
|
|
13
|
+
POLICY_ATTACHMENTS_PDADMIN = "/iam/access/v8/policyattachments/pdadmin"
|
|
14
|
+
OBLIGATIONS = "/iam/access/v8/obligations"
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class AccessControl(object):
|
|
20
|
+
|
|
21
|
+
def __init__(self, base_url, username, password):
|
|
22
|
+
super(AccessControl, self).__init__()
|
|
23
|
+
self.client = RESTClient(base_url, username, password)
|
|
24
|
+
|
|
25
|
+
def create_policy(self, name=None, description=None, dialect="urn:oasis:names:tc:xacml:2.0:policy:schema:os",
|
|
26
|
+
policy=None, attributes_required=False):
|
|
27
|
+
'''
|
|
28
|
+
Create an AAC Access Policy.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
name (:obj:`str`): Name of policy to be created.
|
|
32
|
+
description (:obj:`str`, optional): Description of policy to be created
|
|
33
|
+
dialect (:obj:`str`, optional): Format of policy XML. Only "urn:oasis:names:tc:xacml:2.0:policy:schema:os" is supported
|
|
34
|
+
policy (:obj:`str`, optional): XML of policy steps.
|
|
35
|
+
attributes_required (:obj:`list` of :obj:`str`, optional): Additional attribute mappings used by the policy
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
39
|
+
|
|
40
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
41
|
+
|
|
42
|
+
If the request is successful the id of the created policy can be access from the
|
|
43
|
+
response.id_from_location attribute.
|
|
44
|
+
|
|
45
|
+
'''
|
|
46
|
+
data = DataObject()
|
|
47
|
+
data.add_value_string("name", name)
|
|
48
|
+
data.add_value_string("description", description)
|
|
49
|
+
data.add_value_string("dialect", dialect)
|
|
50
|
+
data.add_value_string("policy", policy)
|
|
51
|
+
data.add_value_boolean("attributesRequired", attributes_required)
|
|
52
|
+
data.add_value_boolean("predefined", False)
|
|
53
|
+
|
|
54
|
+
response = self.client.post_json(POLICIES, data.data)
|
|
55
|
+
response.success = response.status_code == 201
|
|
56
|
+
|
|
57
|
+
return response
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def delete_policy(self, id=None):
|
|
61
|
+
'''
|
|
62
|
+
Delete an AAC Access Policy.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
id (:obj:`str`): Policy id to be removed.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
69
|
+
|
|
70
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
71
|
+
|
|
72
|
+
'''
|
|
73
|
+
endpoint = "%s/%s" % (POLICIES, id)
|
|
74
|
+
response = self.client.delete_json(endpoint)
|
|
75
|
+
response.success = response.status_code == 204
|
|
76
|
+
|
|
77
|
+
return response
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def list_policies(self, sort_by=None, filter=None):
|
|
81
|
+
'''
|
|
82
|
+
List all of the configured AAC Access Policies.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
sort_by (:obj:`str`, optional): Optional sorting of returned policies
|
|
86
|
+
filter (:obj:`str`, optional): Optional filter for returned policies
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
90
|
+
|
|
91
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
92
|
+
|
|
93
|
+
If the request is successful the policies are returned as JSON and can be accessed from
|
|
94
|
+
the response.json attribute.
|
|
95
|
+
|
|
96
|
+
'''
|
|
97
|
+
parameters = DataObject()
|
|
98
|
+
parameters.add_value_string("sortBy", sort_by)
|
|
99
|
+
parameters.add_value_string("filter", filter)
|
|
100
|
+
|
|
101
|
+
response = self.client.get_json(POLICIES, parameters.data)
|
|
102
|
+
response.success = response.status_code == 200
|
|
103
|
+
|
|
104
|
+
return response
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def authenticate_security_access_manager(self, username=None, password=None, domain=None):
|
|
108
|
+
'''
|
|
109
|
+
Authenticate to the Verify Identity Access policy server. This is required before an administrator can modify
|
|
110
|
+
mapping from policies to resources.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
username (:obj:`str`): Username used to authenticate to the policy server.
|
|
114
|
+
password (:obj:`str`): Password used to authenticate to the policy server.
|
|
115
|
+
domain (:obj:`str`): Security domain to authenticate to.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
119
|
+
|
|
120
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
121
|
+
|
|
122
|
+
'''
|
|
123
|
+
data = DataObject()
|
|
124
|
+
data.add_value_string("username", username)
|
|
125
|
+
data.add_value_string("password", password)
|
|
126
|
+
data.add_value_string("domain", domain)
|
|
127
|
+
data.add_value_string("command", "setCredential")
|
|
128
|
+
|
|
129
|
+
response = self.client.post_json(POLICY_ATTACHMENTS_PDADMIN, data.data)
|
|
130
|
+
response.success = response.status_code == 200
|
|
131
|
+
|
|
132
|
+
return response
|
|
133
|
+
|
|
134
|
+
def configure_resource(
|
|
135
|
+
self, server=None, resource_uri=None,
|
|
136
|
+
policy_combining_algorithm=None, policies=None):
|
|
137
|
+
'''
|
|
138
|
+
Create a new resource in the policy server which can be attached to an authentication policy.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
server (:obj:`str`): Name of WebSEAL instance in the policy server where resource will be created.
|
|
142
|
+
resource_uri (:obj:`str`): URI of resource to be created.
|
|
143
|
+
policy_combining_algorithm (:obj:`str`): Algorithm to use: "denyOverrides" or "permitOverrides".
|
|
144
|
+
policies (:obj:`list` of :obj:`str`): List of policies, policy sets or API protection clients.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
148
|
+
|
|
149
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
150
|
+
|
|
151
|
+
If the request is successful the id of the created policy can be accessed from the
|
|
152
|
+
response.id_from_location attribute.
|
|
153
|
+
|
|
154
|
+
'''
|
|
155
|
+
data = DataObject()
|
|
156
|
+
data.add_value_string("server", server)
|
|
157
|
+
data.add_value_string("resourceUri", resource_uri)
|
|
158
|
+
data.add_value_string("policyCombiningAlgorithm", policy_combining_algorithm)
|
|
159
|
+
data.add_value("policies", policies)
|
|
160
|
+
|
|
161
|
+
response = self.client.post_json(POLICY_ATTACHMENTS, data.data)
|
|
162
|
+
response.success = response.status_code == 201
|
|
163
|
+
|
|
164
|
+
return response
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def remove_resource(self, id):
|
|
168
|
+
'''
|
|
169
|
+
Delete a resource from the policy server.
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
id (:obj:`str`): The id of the resource to be removed.
|
|
173
|
+
|
|
174
|
+
Returns:
|
|
175
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
176
|
+
|
|
177
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
178
|
+
|
|
179
|
+
'''
|
|
180
|
+
endpoint = "%s/%s" % (POLICY_ATTACHMENTS, id)
|
|
181
|
+
response = self.client.delete_json(endpoint)
|
|
182
|
+
response.success = response.status_code == 204
|
|
183
|
+
|
|
184
|
+
return response
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def list_resources(self, sort_by=None, filter=None):
|
|
188
|
+
'''
|
|
189
|
+
Return the list of configured resources.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
sort_by (:obj:`str`, optional): Optionally specify the attribute to sort the returned list by.
|
|
193
|
+
filter (:obj:`str`): Optionally specify whether the returned list shouldb e filtered based on an attribute.
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
197
|
+
|
|
198
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
199
|
+
|
|
200
|
+
'''
|
|
201
|
+
parameters = DataObject()
|
|
202
|
+
parameters.add_value_string("sortBy", sort_by)
|
|
203
|
+
parameters.add_value_string("filter", filter)
|
|
204
|
+
|
|
205
|
+
response = self.client.get_json(POLICY_ATTACHMENTS, parameters.data)
|
|
206
|
+
response.success = response.status_code == 200
|
|
207
|
+
|
|
208
|
+
return response
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def publish_policy_attachment(self, id):
|
|
212
|
+
'''
|
|
213
|
+
Publish the changes to the policy server. This will require a restart of the corresponding WebSEAL instance.
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
id (:obj:`str`): The id of the resource to publish.
|
|
217
|
+
|
|
218
|
+
Returns:
|
|
219
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
220
|
+
|
|
221
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
222
|
+
|
|
223
|
+
'''
|
|
224
|
+
endpoint = "%s/deployment/%s" % (POLICY_ATTACHMENTS, id)
|
|
225
|
+
|
|
226
|
+
response = self.client.put_json(endpoint)
|
|
227
|
+
response.success = response.status_code == 204
|
|
228
|
+
|
|
229
|
+
return response
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def publish_multiple_policy_attachments(self, ids=[]):
|
|
233
|
+
'''
|
|
234
|
+
Publish the changes to the policy server for one or more resources. This will require a restart of the
|
|
235
|
+
corresponding WebSEAL instance.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
ids (:obj:`list` of :obj:`str`): List of resource ids to publish.
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
242
|
+
|
|
243
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
244
|
+
|
|
245
|
+
'''
|
|
246
|
+
id_string = ""
|
|
247
|
+
for id in ids:
|
|
248
|
+
|
|
249
|
+
if len(id_string) > 0:
|
|
250
|
+
id_string += ", "
|
|
251
|
+
id_string += str(id)
|
|
252
|
+
|
|
253
|
+
data = DataObject()
|
|
254
|
+
data.add_value_string("policyAttachmentIds", id_string)
|
|
255
|
+
|
|
256
|
+
endpoint = "%s/deployment" % POLICY_ATTACHMENTS
|
|
257
|
+
|
|
258
|
+
response = self.client.put_json(endpoint, data.data)
|
|
259
|
+
response.success = response.status_code == 204
|
|
260
|
+
|
|
261
|
+
return response
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def list_obligations(self, sort_by=None, filter=None):
|
|
265
|
+
'''
|
|
266
|
+
Return the list of configured obligations for AAC.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
sort_by (:obj:`str`, optional): Optional sorting of returned policies.
|
|
270
|
+
filter (:obj:`str`, optional): Optional filter for returned policies.
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
274
|
+
|
|
275
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
276
|
+
|
|
277
|
+
If the request is successful the obligations are returned as JSON and can be accessed from
|
|
278
|
+
the response.json attribute.
|
|
279
|
+
|
|
280
|
+
'''
|
|
281
|
+
parameters = DataObject()
|
|
282
|
+
parameters.add_value_string("sortBy", sort_by)
|
|
283
|
+
parameters.add_value_string("filter", filter)
|
|
284
|
+
|
|
285
|
+
response = self.client.get_json(OBLIGATIONS, parameters.data)
|
|
286
|
+
response.success = response.status_code == 200
|
|
287
|
+
|
|
288
|
+
return response
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def create_obligation(self, name=None, description=None, obligation_uri=None,
|
|
292
|
+
type="Obligation", type_id="1", parameters=None, properties=None):
|
|
293
|
+
'''
|
|
294
|
+
Create a new obligation for use with RBA.
|
|
295
|
+
|
|
296
|
+
Args:
|
|
297
|
+
name (:obj:`str`): Name of obligation.
|
|
298
|
+
description (:obj:`str`, optional): Description of the obligation.
|
|
299
|
+
obligation_uri (:obj:`str`): URI of the obligation.
|
|
300
|
+
type (:obj:`str`): The obligation type, "Obligation".
|
|
301
|
+
type_id (:obj:`str`, optional): The obligation type id. If not provided, the value will be set to "1", which is the "Enforcement Point" type.
|
|
302
|
+
parameters (:obj:`list` of :obj:`str`, optional): List of parameters used by the obligation when making a decision.
|
|
303
|
+
properties (:obj:`list` of :obj:`str`, optional): Properties used by the obligation.
|
|
304
|
+
|
|
305
|
+
Returns:
|
|
306
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
307
|
+
|
|
308
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
309
|
+
|
|
310
|
+
If the request is successful the id of the created obligation can be accessed from the
|
|
311
|
+
response.id_from_location attribute.
|
|
312
|
+
|
|
313
|
+
'''
|
|
314
|
+
data = DataObject()
|
|
315
|
+
data.add_value_string("name", name)
|
|
316
|
+
data.add_value_string("description", description)
|
|
317
|
+
data.add_value_string("obligationURI", obligation_uri)
|
|
318
|
+
data.add_value_string("type", type)
|
|
319
|
+
data.add_value("parameters", parameters)
|
|
320
|
+
data.add_value_string("typeId", type_id)
|
|
321
|
+
data.add_value("properties", properties)
|
|
322
|
+
|
|
323
|
+
response = self.client.post_json(OBLIGATIONS, data.data)
|
|
324
|
+
response.success = response.status_code == 201
|
|
325
|
+
|
|
326
|
+
return response
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def update_obligation(self, id, name=None, description=None, obligation_uri=None,
|
|
330
|
+
type="Obligation", type_id=None, parameters=None, properties=None):
|
|
331
|
+
'''
|
|
332
|
+
Update an existing obligation for use with RBA
|
|
333
|
+
|
|
334
|
+
Args:
|
|
335
|
+
id (:obj:`str`): The generated unique id of the obligation to update.
|
|
336
|
+
name (:obj:`str`): Name of obligation.
|
|
337
|
+
description (:obj:`str`, optional): Description of the obligation.
|
|
338
|
+
obligationURI (:obj:`str`): URI of the obligation.
|
|
339
|
+
type (:obj:`str`, optional): The obligation type, "Obligation".
|
|
340
|
+
parameters (:obj:`list` of :obj:`str`, optional): List of parameters used by the obligation when making a decision.
|
|
341
|
+
properties (:obj:`list` of :obj:`str`, optional): Properties used by the obligation.
|
|
342
|
+
|
|
343
|
+
Returns:
|
|
344
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
345
|
+
|
|
346
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
347
|
+
|
|
348
|
+
If the request is successful the id of the created obligation can be accessed from the
|
|
349
|
+
response.id_from_location attribute.
|
|
350
|
+
|
|
351
|
+
'''
|
|
352
|
+
data = DataObject()
|
|
353
|
+
data.add_value_string("name", name)
|
|
354
|
+
data.add_value_string("description", description)
|
|
355
|
+
data.add_value_string("obligationURI", obligation_uri)
|
|
356
|
+
data.add_value_string("type", type)
|
|
357
|
+
data.add_value("parameters", parameters)
|
|
358
|
+
data.add_value_string("typeId", type_id)
|
|
359
|
+
data.add_value("properties", properties)
|
|
360
|
+
|
|
361
|
+
response = self.client.post_json(OBLIGATIONS, data.data)
|
|
362
|
+
response.success = response.status_code == 201
|
|
363
|
+
|
|
364
|
+
return response
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def delete_obligation(self, id):
|
|
368
|
+
'''
|
|
369
|
+
Delete an existing obligation from the policy server
|
|
370
|
+
|
|
371
|
+
Args:
|
|
372
|
+
id (:obj:`str`): The id of the obligation to be removed.
|
|
373
|
+
|
|
374
|
+
Returns:
|
|
375
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
376
|
+
|
|
377
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
378
|
+
|
|
379
|
+
'''
|
|
380
|
+
endpoint = "%s/%s" % (OBLIGATIONS, id)
|
|
381
|
+
response = self.client.delete_json(endpoint)
|
|
382
|
+
response.success = response.status_code == 204
|
|
383
|
+
|
|
384
|
+
return response
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
class AccessControl9030(AccessControl):
|
|
388
|
+
|
|
389
|
+
def __init__(self, base_url, username, password):
|
|
390
|
+
super(AccessControl9030, self).__init__(base_url, username, password)
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def configure_resource(self, server=None, resource_uri=None, policy_combining_algorithm=None,
|
|
394
|
+
policies=None, type="reverse_proxy"):
|
|
395
|
+
'''
|
|
396
|
+
Create a new resource in the policy server which can be attached to an authentication policy.
|
|
397
|
+
|
|
398
|
+
Args:
|
|
399
|
+
server (:obj:`str`): Name of WebSEAL instance in the policy server where resource will be created.
|
|
400
|
+
resource_uri (:obj:`str`): URI of resource to be created.
|
|
401
|
+
policy_combining_algorithm (:obj:`str`): Algorithm to use: "denyOverrides" or "permitOverrides".
|
|
402
|
+
policies (:obj:`list` of :obj:`str`): List of policies, policy sets or API protection clients.
|
|
403
|
+
type (:obj:`str`, optional): Resource type to be created. Default is "reverse_proxy".
|
|
404
|
+
|
|
405
|
+
Returns:
|
|
406
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
407
|
+
|
|
408
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
409
|
+
|
|
410
|
+
'''
|
|
411
|
+
data = DataObject()
|
|
412
|
+
data.add_value_string("server", server)
|
|
413
|
+
data.add_value_string("resourceUri", resource_uri)
|
|
414
|
+
data.add_value_string(
|
|
415
|
+
"policyCombiningAlgorithm", policy_combining_algorithm)
|
|
416
|
+
data.add_value("policies", policies)
|
|
417
|
+
data.add_value_string("type", type)
|
|
418
|
+
|
|
419
|
+
response = self.client.post_json(POLICY_ATTACHMENTS, data.data)
|
|
420
|
+
response.success = response.status_code == 201
|
|
421
|
+
|
|
422
|
+
return response
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
class AccessControl10000(AccessControl9030):
|
|
426
|
+
|
|
427
|
+
def __init__(self, base_url, username, password):
|
|
428
|
+
super(AccessControl10000, self).__init__(base_url, username, password)
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
def configure_resource(self, server=None, resource_uri=None, policy_combining_algorithm=None,
|
|
432
|
+
policies=None, cache=None):
|
|
433
|
+
'''
|
|
434
|
+
Create a new resource in the policy server which can be attached to an authentication policy.
|
|
435
|
+
|
|
436
|
+
Args:
|
|
437
|
+
server (:obj:`str`): Name of WebSEAL instance in the policy server where resource will be created.
|
|
438
|
+
resource_uri (:obj:`str`): URI of resource to be created.
|
|
439
|
+
policy_combining_algorithm (:obj:`str`): Algorithm to use: "denyOverrides" or "permitOverrides".
|
|
440
|
+
policies (:obj:`list` of :obj:`str`): List of policies, policy sets or API protection clients.
|
|
441
|
+
cache (`int`, optional): 0 to disable the cache for this resource, -1 to cache the decision for
|
|
442
|
+
the lifetime of the session or any number greater than 1 to set a
|
|
443
|
+
specific timeout (in seconds) for the cached decision. If not specified
|
|
444
|
+
a default of 0 will be used.
|
|
445
|
+
|
|
446
|
+
Returns:
|
|
447
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
448
|
+
|
|
449
|
+
Success can be checked by examining the response.success boolean attribute.
|
|
450
|
+
|
|
451
|
+
'''
|
|
452
|
+
data = DataObject()
|
|
453
|
+
data.add_value_string("server", server)
|
|
454
|
+
data.add_value_string("resourceUri", resource_uri)
|
|
455
|
+
data.add_value_string(
|
|
456
|
+
"policyCombiningAlgorithm", policy_combining_algorithm)
|
|
457
|
+
data.add_value("policies", policies)
|
|
458
|
+
data.add_value("cache", cache)
|
|
459
|
+
|
|
460
|
+
response = self.client.post_json(POLICY_ATTACHMENTS, data.data)
|
|
461
|
+
response.success = response.status_code == 201
|
|
462
|
+
|
|
463
|
+
return response
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@copyright: IBM
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
|
|
7
|
+
from pyivia.util.model import DataObject
|
|
8
|
+
from pyivia.util.restclient import RESTClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
OVERRIDE_CONFIGS = "/iam/access/v8/override-configs"
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AdvancedConfig(object):
|
|
17
|
+
|
|
18
|
+
def __init__(self, base_url, username, password):
|
|
19
|
+
super(AdvancedConfig, self).__init__()
|
|
20
|
+
self.client = RESTClient(base_url, username, password)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def list_properties(self, sort_by=None, count=None, start=None, filter=None):
|
|
24
|
+
'''
|
|
25
|
+
Get a list of all the advanced configuration parameters
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
sort_by (:obj:`str`, optional): Attribute to sort results by.
|
|
29
|
+
count (:obj:`str`, optional): Maximum number of results to fetch.
|
|
30
|
+
start (:obj:`str`, optional): Pagination offset of returned results.
|
|
31
|
+
filter (:obj:`str`): Attribute to filter results by
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
35
|
+
|
|
36
|
+
Success can be checked by examining the response.success boolean attribute
|
|
37
|
+
|
|
38
|
+
If the request is successful the Advanced Configuration Properties are returned as JSON and can be accessed from
|
|
39
|
+
the response.json attribute
|
|
40
|
+
|
|
41
|
+
'''
|
|
42
|
+
parameters = DataObject()
|
|
43
|
+
parameters.add_value_string("sortBy", sort_by)
|
|
44
|
+
parameters.add_value_string("count", count)
|
|
45
|
+
parameters.add_value_string("start", start)
|
|
46
|
+
parameters.add_value_string("filter", filter)
|
|
47
|
+
|
|
48
|
+
response = self.client.get_json(OVERRIDE_CONFIGS, parameters.data)
|
|
49
|
+
response.success = response.status_code == 200
|
|
50
|
+
|
|
51
|
+
return response
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def update_property(self, id, value=None, sensitive=False):
|
|
55
|
+
'''
|
|
56
|
+
Update an AAC advanced configuration property.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
id (:obj:`str`): The id of the property to be updated.
|
|
60
|
+
value (:obj:`str`): The new value of the configuration property.
|
|
61
|
+
sensitive (`bool`, optional): Flag to indicate if value should be
|
|
62
|
+
obfuscated from logs/audit records. Default is ``false``.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
:obj:`~requests.Response`: The response from verify identity access.
|
|
66
|
+
|
|
67
|
+
Success can be checked by examining the response.success boolean attribute
|
|
68
|
+
|
|
69
|
+
'''
|
|
70
|
+
data = DataObject()
|
|
71
|
+
data.add_value_string("value", value)
|
|
72
|
+
data.add_value_boolean("sensitive", sensitive)
|
|
73
|
+
|
|
74
|
+
endpoint = "%s/%s" % (OVERRIDE_CONFIGS, id)
|
|
75
|
+
response = self.client.put_json(endpoint, data.data)
|
|
76
|
+
response.success = response.status_code == 204
|
|
77
|
+
|
|
78
|
+
return response
|