Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pkg_authentication_rule.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_pkg_authentication_rule
15 short_description: Configure Authentication Rules.
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 pkg:
29 description: The parameter (pkg) in requested url.
30 type: str
31 required: true
32 pkg_authentication_rule:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 active_auth_method:
38 aliases: ['active-auth-method']
39 type: str
40 description: Select an active authentication method.
41 comments:
42 type: str
43 description: Comment.
44 ip_based:
45 aliases: ['ip-based']
46 type: str
47 description: Enable/disable IP-based authentication.
48 choices: ['disable', 'enable']
49 name:
50 type: str
51 description: Authentication rule name.
52 required: true
53 protocol:
54 type: str
55 description: Select the protocol to use for authentication
56 choices: ['http', 'ftp', 'socks', 'ssh', 'ztna-portal']
57 srcaddr:
58 type: raw
59 description: (list or str) Select an IPv4 source address from available options.
60 srcaddr6:
61 type: raw
62 description: (list or str) Select an IPv6 source address.
63 sso_auth_method:
64 aliases: ['sso-auth-method']
65 type: str
66 description: Select a single-sign on
67 status:
68 type: str
69 description: Enable/disable this authentication rule.
70 choices: ['disable', 'enable']
71 transaction_based:
72 aliases: ['transaction-based']
73 type: str
74 description: Enable/disable transaction based authentication
75 choices: ['disable', 'enable']
76 web_auth_cookie:
77 aliases: ['web-auth-cookie']
78 type: str
79 description: Enable/disable Web authentication cookies
80 choices: ['disable', 'enable']
81 web_portal:
82 aliases: ['web-portal']
83 type: str
84 description: Enable/disable web portal for proxy transparent policy
85 choices: ['disable', 'enable']
86 dstaddr:
87 type: raw
88 description: (list or str) Select an IPv4 destination address from available options.
89 dstaddr6:
90 type: raw
91 description: (list or str) Select an IPv6 destination address from available options.
92 srcintf:
93 type: raw
94 description: (list or str) Incoming
95 cors_depth:
96 aliases: ['cors-depth']
97 type: int
98 description: Depth to allow CORS access
99 cors_stateful:
100 aliases: ['cors-stateful']
101 type: str
102 description: Enable/disable allowance of CORS access
103 choices: ['disable', 'enable']
104 cert_auth_cookie:
105 aliases: ['cert-auth-cookie']
106 type: str
107 description: Enable/disable to use device certificate as authentication cookie
108 choices: ['disable', 'enable']
109 form_auth_fallback:
110 aliases: ['form-auth-fallback']
111 type: str
112 description: Form auth fallback.
113 choices: ['disable', 'enable']
114 web_proxy:
115 aliases: ['web-proxy']
116 type: raw
117 description: (list) Web proxy.
118 session_logout:
119 aliases: ['session-logout']
120 type: str
121 description: Enable/disable logout of a user from the current session.
122 choices: ['disable', 'enable']
123 '''
124
125 EXAMPLES = '''
126 - name: Example playbook (generated based on argument schema)
127 hosts: fortimanagers
128 connection: httpapi
129 gather_facts: false
130 tasks:
131 - name: Configure Authentication Rules.
132 fortinet.fortimanager.fmgr_pkg_authentication_rule:
133 # workspace_locking_adom: <global or your adom name>
134 adom: <your own value>
135 pkg: <your own value>
136 state: present # <value in [present, absent]>
137 pkg_authentication_rule:
138 name: "your value" # Required variable, string
139 # active_auth_method: <string>
140 # comments: <string>
141 # ip_based: <value in [disable, enable]>
142 # protocol: <value in [http, ftp, socks, ...]>
143 # srcaddr: <list or string>
144 # srcaddr6: <list or string>
145 # sso_auth_method: <string>
146 # status: <value in [disable, enable]>
147 # transaction_based: <value in [disable, enable]>
148 # web_auth_cookie: <value in [disable, enable]>
149 # web_portal: <value in [disable, enable]>
150 # dstaddr: <list or string>
151 # dstaddr6: <list or string>
152 # srcintf: <list or string>
153 # cors_depth: <integer>
154 # cors_stateful: <value in [disable, enable]>
155 # cert_auth_cookie: <value in [disable, enable]>
156 # form_auth_fallback: <value in [disable, enable]>
157 # web_proxy: <list or string>
158 # session_logout: <value in [disable, enable]>
159 '''
160
161 RETURN = '''
162 meta:
163 description: The result of the request.
164 type: dict
165 returned: always
166 contains:
167 request_url:
168 description: The full url requested.
169 returned: always
170 type: str
171 sample: /sys/login/user
172 response_code:
173 description: The status of api request.
174 returned: always
175 type: int
176 sample: 0
177 response_data:
178 description: The api response.
179 type: list
180 returned: always
181 response_message:
182 description: The descriptive message of the api response.
183 type: str
184 returned: always
185 sample: OK.
186 system_information:
187 description: The information of the target system.
188 type: dict
189 returned: always
190 rc:
191 description: The status the request.
192 type: int
193 returned: always
194 sample: 0
195 version_check_warning:
196 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
197 type: list
198 returned: complex
199 '''
200 from ansible.module_utils.basic import AnsibleModule
201 from ansible.module_utils.connection import Connection
202 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
203 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
204
205
206 def main():
207 urls_list = [
208 '/pm/config/adom/{adom}/pkg/{pkg}/authentication/rule'
209 ]
210 module_arg_spec = {
211 'adom': {'required': True, 'type': 'str'},
212 'pkg': {'required': True, 'type': 'str'},
213 'revision_note': {'type': 'str'},
214 'pkg_authentication_rule': {
215 'type': 'dict', 'v_range': [['6.2.1', '']],
216 'options': {
217 'active-auth-method': {'v_range': [['6.2.1', '']], 'type': 'str'},
218 'comments': {'v_range': [['6.2.1', '']], 'type': 'str'},
219 'ip-based': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
220 'name': {'v_range': [['6.2.1', '']], 'required': True, 'type': 'str'},
221 'protocol': {'v_range': [['6.2.1', '']], 'choices': ['http', 'ftp', 'socks', 'ssh', 'ztna-portal'], 'type': 'str'},
222 'srcaddr': {'v_range': [['6.2.1', '']], 'type': 'raw'},
223 'srcaddr6': {'v_range': [['6.2.1', '']], 'type': 'raw'},
224 'sso-auth-method': {'v_range': [['6.2.1', '']], 'type': 'str'},
225 'status': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
226 'transaction-based': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
227 'web-auth-cookie': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
228 'web-portal': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
229 'dstaddr': {'v_range': [['7.0.0', '']], 'type': 'raw'},
230 'dstaddr6': {'v_range': [['7.0.0', '']], 'type': 'raw'},
231 'srcintf': {'v_range': [['7.0.0', '']], 'type': 'raw'},
232 'cors-depth': {'v_range': [['7.4.1', '']], 'type': 'int'},
233 'cors-stateful': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
234 'cert-auth-cookie': {'v_range': [['7.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
235 'form-auth-fallback': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
236 'web-proxy': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'raw'},
237 'session-logout': {'v_range': [['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
238 }
239 }
240 }
241
242 module_option_spec = get_module_arg_spec('full crud')
243 module_arg_spec.update(module_option_spec)
244 check_galaxy_version(module_arg_spec)
245 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_authentication_rule'),
246 supports_check_mode=True)
247 if not module._socket_path:
248 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
249 connection = Connection(module._socket_path)
250 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
251 'name', 'data', module, connection)
252 fmgr.process_crud()
253 module.exit_json(meta=module.params)
254
255
256 if __name__ == '__main__':
257 main()