Merge pull request #8 from motaparthipavankumar/create-clients-enhancement
Client Creation Enhancementmain
commit
82fb60509b
|
@ -40,3 +40,4 @@
|
||||||
public_client: "{{ keycloak_client_public }}"
|
public_client: "{{ keycloak_client_public }}"
|
||||||
web_origins: "{{ keycloak_client_web_origins }}"
|
web_origins: "{{ keycloak_client_web_origins }}"
|
||||||
users: "{{ keycloak_client_users }}"
|
users: "{{ keycloak_client_users }}"
|
||||||
|
client_id: TestClient
|
||||||
|
|
|
@ -34,42 +34,36 @@
|
||||||
status_code: 201
|
status_code: 201
|
||||||
when: keycloak_realm_exists.status == 404
|
when: keycloak_realm_exists.status == 404
|
||||||
|
|
||||||
- name: Create user federation
|
- name: Create or update a Keycloak client
|
||||||
community.general.keycloak_user_federation:
|
|
||||||
auth_keycloak_url: "{{ keycloak_url }}/auth"
|
|
||||||
auth_realm: "{{ keycloak_auth_realm }}"
|
|
||||||
auth_username: "{{ keycloak_admin_user }}"
|
|
||||||
auth_password: "{{ keycloak_admin_password }}"
|
|
||||||
realm: "{{ item.realm }}"
|
|
||||||
name: "{{ item.name }}"
|
|
||||||
state: present
|
|
||||||
provider_id: "{{ item.provider_id }}"
|
|
||||||
provider_type: "{{ item.provider_type | default(org.keycloak.storage.UserStorageProvider) }}"
|
|
||||||
config: "{{ item.config }}"
|
|
||||||
mappers: "{{ item.mappers | default(omit) }}"
|
|
||||||
register: create_user_federation_result
|
|
||||||
loop: "{{ keycloak_user_federation | flatten }}"
|
|
||||||
when: keycloak_user_federation is defined
|
|
||||||
|
|
||||||
|
|
||||||
- name: Create Client
|
|
||||||
community.general.keycloak_client:
|
community.general.keycloak_client:
|
||||||
auth_client_id: "{{ keycloak_auth_client }}"
|
auth_client_id: "{{ keycloak_auth_client }}"
|
||||||
auth_keycloak_url: "{{ keycloak_url }}/auth"
|
auth_keycloak_url: "{{ keycloak_url }}/auth"
|
||||||
auth_realm: "{{ keycloak_auth_realm }}"
|
auth_realm: "{{ keycloak_auth_realm }}"
|
||||||
auth_username: "{{ keycloak_admin_user }}"
|
auth_username: "{{ keycloak_admin_user }}"
|
||||||
auth_password: "{{ keycloak_admin_password }}"
|
auth_password: "{{ keycloak_admin_password }}"
|
||||||
client_id: "{{ item.name }}"
|
|
||||||
realm: "{{ item.realm }}"
|
realm: "{{ item.realm }}"
|
||||||
default_roles: "{{ item.roles | default(omit) }}"
|
default_roles: "{{ item.roles | default(omit) }}"
|
||||||
|
client_id: "{{ item.client_id | default(omit) }}"
|
||||||
|
id: "{{ item.id | default(omit) }}"
|
||||||
|
name: "{{ item.name | default(omit) }}"
|
||||||
|
description: "{{ item.description | default(omit) }}"
|
||||||
root_url: "{{ item.root_url | default('') }}"
|
root_url: "{{ item.root_url | default('') }}"
|
||||||
redirect_uris: "{{ demo_app_redirect_uris | default([]) }}"
|
admin_url: "{{ item.admin_url | default('') }}"
|
||||||
public_client: "{{ item.public_client | default(False) }}"
|
base_url: "{{ item.base_url | default('') }}"
|
||||||
|
enabled: "{{ item.enabled | default(True) }}"
|
||||||
|
redirect_uris: "{{ item.redirect_uris | default(omit) }}"
|
||||||
web_origins: "{{ item.web_origins | default('+') }}"
|
web_origins: "{{ item.web_origins | default('+') }}"
|
||||||
|
bearer_only: "{{ item.bearer_only | default(omit) }}"
|
||||||
|
standard_flow_enabled: "{{ item.standard_flow_enabled | default(omit) }}"
|
||||||
|
implicit_flow_enabled: "{{ item.implicit_flow_enabled | default(omit) }}"
|
||||||
|
direct_access_grants_enabled: "{{ item.direct_access_grants_enabled | default(omit) }}"
|
||||||
|
service_accounts_enabled: "{{ item.service_accounts_enabled | default(omit) }}"
|
||||||
|
public_client: "{{ item.public_client | default(False) }}"
|
||||||
|
protocol: "{{ item.protocol | default(omit) }}"
|
||||||
state: present
|
state: present
|
||||||
register: create_client_result
|
register: create_client_result
|
||||||
loop: "{{ keycloak_clients | flatten }}"
|
loop: "{{ keycloak_clients | flatten }}"
|
||||||
when: item.name|length > 0
|
when: (item.name is defined and item.client_id is defined) or (item.name is defined and item.id is defined)
|
||||||
|
|
||||||
- name: Create client roles
|
- name: Create client roles
|
||||||
include_tasks: manage_client_roles.yml
|
include_tasks: manage_client_roles.yml
|
||||||
|
@ -83,3 +77,4 @@
|
||||||
loop: "{{ keycloak_clients | flatten }}"
|
loop: "{{ keycloak_clients | flatten }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: client
|
loop_var: client
|
||||||
|
when: "'users' in keycloak_clients"
|
|
@ -10,3 +10,4 @@
|
||||||
auth_password: "{{ keycloak_admin_password }}"
|
auth_password: "{{ keycloak_admin_password }}"
|
||||||
state: present
|
state: present
|
||||||
loop: "{{ client.roles | flatten }}"
|
loop: "{{ client.roles | flatten }}"
|
||||||
|
when: "'roles' in client"
|
||||||
|
|
Loading…
Reference in New Issue