Skip to content

Commit f83ee7e

Browse files
committed
docs: Document how to configure user-info-fetcher Keycloak user
1 parent 948e3a2 commit f83ee7e

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
lines changed
46 KB
Loading
147 KB
Loading
47.3 KB
Loading
80.2 KB
Loading

docs/modules/opa/pages/usage-guide/user-info-fetcher.adoc

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,69 @@ Fetch groups and extra credentials, but not roles.
7070

7171
NOTE: The OAuth2 Client in Keycloak must be given the `view-users` _Service Account Role_ for the realm that the users are in.
7272

73+
user-info-fetcher needs a service account at Keycloak with the permissions to read user objects.
74+
To create such as user you need to take the following steps:
75+
76+
*With your user realm selected* click on `Clients` at the left side and use the `Import client` button:
77+
78+
image::keycloak-user-info-fetcher/1.png[]
79+
80+
Create a file with the following JSON objects.
81+
Swap out `secret` with your desired password and potentially `redirectUris` and `webOrigins`.
82+
83+
[source,json]
84+
----
85+
{
86+
"clientId" : "user-info-fetcher",
87+
"surrogateAuthRequired" : false,
88+
"enabled" : true,
89+
"alwaysDisplayInConsole" : false,
90+
"clientAuthenticatorType" : "client-secret",
91+
"secret" : "XXX",
92+
"redirectUris" : [ "*" ],
93+
"webOrigins" : [ "*" ],
94+
"notBefore" : 0,
95+
"bearerOnly" : false,
96+
"serviceAccountsEnabled" : true,
97+
"publicClient" : false,
98+
"frontchannelLogout" : true,
99+
"protocol" : "openid-connect",
100+
"attributes" : {
101+
"oidc.ciba.grant.enabled" : "true",
102+
"oauth2.device.authorization.grant.enabled" : "false"
103+
},
104+
"authenticationFlowBindingOverrides" : { },
105+
"fullScopeAllowed" : true
106+
}
107+
----
108+
109+
Upload the file to the client importer and click on `Save`.
110+
111+
image::keycloak-user-info-fetcher/2.png[]
112+
113+
Afterwards you need to modify the created user `service-account-user-info-fetcher`.
114+
To achieve this open the user and click on the `Role mapping tab`:
115+
116+
image::keycloak-user-info-fetcher/3.png[]
117+
118+
Assign the role `view-users` as shown below.
119+
This is needed, so that the user is allowed to read other users information.
120+
121+
image::keycloak-user-info-fetcher/4.png[]
122+
123+
Afterwards you can store the user-info-fetcher credentials in Kubernetes with something like
124+
125+
[source,yaml]
126+
----
127+
apiVersion: v1
128+
kind: Secret
129+
metadata:
130+
name: user-info-fetcher-client-credentials
131+
stringData:
132+
clientId: user-info-fetcher
133+
clientSecret: XXX # replace with your chosen password
134+
----
135+
73136
[#backend-activedirectory]
74137
=== Active Directory
75138

@@ -153,6 +216,23 @@ An example of the returned structure:
153216

154217
NOTE: The exact formats of `id` and `groups` will vary depending on the xref:#backends[backend] in use. This example is using the xref:#backend-keycloak[] backend.
155218

219+
=== Debug request
220+
221+
To debug the user-info-fetcher you can `curl` it's API for a given user.
222+
To achieve this shell into the `user-info-fetcher` container and execute
223+
224+
[source,bash]
225+
----
226+
curl --header "Content-Type: application/json" -d '{"username":"my-user"}' http://127.0.0.1:9476/user
227+
----
228+
229+
You can also use `-d '{"id":"123456"}'` to query by the user ID.
230+
231+
=== Rego rule library
232+
233+
You could call the HTTP API from rego rules yourself.
234+
However, we provide a convenience rego rule library, which we ship with `OpaClusters` by default.
235+
156236
For example, the following rule allows access for users in the `/admin` group:
157237

158238
[source,rego]

0 commit comments

Comments
 (0)