Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_saml.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_user_saml
15 short_description: SAML server entry configuration.
16 version_added: "2.1.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 user_saml:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 cert:
34 type: str
35 description: Certificate to sign SAML messages.
36 entity_id:
37 aliases: ['entity-id']
38 type: str
39 description: SP entity ID.
40 group_name:
41 aliases: ['group-name']
42 type: str
43 description: Group name in assertion statement.
44 idp_cert:
45 aliases: ['idp-cert']
46 type: str
47 description: IDP Certificate name.
48 idp_entity_id:
49 aliases: ['idp-entity-id']
50 type: str
51 description: IDP entity ID.
52 idp_single_logout_url:
53 aliases: ['idp-single-logout-url']
54 type: str
55 description: IDP single logout url.
56 idp_single_sign_on_url:
57 aliases: ['idp-single-sign-on-url']
58 type: str
59 description: IDP single sign-on URL.
60 name:
61 type: str
62 description: SAML server entry name.
63 required: true
64 single_logout_url:
65 aliases: ['single-logout-url']
66 type: str
67 description: SP single logout URL.
68 single_sign_on_url:
69 aliases: ['single-sign-on-url']
70 type: str
71 description: SP single sign-on URL.
72 user_name:
73 aliases: ['user-name']
74 type: str
75 description: User name in assertion statement.
76 adfs_claim:
77 aliases: ['adfs-claim']
78 type: str
79 description: Enable/disable ADFS Claim for user/group attribute in assertion statement
80 choices: ['disable', 'enable']
81 digest_method:
82 aliases: ['digest-method']
83 type: str
84 description: Digest Method Algorithm.
85 choices: ['sha1', 'sha256']
86 group_claim_type:
87 aliases: ['group-claim-type']
88 type: str
89 description: Group claim in assertion statement.
90 choices: ['email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x',
91 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid', 'name-identifier',
92 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid',
93 'deny-only-primary-group-sid', 'group-sid', 'primary-group-sid',
94 'primary-sid', 'windows-account-name']
95 limit_relaystate:
96 aliases: ['limit-relaystate']
97 type: str
98 description: Enable/disable limiting of relay-state parameter when it exceeds SAML 2.
99 choices: ['disable', 'enable']
100 user_claim_type:
101 aliases: ['user-claim-type']
102 type: str
103 description: User name claim in assertion statement.
104 choices: ['email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x',
105 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid', 'name-identifier',
106 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid',
107 'deny-only-primary-group-sid', 'group-sid', 'primary-group-sid',
108 'primary-sid', 'windows-account-name']
109 clock_tolerance:
110 aliases: ['clock-tolerance']
111 type: int
112 description: Clock skew tolerance in seconds
113 dynamic_mapping:
114 type: list
115 elements: dict
116 description: Dynamic mapping.
117 suboptions:
118 _scope:
119 type: list
120 elements: dict
121 description: Scope.
122 suboptions:
123 name:
124 type: str
125 description: Name.
126 vdom:
127 type: str
128 description: Vdom.
129 adfs_claim:
130 aliases: ['adfs-claim']
131 type: str
132 description: Enable/disable ADFS Claim for user/group attribute in assertion statement
133 choices: ['disable', 'enable']
134 cert:
135 type: str
136 description: Certificate to sign SAML messages.
137 clock_tolerance:
138 aliases: ['clock-tolerance']
139 type: int
140 description: Clock skew tolerance in seconds
141 digest_method:
142 aliases: ['digest-method']
143 type: str
144 description: Digest method algorithm
145 choices: ['sha1', 'sha256']
146 entity_id:
147 aliases: ['entity-id']
148 type: str
149 description: SP entity ID.
150 group_claim_type:
151 aliases: ['group-claim-type']
152 type: str
153 description: Group claim in assertion statement.
154 choices: ['email', 'given-name', 'name', 'upn', 'common-name',
155 'email-adfs-1x', 'group', 'upn-adfs-1x', 'role', 'sur-name',
156 'ppid', 'name-identifier', 'authentication-method',
157 'deny-only-group-sid', 'deny-only-primary-sid',
158 'deny-only-primary-group-sid', 'group-sid', 'primary-group-sid',
159 'primary-sid', 'windows-account-name']
160 group_name:
161 aliases: ['group-name']
162 type: str
163 description: Group name in assertion statement.
164 idp_cert:
165 aliases: ['idp-cert']
166 type: str
167 description: IDP Certificate name.
168 idp_entity_id:
169 aliases: ['idp-entity-id']
170 type: str
171 description: IDP entity ID.
172 idp_single_logout_url:
173 aliases: ['idp-single-logout-url']
174 type: str
175 description: IDP single logout url.
176 idp_single_sign_on_url:
177 aliases: ['idp-single-sign-on-url']
178 type: str
179 description: IDP single sign-on URL.
180 limit_relaystate:
181 aliases: ['limit-relaystate']
182 type: str
183 description: Enable/disable limiting of relay-state parameter when it exceeds SAML 2.
184 choices: ['disable', 'enable']
185 single_logout_url:
186 aliases: ['single-logout-url']
187 type: str
188 description: SP single logout URL.
189 single_sign_on_url:
190 aliases: ['single-sign-on-url']
191 type: str
192 description: SP single sign-on URL.
193 user_claim_type:
194 aliases: ['user-claim-type']
195 type: str
196 description: User name claim in assertion statement.
197 choices: ['email', 'given-name', 'name', 'upn', 'common-name',
198 'email-adfs-1x', 'group', 'upn-adfs-1x', 'role', 'sur-name',
199 'ppid', 'name-identifier', 'authentication-method',
200 'deny-only-group-sid', 'deny-only-primary-sid',
201 'deny-only-primary-group-sid', 'group-sid', 'primary-group-sid',
202 'primary-sid', 'windows-account-name']
203 user_name:
204 aliases: ['user-name']
205 type: str
206 description: User name in assertion statement.
207 auth_url:
208 aliases: ['auth-url']
209 type: str
210 description: URL to verify authentication.
211 reauth:
212 type: str
213 description: Enable/disable signalling of IDP to force user re-authentication
214 choices: ['disable', 'enable']
215 scim_client:
216 aliases: ['scim-client']
217 type: raw
218 description: (list) SCIM client name.
219 scim_group_attr_type:
220 aliases: ['scim-group-attr-type']
221 type: str
222 description: Group attribute type used to match SCIM groups
223 choices: ['display-name', 'external-id']
224 require_signed_resp_and_asrt:
225 aliases: ['require-signed-resp-and-asrt']
226 type: str
227 description: Require signed resp and asrt.
228 choices: ['disable', 'enable']
229 scim_user_attr_type:
230 aliases: ['scim-user-attr-type']
231 type: str
232 description: User attribute type used to match SCIM users
233 choices: ['display-name', 'external-id', 'user-name', 'email']
234 auth_url:
235 aliases: ['auth-url']
236 type: str
237 description: URL to verify authentication.
238 reauth:
239 type: str
240 description: Enable/disable signalling of IDP to force user re-authentication
241 choices: ['disable', 'enable']
242 scim_client:
243 aliases: ['scim-client']
244 type: raw
245 description: (list) SCIM client name.
246 scim_group_attr_type:
247 aliases: ['scim-group-attr-type']
248 type: str
249 description: Group attribute type used to match SCIM groups
250 choices: ['display-name', 'external-id']
251 require_signed_resp_and_asrt:
252 aliases: ['require-signed-resp-and-asrt']
253 type: str
254 description: Require signed resp and asrt.
255 choices: ['disable', 'enable']
256 scim_user_attr_type:
257 aliases: ['scim-user-attr-type']
258 type: str
259 description: User attribute type used to match SCIM users
260 choices: ['display-name', 'external-id', 'user-name', 'email']
261 '''
262
263 EXAMPLES = '''
264 - name: Example playbook (generated based on argument schema)
265 hosts: fortimanagers
266 connection: httpapi
267 gather_facts: false
268 tasks:
269 - name: SAML server entry configuration.
270 fortinet.fortimanager.fmgr_user_saml:
271 # workspace_locking_adom: <global or your adom name>
272 adom: <your own value>
273 state: present # <value in [present, absent]>
274 user_saml:
275 name: "your value" # Required variable, string
276 # cert: <string>
277 # entity_id: <string>
278 # group_name: <string>
279 # idp_cert: <string>
280 # idp_entity_id: <string>
281 # idp_single_logout_url: <string>
282 # idp_single_sign_on_url: <string>
283 # single_logout_url: <string>
284 # single_sign_on_url: <string>
285 # user_name: <string>
286 # adfs_claim: <value in [disable, enable]>
287 # digest_method: <value in [sha1, sha256]>
288 # group_claim_type: <value in [email, given-name, name, ...]>
289 # limit_relaystate: <value in [disable, enable]>
290 # user_claim_type: <value in [email, given-name, name, ...]>
291 # clock_tolerance: <integer>
292 # dynamic_mapping:
293 # - _scope:
294 # - name: <string>
295 # vdom: <string>
296 # adfs_claim: <value in [disable, enable]>
297 # cert: <string>
298 # clock_tolerance: <integer>
299 # digest_method: <value in [sha1, sha256]>
300 # entity_id: <string>
301 # group_claim_type: <value in [email, given-name, name, ...]>
302 # group_name: <string>
303 # idp_cert: <string>
304 # idp_entity_id: <string>
305 # idp_single_logout_url: <string>
306 # idp_single_sign_on_url: <string>
307 # limit_relaystate: <value in [disable, enable]>
308 # single_logout_url: <string>
309 # single_sign_on_url: <string>
310 # user_claim_type: <value in [email, given-name, name, ...]>
311 # user_name: <string>
312 # auth_url: <string>
313 # reauth: <value in [disable, enable]>
314 # scim_client: <list or string>
315 # scim_group_attr_type: <value in [display-name, external-id]>
316 # require_signed_resp_and_asrt: <value in [disable, enable]>
317 # scim_user_attr_type: <value in [display-name, external-id, user-name, ...]>
318 # auth_url: <string>
319 # reauth: <value in [disable, enable]>
320 # scim_client: <list or string>
321 # scim_group_attr_type: <value in [display-name, external-id]>
322 # require_signed_resp_and_asrt: <value in [disable, enable]>
323 # scim_user_attr_type: <value in [display-name, external-id, user-name, ...]>
324 '''
325
326 RETURN = '''
327 meta:
328 description: The result of the request.
329 type: dict
330 returned: always
331 contains:
332 request_url:
333 description: The full url requested.
334 returned: always
335 type: str
336 sample: /sys/login/user
337 response_code:
338 description: The status of api request.
339 returned: always
340 type: int
341 sample: 0
342 response_data:
343 description: The api response.
344 type: list
345 returned: always
346 response_message:
347 description: The descriptive message of the api response.
348 type: str
349 returned: always
350 sample: OK.
351 system_information:
352 description: The information of the target system.
353 type: dict
354 returned: always
355 rc:
356 description: The status the request.
357 type: int
358 returned: always
359 sample: 0
360 version_check_warning:
361 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
362 type: list
363 returned: complex
364 '''
365 from ansible.module_utils.basic import AnsibleModule
366 from ansible.module_utils.connection import Connection
367 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
368 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
369
370
371 def main():
372 urls_list = [
373 '/pm/config/adom/{adom}/obj/user/saml',
374 '/pm/config/global/obj/user/saml'
375 ]
376 module_arg_spec = {
377 'adom': {'required': True, 'type': 'str'},
378 'revision_note': {'type': 'str'},
379 'user_saml': {
380 'type': 'dict', 'v_range': [['6.4.0', '']],
381 'options': {
382 'cert': {'v_range': [['6.4.0', '']], 'type': 'str'},
383 'entity-id': {'v_range': [['6.4.0', '']], 'type': 'str'},
384 'group-name': {'v_range': [['6.4.0', '']], 'type': 'str'},
385 'idp-cert': {'v_range': [['6.4.0', '']], 'type': 'str'},
386 'idp-entity-id': {'v_range': [['6.4.0', '']], 'type': 'str'},
387 'idp-single-logout-url': {'v_range': [['6.4.0', '']], 'type': 'str'},
388 'idp-single-sign-on-url': {'v_range': [['6.4.0', '']], 'type': 'str'},
389 'name': {'v_range': [['6.4.0', '']], 'required': True, 'type': 'str'},
390 'single-logout-url': {'v_range': [['6.4.0', '']], 'type': 'str'},
391 'single-sign-on-url': {'v_range': [['6.4.0', '']], 'type': 'str'},
392 'user-name': {'v_range': [['6.4.0', '']], 'type': 'str'},
393 'adfs-claim': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
394 'digest-method': {'v_range': [['7.0.0', '']], 'choices': ['sha1', 'sha256'], 'type': 'str'},
395 'group-claim-type': {
396 'v_range': [['7.0.0', '']],
397 'choices': [
398 'email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x', 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid',
399 'name-identifier', 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid', 'deny-only-primary-group-sid',
400 'group-sid', 'primary-group-sid', 'primary-sid', 'windows-account-name'
401 ],
402 'type': 'str'
403 },
404 'limit-relaystate': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
405 'user-claim-type': {
406 'v_range': [['7.0.0', '']],
407 'choices': [
408 'email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x', 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid',
409 'name-identifier', 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid', 'deny-only-primary-group-sid',
410 'group-sid', 'primary-group-sid', 'primary-sid', 'windows-account-name'
411 ],
412 'type': 'str'
413 },
414 'clock-tolerance': {'v_range': [['7.0.3', '']], 'type': 'int'},
415 'dynamic_mapping': {
416 'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']],
417 'type': 'list',
418 'options': {
419 '_scope': {
420 'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']],
421 'type': 'list',
422 'options': {
423 'name': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
424 'vdom': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'}
425 },
426 'elements': 'dict'
427 },
428 'adfs-claim': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
429 'cert': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
430 'clock-tolerance': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'int'},
431 'digest-method': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'choices': ['sha1', 'sha256'], 'type': 'str'},
432 'entity-id': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
433 'group-claim-type': {
434 'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']],
435 'choices': [
436 'email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x', 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid',
437 'name-identifier', 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid',
438 'deny-only-primary-group-sid', 'group-sid', 'primary-group-sid', 'primary-sid', 'windows-account-name'
439 ],
440 'type': 'str'
441 },
442 'group-name': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
443 'idp-cert': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
444 'idp-entity-id': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
445 'idp-single-logout-url': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
446 'idp-single-sign-on-url': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
447 'limit-relaystate': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
448 'single-logout-url': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
449 'single-sign-on-url': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
450 'user-claim-type': {
451 'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']],
452 'choices': [
453 'email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x', 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid',
454 'name-identifier', 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid',
455 'deny-only-primary-group-sid', 'group-sid', 'primary-group-sid', 'primary-sid', 'windows-account-name'
456 ],
457 'type': 'str'
458 },
459 'user-name': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
460 'auth-url': {'v_range': [['7.2.1', '']], 'type': 'str'},
461 'reauth': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
462 'scim-client': {'v_range': [['7.6.0', '']], 'type': 'raw'},
463 'scim-group-attr-type': {'v_range': [['7.6.3', '']], 'choices': ['display-name', 'external-id'], 'type': 'str'},
464 'require-signed-resp-and-asrt': {
465 'v_range': [['7.0.15', '7.0.16'], ['7.4.9', '7.4.10'], ['7.6.5', '']],
466 'choices': ['disable', 'enable'],
467 'type': 'str'
468 },
469 'scim-user-attr-type': {
470 'v_range': [['7.6.4', '']],
471 'choices': ['display-name', 'external-id', 'user-name', 'email'],
472 'type': 'str'
473 }
474 },
475 'elements': 'dict'
476 },
477 'auth-url': {'v_range': [['7.2.1', '']], 'type': 'str'},
478 'reauth': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
479 'scim-client': {'v_range': [['7.6.0', '']], 'type': 'raw'},
480 'scim-group-attr-type': {'v_range': [['7.6.3', '']], 'choices': ['display-name', 'external-id'], 'type': 'str'},
481 'require-signed-resp-and-asrt': {
482 'v_range': [['7.0.15', '7.0.16'], ['7.4.9', '7.4.10'], ['7.6.5', '']],
483 'choices': ['disable', 'enable'],
484 'type': 'str'
485 },
486 'scim-user-attr-type': {'v_range': [['7.6.4', '']], 'choices': ['display-name', 'external-id', 'user-name', 'email'], 'type': 'str'}
487 }
488 }
489 }
490
491 module_option_spec = get_module_arg_spec('full crud')
492 module_arg_spec.update(module_option_spec)
493 check_galaxy_version(module_arg_spec)
494 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_saml'),
495 supports_check_mode=True)
496 if not module._socket_path:
497 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
498 connection = Connection(module._socket_path)
499 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
500 'name', 'data', module, connection)
501 fmgr.process_crud()
502 module.exit_json(meta=module.params)
503
504
505 if __name__ == '__main__':
506 main()