Skip to content

Commit 19e4a86

Browse files
authored
docs: add guidelines for debugging group sync (#11296)
* docs: add guidelines for debugging group sync * fmt
1 parent e2e56d7 commit 19e4a86

File tree

1 file changed

+59
-25
lines changed

1 file changed

+59
-25
lines changed

docs/admin/auth.md

+59-25
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,65 @@ Users who are not in a matching group will see the following error:
326326

327327
![Unauthorized group error](../images/admin/group-allowlist.png)
328328

329-
### Troubleshooting
329+
## Role sync (enterprise)
330+
331+
If your OpenID Connect provider supports roles claims, you can configure Coder
332+
to synchronize roles in your auth provider to deployment-wide roles within
333+
Coder.
334+
335+
Set the following in your Coder server [configuration](./configure.md).
336+
337+
```env
338+
# Depending on your identity provider configuration, you may need to explicitly request a "roles" scope
339+
CODER_OIDC_SCOPES=openid,profile,email,roles
340+
341+
# The following fields are required for role sync:
342+
CODER_OIDC_USER_ROLE_FIELD=roles
343+
CODER_OIDC_USER_ROLE_MAPPING='{"TemplateAuthor":["template-admin","user-admin"]}'
344+
```
345+
346+
> One role from your identity provider can be mapped to many roles in Coder
347+
> (e.g. the example above maps to 2 roles in Coder.)
348+
349+
## Troubleshooting group/role sync
350+
351+
Some common issues when enabling group/role sync.
352+
353+
### General guidelines
354+
355+
If you are running into issues with group/role sync, is best to view your Coder
356+
server logs and enable
357+
[verbose mode](https://coder.com/docs/v2/v2.5.1/cli#-v---verbose). To reduce
358+
noise, you can filter for only logs related to group/role sync:
359+
360+
```sh
361+
CODER_VERBOSE=true
362+
CODER_LOG_FILTER=".*userauth.*|.*groups returned.*"
363+
```
364+
365+
Be sure to restart the server after changing these configuration values. Then,
366+
attempt to log in, preferably with a user who has the `Owner` role.
367+
368+
The logs for a successful group sync look like this (human-readable):
330369

331-
Some common issues when enabling group sync.
370+
```sh
371+
[debu] coderd.userauth: got oidc claims request_id=49e86507-6842-4b0b-94d4-f245e62e49f3 source=id_token claim_fields="[aio aud email exp groups iat idp iss name nbf oid preferred_username rh sub tid uti ver]" blank=[]
332372
333-
#### User not being assigned / Group does not exist
373+
[debu] coderd.userauth: got oidc claims request_id=49e86507-6842-4b0b-94d4-f245e62e49f3 source=userinfo claim_fields="[email family_name given_name name picture sub]" blank=[]
374+
375+
[debu] coderd.userauth: got oidc claims request_id=49e86507-6842-4b0b-94d4-f245e62e49f3 source=merged claim_fields="[aio aud email exp family_name given_name groups iat idp iss name nbf oid picture preferred_username rh sub tid uti ver]" blank=[]
376+
377+
[debu] coderd: groups returned in oidc claims request_id=49e86507-6842-4b0b-94d4-f245e62e49f3 email=ben@coder.com username=ben len=3 groups="[c8048e91-f5c3-47e5-9693-834de84034ad 66ad2cc3-a42f-4574-a281-40d1922e5b65 70b48175-107b-4ad8-b405-4d888a1c466f]"
378+
```
379+
380+
To view the full claim, the Owner role can visit this endpoint on their Coder
381+
deployment after logging in:
382+
383+
```sh
384+
https://[coder.example.com]/api/v2/debug/[username]/debug-link
385+
```
386+
387+
### User not being assigned / Group does not exist
334388

335389
If you want Coder to create groups that do not exist, you can set the following
336390
environment variable. If you enable this, your OIDC provider might be sending
@@ -364,7 +418,7 @@ CODER_OIDC_GROUP_REGEX_FILTER="^my-group-.*$"
364418
--oidc-group-regex-filter="^my-group-.*$"
365419
```
366420

367-
#### Invalid Scope
421+
### Invalid Scope
368422

369423
If you see an error like the following, you may have an invalid scope.
370424

@@ -380,7 +434,7 @@ configuring the name of this scope.
380434
The solution is to update the value of `CODER_OIDC_SCOPES` to the correct value
381435
for the identity provider.
382436

383-
#### No `group` claim in the `got oidc claims` log
437+
### No `group` claim in the `got oidc claims` log
384438

385439
Steps to troubleshoot.
386440

@@ -396,26 +450,6 @@ Steps to troubleshoot.
396450
- [Azure AD limit is 200, and omits groups if exceeded.](https://learn.microsoft.com/en-us/azure/active-directory/hybrid/connect/how-to-connect-fed-group-claims#options-for-applications-to-consume-group-information)
397451
- [Okta limit is 100, and returns an error if exceeded.](https://developer.okta.com/docs/reference/api/oidc/#scope-dependent-claims-not-always-returned)
398452

399-
## Role sync (enterprise)
400-
401-
If your OpenID Connect provider supports roles claims, you can configure Coder
402-
to synchronize roles in your auth provider to deployment-wide roles within
403-
Coder.
404-
405-
Set the following in your Coder server [configuration](./configure.md).
406-
407-
```env
408-
# Depending on your identity provider configuration, you may need to explicitly request a "roles" scope
409-
CODER_OIDC_SCOPES=openid,profile,email,roles
410-
411-
# The following fields are required for role sync:
412-
CODER_OIDC_USER_ROLE_FIELD=roles
413-
CODER_OIDC_USER_ROLE_MAPPING='{"TemplateAuthor":["template-admin","user-admin"]}'
414-
```
415-
416-
> One role from your identity provider can be mapped to many roles in Coder
417-
> (e.g. the example above maps to 2 roles in Coder.)
418-
419453
## Provider-Specific Guides
420454

421455
Below are some details specific to individual OIDC providers.

0 commit comments

Comments
 (0)