| 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_user_oidc |
| 15 |
short_description: User oidc |
| 16 |
version_added: "2.12.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_oidc: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
auth_method: |
| 34 |
aliases: ['auth-method'] |
| 35 |
type: str |
| 36 |
description: Auth method. |
| 37 |
choices: ['client_secret_basic', 'client_secret_post', 'private_key_jwt'] |
| 38 |
auth_type: |
| 39 |
aliases: ['auth-type'] |
| 40 |
type: str |
| 41 |
description: Auth type. |
| 42 |
choices: ['client-secret', 'private-key'] |
| 43 |
authorization_url: |
| 44 |
aliases: ['authorization-url'] |
| 45 |
type: str |
| 46 |
description: Authorization url. |
| 47 |
client_id: |
| 48 |
aliases: ['client-id'] |
| 49 |
type: str |
| 50 |
description: Client id. |
| 51 |
client_secret: |
| 52 |
aliases: ['client-secret'] |
| 53 |
type: str |
| 54 |
description: Client secret. |
| 55 |
clock_tolerance: |
| 56 |
aliases: ['clock-tolerance'] |
| 57 |
type: int |
| 58 |
description: Clock tolerance. |
| 59 |
discovery_url: |
| 60 |
aliases: ['discovery-url'] |
| 61 |
type: str |
| 62 |
description: Discovery url. |
| 63 |
display_name: |
| 64 |
aliases: ['display-name'] |
| 65 |
type: str |
| 66 |
description: Display name. |
| 67 |
domain_hint: |
| 68 |
aliases: ['domain-hint'] |
| 69 |
type: str |
| 70 |
description: Domain hint. |
| 71 |
group_attr_name: |
| 72 |
aliases: ['group-attr-name'] |
| 73 |
type: str |
| 74 |
description: Group attr name. |
| 75 |
icon_url: |
| 76 |
aliases: ['icon-url'] |
| 77 |
type: str |
| 78 |
description: Icon url. |
| 79 |
issuer: |
| 80 |
type: str |
| 81 |
description: Issuer. |
| 82 |
jwks_uri: |
| 83 |
aliases: ['jwks-uri'] |
| 84 |
type: str |
| 85 |
description: Jwks uri. |
| 86 |
ldap_server: |
| 87 |
aliases: ['ldap-server'] |
| 88 |
type: list |
| 89 |
elements: str |
| 90 |
description: Ldap server. |
| 91 |
name: |
| 92 |
type: str |
| 93 |
description: Name. |
| 94 |
required: true |
| 95 |
private_key: |
| 96 |
aliases: ['private-key'] |
| 97 |
type: list |
| 98 |
elements: str |
| 99 |
description: Private key. |
| 100 |
token_url: |
| 101 |
aliases: ['token-url'] |
| 102 |
type: str |
| 103 |
description: Token url. |
| 104 |
type: |
| 105 |
type: str |
| 106 |
description: Type. |
| 107 |
choices: ['discovery', 'manual'] |
| 108 |
user_attr_name: |
| 109 |
aliases: ['user-attr-name'] |
| 110 |
type: str |
| 111 |
description: User attr name. |
| 112 |
choices: ['email', 'sub', 'preferred_username'] |
| 113 |
user_regex: |
| 114 |
aliases: ['user-regex'] |
| 115 |
type: str |
| 116 |
description: User regex. |
| 117 |
verify_cert: |
| 118 |
aliases: ['verify-cert'] |
| 119 |
type: str |
| 120 |
description: Verify cert. |
| 121 |
choices: ['disable', 'enable'] |
| 122 |
verify_issuer: |
| 123 |
aliases: ['verify-issuer'] |
| 124 |
type: str |
| 125 |
description: Verify issuer. |
| 126 |
choices: ['disable', 'enable'] |
| 127 |
''' |
| 128 |
|
| 129 |
EXAMPLES = ''' |
| 130 |
- name: Example playbook (generated based on argument schema) |
| 131 |
hosts: fortimanagers |
| 132 |
connection: httpapi |
| 133 |
gather_facts: false |
| 134 |
tasks: |
| 135 |
- name: User oidc |
| 136 |
fortinet.fortimanager.fmgr_user_oidc: |
| 137 |
# workspace_locking_adom: <global or your adom name> |
| 138 |
adom: <your own value> |
| 139 |
state: present # <value in [present, absent]> |
| 140 |
user_oidc: |
| 141 |
name: "your value" # Required variable, string |
| 142 |
# auth_method: <value in [client_secret_basic, client_secret_post, private_key_jwt]> |
| 143 |
# auth_type: <value in [client-secret, private-key]> |
| 144 |
# authorization_url: <string> |
| 145 |
# client_id: <string> |
| 146 |
# client_secret: <string> |
| 147 |
# clock_tolerance: <integer> |
| 148 |
# discovery_url: <string> |
| 149 |
# display_name: <string> |
| 150 |
# domain_hint: <string> |
| 151 |
# group_attr_name: <string> |
| 152 |
# icon_url: <string> |
| 153 |
# issuer: <string> |
| 154 |
# jwks_uri: <string> |
| 155 |
# ldap_server: <list or string> |
| 156 |
# private_key: <list or string> |
| 157 |
# token_url: <string> |
| 158 |
# type: <value in [discovery, manual]> |
| 159 |
# user_attr_name: <value in [email, sub, preferred_username]> |
| 160 |
# user_regex: <string> |
| 161 |
# verify_cert: <value in [disable, enable]> |
| 162 |
# verify_issuer: <value in [disable, enable]> |
| 163 |
''' |
| 164 |
|
| 165 |
RETURN = ''' |
| 166 |
meta: |
| 167 |
description: The result of the request. |
| 168 |
type: dict |
| 169 |
returned: always |
| 170 |
contains: |
| 171 |
request_url: |
| 172 |
description: The full url requested. |
| 173 |
returned: always |
| 174 |
type: str |
| 175 |
sample: /sys/login/user |
| 176 |
response_code: |
| 177 |
description: The status of api request. |
| 178 |
returned: always |
| 179 |
type: int |
| 180 |
sample: 0 |
| 181 |
response_data: |
| 182 |
description: The api response. |
| 183 |
type: list |
| 184 |
returned: always |
| 185 |
response_message: |
| 186 |
description: The descriptive message of the api response. |
| 187 |
type: str |
| 188 |
returned: always |
| 189 |
sample: OK. |
| 190 |
system_information: |
| 191 |
description: The information of the target system. |
| 192 |
type: dict |
| 193 |
returned: always |
| 194 |
rc: |
| 195 |
description: The status the request. |
| 196 |
type: int |
| 197 |
returned: always |
| 198 |
sample: 0 |
| 199 |
version_check_warning: |
| 200 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 201 |
type: list |
| 202 |
returned: complex |
| 203 |
''' |
| 204 |
from ansible.module_utils.basic import AnsibleModule |
| 205 |
from ansible.module_utils.connection import Connection |
| 206 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 207 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 208 |
|
| 209 |
|
| 210 |
def main(): |
| 211 |
urls_list = [ |
| 212 |
'/pm/config/adom/{adom}/obj/user/oidc', |
| 213 |
'/pm/config/global/obj/user/oidc' |
| 214 |
] |
| 215 |
module_arg_spec = { |
| 216 |
'adom': {'required': True, 'type': 'str'}, |
| 217 |
'revision_note': {'type': 'str'}, |
| 218 |
'user_oidc': { |
| 219 |
'type': 'dict', 'v_range': [['7.6.4', '']], |
| 220 |
'options': { |
| 221 |
'auth-method': {'v_range': [['7.6.4', '']], 'choices': ['client_secret_basic', 'client_secret_post', 'private_key_jwt'], 'type': 'str'}, |
| 222 |
'auth-type': {'v_range': [['7.6.4', '']], 'choices': ['client-secret', 'private-key'], 'type': 'str'}, |
| 223 |
'authorization-url': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 224 |
'client-id': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 225 |
'client-secret': {'v_range': [['7.6.4', '']], 'no_log': True, 'type': 'str'}, |
| 226 |
'clock-tolerance': {'v_range': [['7.6.4', '']], 'type': 'int'}, |
| 227 |
'discovery-url': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 228 |
'display-name': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 229 |
'domain-hint': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 230 |
'group-attr-name': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 231 |
'icon-url': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 232 |
'issuer': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 233 |
'jwks-uri': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 234 |
'ldap-server': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 235 |
'name': {'v_range': [['7.6.4', '']], 'required': True, 'type': 'str'}, |
| 236 |
'private-key': {'v_range': [['7.6.4', '']], 'no_log': True, 'type': 'list', 'elements': 'str'}, |
| 237 |
'token-url': {'v_range': [['7.6.4', '']], 'no_log': True, 'type': 'str'}, |
| 238 |
'type': {'v_range': [['7.6.4', '']], 'choices': ['discovery', 'manual'], 'type': 'str'}, |
| 239 |
'user-attr-name': {'v_range': [['7.6.4', '']], 'choices': ['email', 'sub', 'preferred_username'], 'type': 'str'}, |
| 240 |
'user-regex': {'v_range': [['7.6.4', '']], 'type': 'str'}, |
| 241 |
'verify-cert': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 242 |
'verify-issuer': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 243 |
} |
| 244 |
} |
| 245 |
} |
| 246 |
|
| 247 |
module_option_spec = get_module_arg_spec('full crud') |
| 248 |
module_arg_spec.update(module_option_spec) |
| 249 |
check_galaxy_version(module_arg_spec) |
| 250 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_oidc'), |
| 251 |
supports_check_mode=True) |
| 252 |
if not module._socket_path: |
| 253 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 254 |
connection = Connection(module._socket_path) |
| 255 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 256 |
'name', 'data', module, connection) |
| 257 |
fmgr.process_crud() |
| 258 |
module.exit_json(meta=module.params) |
| 259 |
|
| 260 |
|
| 261 |
if __name__ == '__main__': |
| 262 |
main() |