Created
August 26, 2017 13:11
-
-
Save glennswest/50ad4aeecc91e5d1b1b246d4075cde62 to your computer and use it in GitHub Desktop.
Create Keycloak Client Registration Using Ansible URL Module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
vars: | |
description: "auth users" | |
create_data: | |
clientId: "openshift" | |
name: "OpenShift" | |
description: "OpenShift Console Authentication" | |
enabled: true | |
protocol: "openid-connect" | |
clientAuthenticatorType: "client-secret" | |
directAccessGrantsEnabled: true | |
redirectUris: ["https://gsw1v11.southeastasia.cloudapp.azure.com:8443"] | |
webOrigins: [] | |
publicClient: false | |
consentRequired: false | |
frontchannelLogout: false | |
standardFlowEnabled: true | |
tasks: | |
- name: Login to SSO | |
uri: | |
url: https://login.52.160.91.126.nip.io/auth/realms/cloud/protocol/openid-connect/token | |
method: POST | |
body: "grant_type=pass&client_id=admin-cli&username=mgmtuser&password=mgmtpass" | |
return_content: yes | |
status_code: 200 | |
validate_certs: no | |
register: login | |
- debug: var=login.json.access_token | |
- name: Login to SSO | |
uri: | |
url: https://login.52.160.91.126.nip.io/auth/realms/cloud/clients-registrations/default | |
method: POST | |
headers: | |
"Authorization": "bearer {{login.json.access_token}}" | |
"Content-Type": "application/json" | |
body: "{{ create_data | to_json }}" | |
return_content: yes | |
status_code: 201 | |
validate_certs: no | |
register: create | |
- debug: var=create.json.secret | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"grant_type" should be "password" instead of "pass", at least with Keycloak 3.4.3
You may also add client_secret parameter for confidential clients