You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/authentication/proc-creating-a-custom-transformer-to-provision-users-from-rhbk-to-the-software-catalog.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
To customize how {rhbk} users and groups are mapped to {product} entities, you can create a backend module that uses the `keycloakTransformerExtensionPoint` to provide custom user and group transformers for the Keycloak backend.
5
5
6
6
.Prerequisites
7
-
* You have xref:provisioning-users-from-rhbk-to-the-software-catalog[enabled provisioning users from {rhbk-brand-name} ({rhbk}) to the software catalog].
7
+
* You have xref:enabling-user-authentication-with-rhbk[enabled provisioning users from {rhbk-brand-name} ({rhbk}) to the software catalog].
8
8
9
9
.Procedure
10
10
. Create a new backend module with the `yarn new` command.
= Enabling authentication with {rhbk-brand-name} ({rhbk})
3
-
4
-
To authenticate users with {rhbk-brand-name} ({rhbk}), enable the OpenID Connect (OIDC) authentication provider in {product}.
1
+
[id="enabling-user-authentication-with-rhbk"]
2
+
= Enabling user authentication with {rhbk-brand-name} ({rhbk})
5
3
4
+
To authenticate users with {rhbk-brand-name} ({rhbk}), enable and configure the OpenID Connect (OIDC) authentication provider in {product} and provision the users and groups from {rhbk} to the {product-short} software catalog.
6
5
7
6
.Prerequisites
8
7
* You link:{configuring-book-url}[added a custom {product-short} application configuration], and have sufficient permissions to modify it.
9
8
* You have sufficient permissions in {rhsso} to create and manage a realm.
9
+
Alternatively, you can ask your {rhbk} administrator to prepare the required {rhbk} App.
10
10
11
11
.Procedure
12
12
. To allow {product-short} to authenticate with {rhbk}, complete the steps in {rhbk}, to link:https://docs.redhat.com/en/documentation/red_hat_build_of_keycloak/26.0/html/getting_started_guide/getting-started-zip-#getting-started-zip-create-a-realm[create a realm and a user] and link:https://docs.redhat.com/en/documentation/red_hat_build_of_keycloak/26.0/html/getting_started_guide/getting-started-zip-#getting-started-zip-secure-the-first-application[secure the first application]:
@@ -25,11 +25,158 @@ Save the value for the next step:
25
25
26
26
.. To prepare for the verification steps, in the same realm, get the credential information for an existing user or link:https://docs.redhat.com/en/documentation/red_hat_build_of_keycloak/26.0/html-single/getting_started_guide/index#getting-started-zip-create-a-user[create a user]. Save the user credential information for the verification steps.
27
27
28
-
. To add your {rhsso} credentials to your {product-short}, add the following key/value pairs to link:{configuring-dynamic-plugins-book-url}#provisioning-your-custom-configuration[your {product-short} secrets]:
28
+
. To add your {rhsso} credentials to {product-short}, add the following key/value pairs to link:{configuring-dynamic-plugins-book-url}#provisioning-your-custom-configuration[your {product-short} secrets].
29
+
You can use these secrets in the {product-short} configuration files by using their respective environment variable name.
30
+
+
31
+
`AUTH_OIDC_CLIENT_ID`::
32
+
Enter the saved **Client ID**.
33
+
34
+
`AUTH_OIDC_CLIENT_SECRET`::
35
+
Enter the saved **Client Secret**.
36
+
37
+
`AUTH_OIDC_METADATA_URL`::
38
+
Enter the saved **{rhbk} realm base URL**.
39
+
40
+
. Enable the Keycloak organization plugin (`backstage-plugin-catalog-backend-module-keycloak-dynamic`).
41
+
The plugin is named after {rhbk} upstream project.
42
+
This plugin ingests {rhbk} users and groups to the {product-short} software catalog.
. To provision {rhbk} users and groups to the {product-short} software catalog, add the `catalog.providers.keycloakOrg` section to your custom {product-short} `{my-app-config-file}` configuration file:
53
+
+
54
+
--
55
+
[id=keycloakOrgProviderId]
56
+
.`{my-app-config-file}` fragment with mandatory `keycloakOrg` fields
57
+
[source,yaml]
58
+
----
59
+
catalog:
60
+
providers:
61
+
keycloakOrg:
62
+
default:
63
+
baseUrl: ${AUTH_OIDC_METADATA_URL}
64
+
clientId: ${AUTH_OIDC_CLIENT_ID}
65
+
clientSecret: ${AUTH_OIDC_CLIENT_SECRET}
66
+
----
67
+
68
+
`baseUrl`::
69
+
Your {rhbk} server URL, defined when xref:enabling-user-authentication-with-rhbk[enabling authentication with {rhbk}].
70
+
71
+
`clientId`::
72
+
Your {product-short} application client ID in {rhbk}, defined when xref:enabling-user-authentication-with-rhbk[enabling authentication with {rhbk}].
73
+
74
+
`clientSecret`::
75
+
Your {product-short} application client secret in {rhbk}, defined when xref:enabling-user-authentication-with-rhbk[enabling authentication with {rhbk}].
76
+
77
+
Optional: Consider adding the following optional fields:
78
+
79
+
`realm`::
80
+
Realm to synchronize.
81
+
Default value: `master`.
82
+
+
83
+
.`{my-app-config-file}` fragment with optional `realm` field
84
+
[source,yaml]
85
+
----
86
+
catalog:
87
+
providers:
88
+
keycloakOrg:
89
+
default:
90
+
realm: master
91
+
----
92
+
93
+
`loginRealm`::
94
+
Realm used to authenticate.
95
+
Default value: `master`.
29
96
+
30
-
`AUTH_OIDC_CLIENT_ID`:: Enter the saved **Client ID**.
31
-
`AUTH_OIDC_CLIENT_SECRET`:: Enter the saved **Client Secret**.
32
-
`AUTH_OIDC_METADATA_URL`:: Enter the saved **{rhbk} realm base URL**.
97
+
.`{my-app-config-file}` fragment with optional `loginRealm` field
98
+
[source,yaml]
99
+
----
100
+
catalog:
101
+
providers:
102
+
keycloakOrg:
103
+
default:
104
+
loginRealm: master
105
+
----
106
+
107
+
`userQuerySize`::
108
+
User number to query simultaneously.
109
+
Default value: `100`.
110
+
+
111
+
.`{my-app-config-file}` fragment with optional `userQuerySize` field
112
+
[source,yaml]
113
+
----
114
+
catalog:
115
+
providers:
116
+
keycloakOrg:
117
+
default:
118
+
userQuerySize: 100
119
+
----
120
+
121
+
`groupQuerySize`::
122
+
Group number to query simultaneously.
123
+
Default value: `100`.
124
+
+
125
+
.`{my-app-config-file}` fragment with optional `groupQuerySize` field
126
+
[source,yaml]
127
+
----
128
+
catalog:
129
+
providers:
130
+
keycloakOrg:
131
+
default:
132
+
groupQuerySize: 100
133
+
----
134
+
135
+
`schedule.frequency`::
136
+
To specify custom schedule frequency.
137
+
Supports cron, ISO duration, and "human duration" as used in code.
138
+
+
139
+
.`{my-app-config-file}` fragment with optional `schedule.frequency` field
140
+
[source,yaml]
141
+
----
142
+
catalog:
143
+
providers:
144
+
keycloakOrg:
145
+
default:
146
+
schedule:
147
+
frequency: { hours: 1 }
148
+
----
149
+
150
+
`schedule.timeout`::
151
+
To specify custom timeout.
152
+
Supports ISO duration and "human duration" as used in code.
153
+
+
154
+
.`{my-app-config-file}` fragment with optional `schedule.timeout` field
155
+
[source,yaml]
156
+
----
157
+
catalog:
158
+
providers:
159
+
keycloakOrg:
160
+
default:
161
+
schedule:
162
+
timeout: { minutes: 50 }
163
+
----
164
+
165
+
`schedule.initialDelay`::
166
+
To specify custom initial delay.
167
+
Supports ISO duration and "human duration" as used in code.
168
+
+
169
+
.`{my-app-config-file}` fragment with optional `schedule.initialDelay` field
170
+
[source,yaml]
171
+
----
172
+
catalog:
173
+
providers:
174
+
keycloakOrg:
175
+
default:
176
+
schedule:
177
+
initialDelay: { seconds: 15}
178
+
----
179
+
--
33
180
34
181
. To set up the {rhbk} authentication provider in your {product-short} custom configuration, edit your custom {product-short} ConfigMap such as `app-config-rhdh`, and add the following lines to the `{my-app-config-file}` content:
35
182
@@ -132,10 +279,19 @@ WARNING: In production mode, only configure one resolver to ensure users are sec
132
279
`resolver`::::
133
280
Enter the sign-in resolver name.
134
281
Available values:
135
-
* `oidcSubClaimMatchingKeycloakUserId`
136
-
* `emailLocalPartMatchingUserEntityName`
137
-
* `emailMatchingUserEntityProfileEmail`
138
-
* `preferredUsernameMatchingUserEntityName`
282
+
283
+
`oidcSubClaimMatchingKeycloakUserId`:::::
284
+
Matches the user with the immutable `sub` parameter from OIDC to the {RHBK} user ID.
285
+
Consider using this resolver for enhanced security.
286
+
287
+
`emailLocalPartMatchingUserEntityName`:::::
288
+
Matches the email local part with the user entity name.
289
+
290
+
`emailMatchingUserEntityProfileEmail`:::::
291
+
Matches the email with the user entity profile email.
292
+
293
+
`preferredUsernameMatchingUserEntityName`:::::
294
+
Matches the preferred username with the user entity name.
139
295
+
140
296
.`{my-app-config-file}` fragment with optional `resolvers` list
141
297
[source,yaml]
@@ -212,6 +368,17 @@ If multiple valid refresh tokens are issued due to frequent refresh token reques
212
368
====
213
369
214
370
.Verification
215
-
. Go to the {product-short} login page.
216
-
. Your {product-short} sign-in page displays *Sign in using OIDC* and the Guest user sign-in is disabled.
217
-
. Log in with OIDC by using the saved **Username** and **Password** values.
371
+
372
+
. To verify user and group provisioning, check the console logs.
373
+
+
374
+
.Successful synchronization example:
375
+
[source,json]
376
+
----
377
+
{"class":"KeycloakOrgEntityProvider","level":"info","message":"Read 3 Keycloak users and 2 Keycloak groups in 1.5 seconds. Committing...","plugin":"catalog","service":"backstage","taskId":"KeycloakOrgEntityProvider:default:refresh","taskInstanceId":"bf0467ff-8ac4-4702-911c-380270e44dea","timestamp":"2024-09-25 13:58:04"}
378
+
{"class":"KeycloakOrgEntityProvider","level":"info","message":"Committed 3 Keycloak users and 2 Keycloak groups in 0.0 seconds.","plugin":"catalog","service":"backstage","taskId":"KeycloakOrgEntityProvider:default:refresh","taskInstanceId":"bf0467ff-8ac4-4702-911c-380270e44dea","timestamp":"2024-09-25 13:58:04"}
379
+
----
380
+
381
+
. To verify {rhbk} user authentication:
382
+
.. Go to the {product-short} login page.
383
+
.. Your {product-short} sign-in page displays *Sign in using OIDC* and the Guest user sign-in is disabled.
384
+
.. Log in with OIDC by using the saved **Username** and **Password** values.
0 commit comments