| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 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_authentication_scheme |
| 15 |
short_description: Configure Authentication Schemes. |
| 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 |
authentication_scheme: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
domain_controller: |
| 34 |
aliases: ['domain-controller'] |
| 35 |
type: str |
| 36 |
description: Domain controller setting. |
| 37 |
fsso_agent_for_ntlm: |
| 38 |
aliases: ['fsso-agent-for-ntlm'] |
| 39 |
type: str |
| 40 |
description: FSSO agent to use for NTLM authentication. |
| 41 |
fsso_guest: |
| 42 |
aliases: ['fsso-guest'] |
| 43 |
type: str |
| 44 |
description: Enable/disable user fsso-guest authentication |
| 45 |
choices: ['disable', 'enable'] |
| 46 |
kerberos_keytab: |
| 47 |
aliases: ['kerberos-keytab'] |
| 48 |
type: str |
| 49 |
description: Kerberos keytab setting. |
| 50 |
method: |
| 51 |
type: list |
| 52 |
elements: str |
| 53 |
description: Authentication methods |
| 54 |
choices: ['ntlm', 'basic', 'digest', 'form', 'negotiate', 'fsso', 'rsso', |
| 55 |
'ssh-publickey', 'saml', 'cert', 'x-auth-user', 'saml-sp', 'entra-sso', |
| 56 |
'ztna-relay', 'oidc'] |
| 57 |
name: |
| 58 |
type: str |
| 59 |
description: Authentication scheme name. |
| 60 |
required: true |
| 61 |
negotiate_ntlm: |
| 62 |
aliases: ['negotiate-ntlm'] |
| 63 |
type: str |
| 64 |
description: Enable/disable negotiate authentication for NTLM |
| 65 |
choices: ['disable', 'enable'] |
| 66 |
require_tfa: |
| 67 |
aliases: ['require-tfa'] |
| 68 |
type: str |
| 69 |
description: Enable/disable two-factor authentication |
| 70 |
choices: ['disable', 'enable'] |
| 71 |
ssh_ca: |
| 72 |
aliases: ['ssh-ca'] |
| 73 |
type: str |
| 74 |
description: SSH CA name. |
| 75 |
user_database: |
| 76 |
aliases: ['user-database'] |
| 77 |
type: raw |
| 78 |
description: (list or str) Authentication server to contain user information; local |
| 79 |
ems_device_owner: |
| 80 |
aliases: ['ems-device-owner'] |
| 81 |
type: str |
| 82 |
description: Enable/disable SSH public-key authentication with device owner |
| 83 |
choices: ['disable', 'enable'] |
| 84 |
saml_server: |
| 85 |
aliases: ['saml-server'] |
| 86 |
type: str |
| 87 |
description: SAML configuration. |
| 88 |
saml_timeout: |
| 89 |
aliases: ['saml-timeout'] |
| 90 |
type: int |
| 91 |
description: SAML authentication timeout in seconds. |
| 92 |
user_cert: |
| 93 |
aliases: ['user-cert'] |
| 94 |
type: str |
| 95 |
description: Enable/disable authentication with user certificate |
| 96 |
choices: ['disable', 'enable'] |
| 97 |
external_idp: |
| 98 |
aliases: ['external-idp'] |
| 99 |
type: raw |
| 100 |
description: (list) External identity provider configuration. |
| 101 |
digest_algo: |
| 102 |
aliases: ['digest-algo'] |
| 103 |
type: list |
| 104 |
elements: str |
| 105 |
description: Digest Authentication Algorithms. |
| 106 |
choices: ['md5', 'sha-256'] |
| 107 |
group_attr_type: |
| 108 |
aliases: ['group-attr-type'] |
| 109 |
type: str |
| 110 |
description: Group attribute type used to match SCIM groups |
| 111 |
choices: ['display-name', 'external-id'] |
| 112 |
search_all_ldap_databases: |
| 113 |
aliases: ['search-all-ldap-databases'] |
| 114 |
type: str |
| 115 |
description: Search all ldap databases. |
| 116 |
choices: ['disable', 'enable'] |
| 117 |
saml_idp_portal: |
| 118 |
aliases: ['saml-idp-portal'] |
| 119 |
type: str |
| 120 |
description: External SAML-IDP authentication Portal URL. |
| 121 |
oidc_server: |
| 122 |
aliases: ['oidc-server'] |
| 123 |
type: raw |
| 124 |
description: (list) Oidc server. |
| 125 |
oidc_timeout: |
| 126 |
aliases: ['oidc-timeout'] |
| 127 |
type: int |
| 128 |
description: Oidc timeout. |
| 129 |
digest_rfc2069: |
| 130 |
aliases: ['digest-rfc2069'] |
| 131 |
type: str |
| 132 |
description: Enable/disable support for the deprecated RFC2069 Digest Client |
| 133 |
choices: ['disable', 'enable'] |
| 134 |
auth_user_header: |
| 135 |
aliases: ['auth-user-header'] |
| 136 |
type: str |
| 137 |
description: Auth user header. |
| 138 |
captcha: |
| 139 |
type: str |
| 140 |
description: Captcha. |
| 141 |
choices: ['disable', 'enable'] |
| 142 |
captcha_secret_key: |
| 143 |
aliases: ['captcha-secret-key'] |
| 144 |
type: str |
| 145 |
description: Captcha secret key. |
| 146 |
captcha_site_key: |
| 147 |
aliases: ['captcha-site-key'] |
| 148 |
type: str |
| 149 |
description: Captcha site key. |
| 150 |
captcha_vendor: |
| 151 |
aliases: ['captcha-vendor'] |
| 152 |
type: str |
| 153 |
description: Captcha vendor. |
| 154 |
choices: ['google-recaptcha-v2-checkbox', 'google-recaptcha-v2-invisible', |
| 155 |
'google-recaptcha-v3', 'cloudflare-turnstile'] |
| 156 |
cert_http_header: |
| 157 |
aliases: ['cert-http-header'] |
| 158 |
type: str |
| 159 |
description: Enable/disable authentication with user certificate in Client-Cert HTTP header |
| 160 |
choices: ['disable', 'enable'] |
| 161 |
''' |
| 162 |
|
| 163 |
EXAMPLES = ''' |
| 164 |
- name: Example playbook (generated based on argument schema) |
| 165 |
hosts: fortimanagers |
| 166 |
connection: httpapi |
| 167 |
gather_facts: false |
| 168 |
tasks: |
| 169 |
- name: Configure Authentication Schemes. |
| 170 |
fortinet.fortimanager.fmgr_authentication_scheme: |
| 171 |
# workspace_locking_adom: <global or your adom name> |
| 172 |
adom: <your own value> |
| 173 |
state: present # <value in [present, absent]> |
| 174 |
authentication_scheme: |
| 175 |
name: "your value" # Required variable, string |
| 176 |
# domain_controller: <string> |
| 177 |
# fsso_agent_for_ntlm: <string> |
| 178 |
# fsso_guest: <value in [disable, enable]> |
| 179 |
# kerberos_keytab: <string> |
| 180 |
# method: ["ntlm", "basic", "digest", "form", "negotiate", "fsso", "rsso", |
| 181 |
# "ssh-publickey", "saml", "cert", "x-auth-user", "saml-sp", "entra-sso", |
| 182 |
# "ztna-relay", "oidc"] |
| 183 |
# negotiate_ntlm: <value in [disable, enable]> |
| 184 |
# require_tfa: <value in [disable, enable]> |
| 185 |
# ssh_ca: <string> |
| 186 |
# user_database: <list or string> |
| 187 |
# ems_device_owner: <value in [disable, enable]> |
| 188 |
# saml_server: <string> |
| 189 |
# saml_timeout: <integer> |
| 190 |
# user_cert: <value in [disable, enable]> |
| 191 |
# external_idp: <list or string> |
| 192 |
# digest_algo: ["md5", "sha-256"] |
| 193 |
# group_attr_type: <value in [display-name, external-id]> |
| 194 |
# search_all_ldap_databases: <value in [disable, enable]> |
| 195 |
# saml_idp_portal: <string> |
| 196 |
# oidc_server: <list or string> |
| 197 |
# oidc_timeout: <integer> |
| 198 |
# digest_rfc2069: <value in [disable, enable]> |
| 199 |
# auth_user_header: <string> |
| 200 |
# captcha: <value in [disable, enable]> |
| 201 |
# captcha_secret_key: <string> |
| 202 |
# captcha_site_key: <string> |
| 203 |
# captcha_vendor: <value in [google-recaptcha-v2-checkbox, google-recaptcha-v2-invisible, google-recaptcha-v3, ...]> |
| 204 |
# cert_http_header: <value in [disable, enable]> |
| 205 |
''' |
| 206 |
|
| 207 |
RETURN = ''' |
| 208 |
meta: |
| 209 |
description: The result of the request. |
| 210 |
type: dict |
| 211 |
returned: always |
| 212 |
contains: |
| 213 |
request_url: |
| 214 |
description: The full url requested. |
| 215 |
returned: always |
| 216 |
type: str |
| 217 |
sample: /sys/login/user |
| 218 |
response_code: |
| 219 |
description: The status of api request. |
| 220 |
returned: always |
| 221 |
type: int |
| 222 |
sample: 0 |
| 223 |
response_data: |
| 224 |
description: The api response. |
| 225 |
type: list |
| 226 |
returned: always |
| 227 |
response_message: |
| 228 |
description: The descriptive message of the api response. |
| 229 |
type: str |
| 230 |
returned: always |
| 231 |
sample: OK. |
| 232 |
system_information: |
| 233 |
description: The information of the target system. |
| 234 |
type: dict |
| 235 |
returned: always |
| 236 |
rc: |
| 237 |
description: The status the request. |
| 238 |
type: int |
| 239 |
returned: always |
| 240 |
sample: 0 |
| 241 |
version_check_warning: |
| 242 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 243 |
type: list |
| 244 |
returned: complex |
| 245 |
''' |
| 246 |
from ansible.module_utils.basic import AnsibleModule |
| 247 |
from ansible.module_utils.connection import Connection |
| 248 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 249 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 250 |
|
| 251 |
|
| 252 |
def main(): |
| 253 |
urls_list = [ |
| 254 |
'/pm/config/adom/{adom}/obj/authentication/scheme', |
| 255 |
'/pm/config/global/obj/authentication/scheme' |
| 256 |
] |
| 257 |
module_arg_spec = { |
| 258 |
'adom': {'required': True, 'type': 'str'}, |
| 259 |
'revision_note': {'type': 'str'}, |
| 260 |
'authentication_scheme': { |
| 261 |
'type': 'dict', 'v_range': [['6.2.1', '']], |
| 262 |
'options': { |
| 263 |
'domain-controller': {'v_range': [['6.2.1', '']], 'type': 'str'}, |
| 264 |
'fsso-agent-for-ntlm': {'v_range': [['6.2.1', '']], 'type': 'str'}, |
| 265 |
'fsso-guest': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 266 |
'kerberos-keytab': {'v_range': [['6.2.1', '']], 'no_log': True, 'type': 'str'}, |
| 267 |
'method': { |
| 268 |
'v_range': [['6.2.1', '']], |
| 269 |
'type': 'list', |
| 270 |
'choices': [ |
| 271 |
'ntlm', 'basic', 'digest', 'form', 'negotiate', 'fsso', 'rsso', 'ssh-publickey', 'saml', 'cert', 'x-auth-user', 'saml-sp', |
| 272 |
'entra-sso', 'ztna-relay', 'oidc' |
| 273 |
], |
| 274 |
'elements': 'str' |
| 275 |
}, |
| 276 |
'name': {'v_range': [['6.2.1', '']], 'required': True, 'type': 'str'}, |
| 277 |
'negotiate-ntlm': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 278 |
'require-tfa': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 279 |
'ssh-ca': {'v_range': [['6.2.1', '']], 'type': 'str'}, |
| 280 |
'user-database': {'v_range': [['6.2.1', '']], 'type': 'raw'}, |
| 281 |
'ems-device-owner': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 282 |
'saml-server': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 283 |
'saml-timeout': {'v_range': [['7.0.0', '']], 'type': 'int'}, |
| 284 |
'user-cert': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 285 |
'external-idp': {'v_range': [['7.6.2', '']], 'type': 'raw'}, |
| 286 |
'digest-algo': {'v_range': [['7.6.3', '']], 'type': 'list', 'choices': ['md5', 'sha-256'], 'elements': 'str'}, |
| 287 |
'group-attr-type': {'v_range': [['7.6.3', '']], 'choices': ['display-name', 'external-id'], 'type': 'str'}, |
| 288 |
'search-all-ldap-databases': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 289 |
'saml-idp-portal': {'v_range': [['7.4.8', '7.4.10']], 'type': 'str'}, |
| 290 |
'oidc-server': {'v_range': [['7.6.4', '']], 'type': 'raw'}, |
| 291 |
'oidc-timeout': {'v_range': [['7.6.4', '']], 'type': 'int'}, |
| 292 |
'digest-rfc2069': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 293 |
'auth-user-header': {'v_range': [['7.4.9', '7.4.10'], ['7.6.5', '']], 'type': 'str'}, |
| 294 |
'captcha': {'v_range': [['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 295 |
'captcha-secret-key': {'v_range': [['7.6.5', '']], 'no_log': True, 'type': 'str'}, |
| 296 |
'captcha-site-key': {'v_range': [['7.6.5', '']], 'no_log': True, 'type': 'str'}, |
| 297 |
'captcha-vendor': { |
| 298 |
'v_range': [['7.6.5', '']], |
| 299 |
'choices': ['google-recaptcha-v2-checkbox', 'google-recaptcha-v2-invisible', 'google-recaptcha-v3', 'cloudflare-turnstile'], |
| 300 |
'type': 'str' |
| 301 |
}, |
| 302 |
'cert-http-header': {'v_range': [['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 303 |
} |
| 304 |
} |
| 305 |
} |
| 306 |
|
| 307 |
module_option_spec = get_module_arg_spec('full crud') |
| 308 |
module_arg_spec.update(module_option_spec) |
| 309 |
check_galaxy_version(module_arg_spec) |
| 310 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'authentication_scheme'), |
| 311 |
supports_check_mode=True) |
| 312 |
if not module._socket_path: |
| 313 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 314 |
connection = Connection(module._socket_path) |
| 315 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 316 |
'name', 'data', module, connection) |
| 317 |
fmgr.process_crud() |
| 318 |
module.exit_json(meta=module.params) |
| 319 |
|
| 320 |
|
| 321 |
if __name__ == '__main__': |
| 322 |
main() |