Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_saml_dynamicmapping.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_dynamicmapping
15 short_description: SAML server entry configuration.
16 version_added: "2.2.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 saml:
29 description: The parameter (saml) in requested url.
30 type: str
31 required: true
32 user_saml_dynamicmapping:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 _scope:
38 type: list
39 elements: dict
40 description: Scope.
41 suboptions:
42 name:
43 type: str
44 description: Name.
45 vdom:
46 type: str
47 description: Vdom.
48 adfs_claim:
49 aliases: ['adfs-claim']
50 type: str
51 description: Enable/disable ADFS Claim for user/group attribute in assertion statement
52 choices: ['disable', 'enable']
53 cert:
54 type: str
55 description: Certificate to sign SAML messages.
56 clock_tolerance:
57 aliases: ['clock-tolerance']
58 type: int
59 description: Clock skew tolerance in seconds
60 digest_method:
61 aliases: ['digest-method']
62 type: str
63 description: Digest method algorithm
64 choices: ['sha1', 'sha256']
65 entity_id:
66 aliases: ['entity-id']
67 type: str
68 description: SP entity ID.
69 group_claim_type:
70 aliases: ['group-claim-type']
71 type: str
72 description: Group claim in assertion statement.
73 choices: ['email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x',
74 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid', 'name-identifier',
75 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid',
76 'deny-only-primary-group-sid', 'group-sid', 'primary-group-sid',
77 'primary-sid', 'windows-account-name']
78 group_name:
79 aliases: ['group-name']
80 type: str
81 description: Group name in assertion statement.
82 idp_cert:
83 aliases: ['idp-cert']
84 type: str
85 description: IDP Certificate name.
86 idp_entity_id:
87 aliases: ['idp-entity-id']
88 type: str
89 description: IDP entity ID.
90 idp_single_logout_url:
91 aliases: ['idp-single-logout-url']
92 type: str
93 description: IDP single logout url.
94 idp_single_sign_on_url:
95 aliases: ['idp-single-sign-on-url']
96 type: str
97 description: IDP single sign-on URL.
98 limit_relaystate:
99 aliases: ['limit-relaystate']
100 type: str
101 description: Enable/disable limiting of relay-state parameter when it exceeds SAML 2.
102 choices: ['disable', 'enable']
103 single_logout_url:
104 aliases: ['single-logout-url']
105 type: str
106 description: SP single logout URL.
107 single_sign_on_url:
108 aliases: ['single-sign-on-url']
109 type: str
110 description: SP single sign-on URL.
111 user_claim_type:
112 aliases: ['user-claim-type']
113 type: str
114 description: User name claim in assertion statement.
115 choices: ['email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x',
116 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid', 'name-identifier',
117 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid',
118 'deny-only-primary-group-sid', 'group-sid', 'primary-group-sid',
119 'primary-sid', 'windows-account-name']
120 user_name:
121 aliases: ['user-name']
122 type: str
123 description: User name in assertion statement.
124 auth_url:
125 aliases: ['auth-url']
126 type: str
127 description: URL to verify authentication.
128 reauth:
129 type: str
130 description: Enable/disable signalling of IDP to force user re-authentication
131 choices: ['disable', 'enable']
132 scim_client:
133 aliases: ['scim-client']
134 type: raw
135 description: (list) SCIM client name.
136 scim_group_attr_type:
137 aliases: ['scim-group-attr-type']
138 type: str
139 description: Group attribute type used to match SCIM groups
140 choices: ['display-name', 'external-id']
141 require_signed_resp_and_asrt:
142 aliases: ['require-signed-resp-and-asrt']
143 type: str
144 description: Require signed resp and asrt.
145 choices: ['disable', 'enable']
146 scim_user_attr_type:
147 aliases: ['scim-user-attr-type']
148 type: str
149 description: User attribute type used to match SCIM users
150 choices: ['display-name', 'external-id', 'user-name', 'email']
151 '''
152
153 EXAMPLES = '''
154 - name: Example playbook (generated based on argument schema)
155 hosts: fortimanagers
156 connection: httpapi
157 gather_facts: false
158 tasks:
159 - name: SAML server entry configuration.
160 fortinet.fortimanager.fmgr_user_saml_dynamicmapping:
161 # workspace_locking_adom: <global or your adom name>
162 adom: <your own value>
163 saml: <your own value>
164 state: present # <value in [present, absent]>
165 user_saml_dynamicmapping:
166 # _scope:
167 # - name: <string>
168 # vdom: <string>
169 # adfs_claim: <value in [disable, enable]>
170 # cert: <string>
171 # clock_tolerance: <integer>
172 # digest_method: <value in [sha1, sha256]>
173 # entity_id: <string>
174 # group_claim_type: <value in [email, given-name, name, ...]>
175 # group_name: <string>
176 # idp_cert: <string>
177 # idp_entity_id: <string>
178 # idp_single_logout_url: <string>
179 # idp_single_sign_on_url: <string>
180 # limit_relaystate: <value in [disable, enable]>
181 # single_logout_url: <string>
182 # single_sign_on_url: <string>
183 # user_claim_type: <value in [email, given-name, name, ...]>
184 # user_name: <string>
185 # auth_url: <string>
186 # reauth: <value in [disable, enable]>
187 # scim_client: <list or string>
188 # scim_group_attr_type: <value in [display-name, external-id]>
189 # require_signed_resp_and_asrt: <value in [disable, enable]>
190 # scim_user_attr_type: <value in [display-name, external-id, user-name, ...]>
191 '''
192
193 RETURN = '''
194 meta:
195 description: The result of the request.
196 type: dict
197 returned: always
198 contains:
199 request_url:
200 description: The full url requested.
201 returned: always
202 type: str
203 sample: /sys/login/user
204 response_code:
205 description: The status of api request.
206 returned: always
207 type: int
208 sample: 0
209 response_data:
210 description: The api response.
211 type: list
212 returned: always
213 response_message:
214 description: The descriptive message of the api response.
215 type: str
216 returned: always
217 sample: OK.
218 system_information:
219 description: The information of the target system.
220 type: dict
221 returned: always
222 rc:
223 description: The status the request.
224 type: int
225 returned: always
226 sample: 0
227 version_check_warning:
228 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
229 type: list
230 returned: complex
231 '''
232 from ansible.module_utils.basic import AnsibleModule
233 from ansible.module_utils.connection import Connection
234 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
235 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
236
237
238 def main():
239 urls_list = [
240 '/pm/config/adom/{adom}/obj/user/saml/{saml}/dynamic_mapping',
241 '/pm/config/global/obj/user/saml/{saml}/dynamic_mapping'
242 ]
243 module_arg_spec = {
244 'adom': {'required': True, 'type': 'str'},
245 'saml': {'required': True, 'type': 'str'},
246 'revision_note': {'type': 'str'},
247 'user_saml_dynamicmapping': {
248 'type': 'dict', 'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']],
249 'options': {
250 '_scope': {
251 'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']],
252 'type': 'list',
253 'options': {
254 'name': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
255 'vdom': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'}
256 },
257 'elements': 'dict'
258 },
259 'adfs-claim': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
260 'cert': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
261 'clock-tolerance': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'int'},
262 'digest-method': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'choices': ['sha1', 'sha256'], 'type': 'str'},
263 'entity-id': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
264 'group-claim-type': {
265 'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']],
266 'choices': [
267 'email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x', 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid',
268 'name-identifier', 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid', 'deny-only-primary-group-sid',
269 'group-sid', 'primary-group-sid', 'primary-sid', 'windows-account-name'
270 ],
271 'type': 'str'
272 },
273 'group-name': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
274 'idp-cert': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
275 'idp-entity-id': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
276 'idp-single-logout-url': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
277 'idp-single-sign-on-url': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
278 'limit-relaystate': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
279 'single-logout-url': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
280 'single-sign-on-url': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
281 'user-claim-type': {
282 'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']],
283 'choices': [
284 'email', 'given-name', 'name', 'upn', 'common-name', 'email-adfs-1x', 'group', 'upn-adfs-1x', 'role', 'sur-name', 'ppid',
285 'name-identifier', 'authentication-method', 'deny-only-group-sid', 'deny-only-primary-sid', 'deny-only-primary-group-sid',
286 'group-sid', 'primary-group-sid', 'primary-sid', 'windows-account-name'
287 ],
288 'type': 'str'
289 },
290 'user-name': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'type': 'str'},
291 'auth-url': {'v_range': [['7.2.1', '']], 'type': 'str'},
292 'reauth': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
293 'scim-client': {'v_range': [['7.6.0', '']], 'type': 'raw'},
294 'scim-group-attr-type': {'v_range': [['7.6.3', '']], 'choices': ['display-name', 'external-id'], 'type': 'str'},
295 'require-signed-resp-and-asrt': {
296 'v_range': [['7.0.15', '7.0.16'], ['7.4.9', '7.4.10'], ['7.6.5', '']],
297 'choices': ['disable', 'enable'],
298 'type': 'str'
299 },
300 'scim-user-attr-type': {'v_range': [['7.6.4', '']], 'choices': ['display-name', 'external-id', 'user-name', 'email'], 'type': 'str'}
301 }
302 }
303 }
304
305 module_option_spec = get_module_arg_spec('full crud')
306 module_arg_spec.update(module_option_spec)
307 check_galaxy_version(module_arg_spec)
308 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_saml_dynamicmapping'),
309 supports_check_mode=True)
310 if not module._socket_path:
311 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
312 connection = Connection(module._socket_path)
313 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
314 None, 'data', module, connection)
315 fmgr.process_crud()
316 module.exit_json(meta=module.params)
317
318
319 if __name__ == '__main__':
320 main()