| 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_system_saml |
| 15 |
short_description: Global settings for SAML authentication. |
| 16 |
version_added: "2.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.partial_crud |
| 20 |
options: |
| 21 |
system_saml: |
| 22 |
description: The top level parameters set. |
| 23 |
required: false |
| 24 |
type: dict |
| 25 |
suboptions: |
| 26 |
acs_url: |
| 27 |
aliases: ['acs-url'] |
| 28 |
type: str |
| 29 |
description: SP ACS |
| 30 |
cert: |
| 31 |
type: str |
| 32 |
description: Certificate name. |
| 33 |
entity_id: |
| 34 |
aliases: ['entity-id'] |
| 35 |
type: str |
| 36 |
description: SP entity ID. |
| 37 |
idp_cert: |
| 38 |
aliases: ['idp-cert'] |
| 39 |
type: str |
| 40 |
description: IDP Certificate name. |
| 41 |
idp_entity_id: |
| 42 |
aliases: ['idp-entity-id'] |
| 43 |
type: str |
| 44 |
description: IDP entity ID. |
| 45 |
idp_single_logout_url: |
| 46 |
aliases: ['idp-single-logout-url'] |
| 47 |
type: str |
| 48 |
description: IDP single logout url. |
| 49 |
idp_single_sign_on_url: |
| 50 |
aliases: ['idp-single-sign-on-url'] |
| 51 |
type: str |
| 52 |
description: IDP single sign-on URL. |
| 53 |
login_auto_redirect: |
| 54 |
aliases: ['login-auto-redirect'] |
| 55 |
type: str |
| 56 |
description: |
| 57 |
- Enable/Disable auto redirect to IDP login page. |
| 58 |
- disable - Disable auto redirect to IDP Login Page. |
| 59 |
- enable - Enable auto redirect to IDP Login Page. |
| 60 |
choices: ['disable', 'enable'] |
| 61 |
role: |
| 62 |
type: str |
| 63 |
description: |
| 64 |
- SAML role. |
| 65 |
- IDP - IDentiy Provider. |
| 66 |
- SP - Service Provider. |
| 67 |
choices: ['IDP', 'SP', 'FAB-SP'] |
| 68 |
server_address: |
| 69 |
aliases: ['server-address'] |
| 70 |
type: str |
| 71 |
description: Server address. |
| 72 |
service_providers: |
| 73 |
aliases: ['service-providers'] |
| 74 |
type: list |
| 75 |
elements: dict |
| 76 |
description: Service providers. |
| 77 |
suboptions: |
| 78 |
idp_entity_id: |
| 79 |
aliases: ['idp-entity-id'] |
| 80 |
type: str |
| 81 |
description: IDP Entity ID. |
| 82 |
idp_single_logout_url: |
| 83 |
aliases: ['idp-single-logout-url'] |
| 84 |
type: str |
| 85 |
description: IDP single logout url. |
| 86 |
idp_single_sign_on_url: |
| 87 |
aliases: ['idp-single-sign-on-url'] |
| 88 |
type: str |
| 89 |
description: IDP single sign-on URL. |
| 90 |
name: |
| 91 |
type: str |
| 92 |
description: Name. |
| 93 |
prefix: |
| 94 |
type: str |
| 95 |
description: Prefix. |
| 96 |
sp_cert: |
| 97 |
aliases: ['sp-cert'] |
| 98 |
type: str |
| 99 |
description: SP certificate name. |
| 100 |
sp_entity_id: |
| 101 |
aliases: ['sp-entity-id'] |
| 102 |
type: str |
| 103 |
description: SP Entity ID. |
| 104 |
sp_single_logout_url: |
| 105 |
aliases: ['sp-single-logout-url'] |
| 106 |
type: str |
| 107 |
description: SP single logout URL. |
| 108 |
sp_single_sign_on_url: |
| 109 |
aliases: ['sp-single-sign-on-url'] |
| 110 |
type: str |
| 111 |
description: SP single sign-on URL. |
| 112 |
sp_adom: |
| 113 |
aliases: ['sp-adom'] |
| 114 |
type: str |
| 115 |
description: SP adom name. |
| 116 |
sp_profile: |
| 117 |
aliases: ['sp-profile'] |
| 118 |
type: str |
| 119 |
description: SP profile name. |
| 120 |
sls_url: |
| 121 |
aliases: ['sls-url'] |
| 122 |
type: str |
| 123 |
description: SP SLS |
| 124 |
status: |
| 125 |
type: str |
| 126 |
description: |
| 127 |
- Enable/disable SAML authentication |
| 128 |
- disable - Disable SAML authentication. |
| 129 |
- enable - Enabld SAML authentication. |
| 130 |
choices: ['disable', 'enable'] |
| 131 |
default_profile: |
| 132 |
aliases: ['default-profile'] |
| 133 |
type: str |
| 134 |
description: Default Profile Name. |
| 135 |
fabric_idp: |
| 136 |
aliases: ['fabric-idp'] |
| 137 |
type: list |
| 138 |
elements: dict |
| 139 |
description: Fabric idp. |
| 140 |
suboptions: |
| 141 |
dev_id: |
| 142 |
aliases: ['dev-id'] |
| 143 |
type: str |
| 144 |
description: IDP Device ID. |
| 145 |
idp_cert: |
| 146 |
aliases: ['idp-cert'] |
| 147 |
type: str |
| 148 |
description: IDP Certificate name. |
| 149 |
idp_entity_id: |
| 150 |
aliases: ['idp-entity-id'] |
| 151 |
type: str |
| 152 |
description: IDP entity ID. |
| 153 |
idp_single_logout_url: |
| 154 |
aliases: ['idp-single-logout-url'] |
| 155 |
type: str |
| 156 |
description: IDP single logout url. |
| 157 |
idp_single_sign_on_url: |
| 158 |
aliases: ['idp-single-sign-on-url'] |
| 159 |
type: str |
| 160 |
description: IDP single sign-on URL. |
| 161 |
idp_status: |
| 162 |
aliases: ['idp-status'] |
| 163 |
type: str |
| 164 |
description: |
| 165 |
- Enable/disable SAML authentication |
| 166 |
- disable - Disable SAML authentication. |
| 167 |
- enable - Enabld SAML authentication. |
| 168 |
choices: ['disable', 'enable'] |
| 169 |
forticloud_sso: |
| 170 |
aliases: ['forticloud-sso'] |
| 171 |
type: str |
| 172 |
description: |
| 173 |
- Enable/disable FortiCloud SSO |
| 174 |
- disable - Disable Forticloud SSO. |
| 175 |
- enable - Enabld Forticloud SSO. |
| 176 |
choices: ['disable', 'enable'] |
| 177 |
user_auto_create: |
| 178 |
aliases: ['user-auto-create'] |
| 179 |
type: str |
| 180 |
description: |
| 181 |
- Enable/disable user auto creation |
| 182 |
- disable - Disable auto create user. |
| 183 |
- enable - Enable auto create user. |
| 184 |
choices: ['disable', 'enable'] |
| 185 |
auth_request_signed: |
| 186 |
aliases: ['auth-request-signed'] |
| 187 |
type: str |
| 188 |
description: |
| 189 |
- Enable/Disable auth request signed. |
| 190 |
- disable - Disable setting. |
| 191 |
- enable - Enable setting. |
| 192 |
choices: ['disable', 'enable'] |
| 193 |
want_assertions_signed: |
| 194 |
aliases: ['want-assertions-signed'] |
| 195 |
type: str |
| 196 |
description: |
| 197 |
- Enable/Disable want assertions signed. |
| 198 |
- disable - Disable setting. |
| 199 |
- enable - Enable setting. |
| 200 |
choices: ['disable', 'enable'] |
| 201 |
logout_request_signed: |
| 202 |
aliases: ['logout-request-signed'] |
| 203 |
type: str |
| 204 |
description: |
| 205 |
- Enable/Disable logout request signed. |
| 206 |
- disable - Disable setting. |
| 207 |
- enable - Enable setting. |
| 208 |
choices: ['disable', 'enable'] |
| 209 |
logout_response_signed: |
| 210 |
aliases: ['logout-response-signed'] |
| 211 |
type: str |
| 212 |
description: |
| 213 |
- Enable/Disable logout response signed. |
| 214 |
- disable - Disable setting. |
| 215 |
- enable - Enable setting. |
| 216 |
choices: ['disable', 'enable'] |
| 217 |
''' |
| 218 |
|
| 219 |
EXAMPLES = ''' |
| 220 |
- name: Example playbook (generated based on argument schema) |
| 221 |
hosts: fortimanagers |
| 222 |
connection: httpapi |
| 223 |
gather_facts: false |
| 224 |
tasks: |
| 225 |
- name: Global settings for SAML authentication. |
| 226 |
fortinet.fortimanager.fmgr_system_saml: |
| 227 |
# workspace_locking_adom: <global or your adom name> |
| 228 |
system_saml: |
| 229 |
# acs_url: <string> |
| 230 |
# cert: <string> |
| 231 |
# entity_id: <string> |
| 232 |
# idp_cert: <string> |
| 233 |
# idp_entity_id: <string> |
| 234 |
# idp_single_logout_url: <string> |
| 235 |
# idp_single_sign_on_url: <string> |
| 236 |
# login_auto_redirect: <value in [disable, enable]> |
| 237 |
# role: <value in [IDP, SP, FAB-SP]> |
| 238 |
# server_address: <string> |
| 239 |
# service_providers: |
| 240 |
# - idp_entity_id: <string> |
| 241 |
# idp_single_logout_url: <string> |
| 242 |
# idp_single_sign_on_url: <string> |
| 243 |
# name: <string> |
| 244 |
# prefix: <string> |
| 245 |
# sp_cert: <string> |
| 246 |
# sp_entity_id: <string> |
| 247 |
# sp_single_logout_url: <string> |
| 248 |
# sp_single_sign_on_url: <string> |
| 249 |
# sp_adom: <string> |
| 250 |
# sp_profile: <string> |
| 251 |
# sls_url: <string> |
| 252 |
# status: <value in [disable, enable]> |
| 253 |
# default_profile: <string> |
| 254 |
# fabric_idp: |
| 255 |
# - dev_id: <string> |
| 256 |
# idp_cert: <string> |
| 257 |
# idp_entity_id: <string> |
| 258 |
# idp_single_logout_url: <string> |
| 259 |
# idp_single_sign_on_url: <string> |
| 260 |
# idp_status: <value in [disable, enable]> |
| 261 |
# forticloud_sso: <value in [disable, enable]> |
| 262 |
# user_auto_create: <value in [disable, enable]> |
| 263 |
# auth_request_signed: <value in [disable, enable]> |
| 264 |
# want_assertions_signed: <value in [disable, enable]> |
| 265 |
# logout_request_signed: <value in [disable, enable]> |
| 266 |
# logout_response_signed: <value in [disable, enable]> |
| 267 |
''' |
| 268 |
|
| 269 |
RETURN = ''' |
| 270 |
meta: |
| 271 |
description: The result of the request. |
| 272 |
type: dict |
| 273 |
returned: always |
| 274 |
contains: |
| 275 |
request_url: |
| 276 |
description: The full url requested. |
| 277 |
returned: always |
| 278 |
type: str |
| 279 |
sample: /sys/login/user |
| 280 |
response_code: |
| 281 |
description: The status of api request. |
| 282 |
returned: always |
| 283 |
type: int |
| 284 |
sample: 0 |
| 285 |
response_data: |
| 286 |
description: The api response. |
| 287 |
type: list |
| 288 |
returned: always |
| 289 |
response_message: |
| 290 |
description: The descriptive message of the api response. |
| 291 |
type: str |
| 292 |
returned: always |
| 293 |
sample: OK. |
| 294 |
system_information: |
| 295 |
description: The information of the target system. |
| 296 |
type: dict |
| 297 |
returned: always |
| 298 |
rc: |
| 299 |
description: The status the request. |
| 300 |
type: int |
| 301 |
returned: always |
| 302 |
sample: 0 |
| 303 |
version_check_warning: |
| 304 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 305 |
type: list |
| 306 |
returned: complex |
| 307 |
''' |
| 308 |
from ansible.module_utils.basic import AnsibleModule |
| 309 |
from ansible.module_utils.connection import Connection |
| 310 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 311 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 312 |
|
| 313 |
|
| 314 |
def main(): |
| 315 |
urls_list = [ |
| 316 |
'/cli/global/system/saml' |
| 317 |
] |
| 318 |
module_arg_spec = { |
| 319 |
'system_saml': { |
| 320 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 321 |
'options': { |
| 322 |
'acs-url': {'type': 'str'}, |
| 323 |
'cert': {'type': 'str'}, |
| 324 |
'entity-id': {'type': 'str'}, |
| 325 |
'idp-cert': {'type': 'str'}, |
| 326 |
'idp-entity-id': {'type': 'str'}, |
| 327 |
'idp-single-logout-url': {'type': 'str'}, |
| 328 |
'idp-single-sign-on-url': {'type': 'str'}, |
| 329 |
'login-auto-redirect': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 330 |
'role': {'choices': ['IDP', 'SP', 'FAB-SP'], 'type': 'str'}, |
| 331 |
'server-address': {'type': 'str'}, |
| 332 |
'service-providers': { |
| 333 |
'type': 'list', |
| 334 |
'options': { |
| 335 |
'idp-entity-id': {'type': 'str'}, |
| 336 |
'idp-single-logout-url': {'type': 'str'}, |
| 337 |
'idp-single-sign-on-url': {'type': 'str'}, |
| 338 |
'name': {'type': 'str'}, |
| 339 |
'prefix': {'type': 'str'}, |
| 340 |
'sp-cert': {'type': 'str'}, |
| 341 |
'sp-entity-id': {'type': 'str'}, |
| 342 |
'sp-single-logout-url': {'type': 'str'}, |
| 343 |
'sp-single-sign-on-url': {'type': 'str'}, |
| 344 |
'sp-adom': {'v_range': [['7.2.0', '']], 'type': 'str'}, |
| 345 |
'sp-profile': {'v_range': [['7.2.0', '']], 'type': 'str'} |
| 346 |
}, |
| 347 |
'elements': 'dict' |
| 348 |
}, |
| 349 |
'sls-url': {'type': 'str'}, |
| 350 |
'status': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 351 |
'default-profile': {'v_range': [['6.2.5', '']], 'type': 'str'}, |
| 352 |
'fabric-idp': { |
| 353 |
'v_range': [['6.4.0', '']], |
| 354 |
'type': 'list', |
| 355 |
'options': { |
| 356 |
'dev-id': {'v_range': [['6.4.0', '']], 'type': 'str'}, |
| 357 |
'idp-cert': {'v_range': [['6.4.0', '']], 'type': 'str'}, |
| 358 |
'idp-entity-id': {'v_range': [['6.4.0', '']], 'type': 'str'}, |
| 359 |
'idp-single-logout-url': {'v_range': [['6.4.0', '']], 'type': 'str'}, |
| 360 |
'idp-single-sign-on-url': {'v_range': [['6.4.0', '']], 'type': 'str'}, |
| 361 |
'idp-status': {'v_range': [['6.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 362 |
}, |
| 363 |
'elements': 'dict' |
| 364 |
}, |
| 365 |
'forticloud-sso': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 366 |
'user-auto-create': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 367 |
'auth-request-signed': {'v_range': [['7.2.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 368 |
'want-assertions-signed': {'v_range': [['7.2.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 369 |
'logout-request-signed': {'v_range': [['7.4.8', '7.4.10'], ['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 370 |
'logout-response-signed': {'v_range': [['7.4.8', '7.4.10'], ['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 371 |
} |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
module_option_spec = get_module_arg_spec('partial crud') |
| 376 |
module_arg_spec.update(module_option_spec) |
| 377 |
check_galaxy_version(module_arg_spec) |
| 378 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_saml'), |
| 379 |
supports_check_mode=True) |
| 380 |
if not module._socket_path: |
| 381 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 382 |
connection = Connection(module._socket_path) |
| 383 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 384 |
None, 'data', module, connection) |
| 385 |
fmgr.process_partial_crud() |
| 386 |
module.exit_json(meta=module.params) |
| 387 |
|
| 388 |
|
| 389 |
if __name__ == '__main__': |
| 390 |
main() |