peterpathirana
04/21/2023, 5:00 PMdata.coder_workspace.me.owner_oidc_access_token
We use the OIDC access token to interact w/ Gitlab API on first-time workspace creation and startup.
- So the workspace restarts (say by schedule) isn't affecting us.
- But since Gitlab OIDC tokens expire after 2hours (since Gitlab v15), it is possible that the a user logged in to Coder more than 2 hours ago and then creates a workspace after the Gitlab OIDC access token has expired. Then our attempts to use that token from agent-startup script fails.
Is it possible to do one of the following?
- Make the Coder auth expiration time window (CLI and UI) configurable?
- Then the admins can set it to their desired value (in our case the same as OIDC auth expiration length)matching
- If the OIDC auth has expired, trigger a re-login?kyle
04/21/2023, 5:03 PMpeterpathirana
04/21/2023, 5:04 PMkyle
04/21/2023, 5:07 PMkyle
04/21/2023, 5:08 PMpeterpathirana
04/21/2023, 5:09 PMpeterpathirana
04/21/2023, 5:09 PMkyle
04/21/2023, 5:11 PMpeterpathirana
04/21/2023, 5:12 PMpeterpathirana
04/21/2023, 5:14 PMpeterpathirana
04/21/2023, 5:15 PMpeterpathirana
04/21/2023, 5:20 PMkyle
04/21/2023, 6:04 PMaccess_token is expired, the expiry time is greater than zero, and the refresh_token isn't an empty string.
You can get this by doing the following query:
sql
SELECT * FROM user_links WHERE login_type = 'oidc';
And paste me the output (with the access tokens scrubbed away).peterpathirana
04/21/2023, 8:42 PMkyle
04/21/2023, 9:12 PMpeterpathirana
04/24/2023, 2:39 PMpeterpathirana
04/24/2023, 2:39 PMpeterpathirana
04/24/2023, 2:43 PM9488370d-0f91-4e42-a2e1-79ed53812dba | oidc | 216 | 7a47 | 34d7 | 2023-04-21 23:59:05.939328+00
My workspace container started this morning on schedule (before I ever logged into UI) w/ environment variable populated by data.coder_workspace.me.owner_oidc_access_token set to empty string.
If I log out from UI, and re-login and restart, that environment variable will have a value set and it will work against Gitlab API.peterpathirana
04/28/2023, 1:14 PMpeterpathirana
04/28/2023, 1:14 PM/var/log/syslog.1:Apr 27 08:22:56 d-coder-demo coder[2261413]: 2023-04-27 08:22:56.528 [INFO]#011(coderd)#011<./coderd/workspaceagents.go:194>#011(*API).postWorkspaceAgentStartup#011post workspace agent version#011{"request_id": "bc58cfd1-b004-44ae-9223-64152bd07b7f", "agent_id": "4dd315fa-2f21-4ca8-9706-2e36b068e878", "agent_version": "v0.20.1+ed9a3b9"}
/var/log/syslog.1:Apr 27 08:22:56 d-coder-demo coder[2261413]: 2023-04-27 08:22:56.768 [WARN]#011<./provisionerd/provisionerd.go:330>#011(*Server).acquireJob#011acquire job ...
/var/log/syslog.1:Apr 27 08:22:56 d-coder-demo coder[2261413]: "error": request job was invalidated: obtain OIDC access token: update user link: unauthorized: forbidden
/var/log/syslog.1:Apr 27 08:22:56 d-coder-demo coder[2261413]: #011storj.io/drpc/drpcwire.UnmarshalError:26
/var/log/syslog.1:Apr 27 08:22:56 d-coder-demo coder[2261413]: #011storj.io/drpc/drpcstream.(*Stream).HandlePacket:198
/var/log/syslog.1:Apr 27 08:22:56 d-coder-demo coder[2261413]: #011storj.io/drpc/drpcmanager.(*Manager).manageReader:216kyle
04/28/2023, 2:00 PMkyle
04/28/2023, 2:00 PMpeterpathirana
04/28/2023, 2:05 PMkyle
04/28/2023, 2:21 PMpeterpathirana
05/05/2023, 3:30 PMkyle
05/05/2023, 3:38 PMpeterpathirana
05/05/2023, 3:49 PMcurl -fsSL -H "Authorization: Bearer <oidc-token>" "https://<self-hosted-gitlab>/api/v4/user"
curl: (22) The requested URL returned error: 401peterpathirana
05/05/2023, 3:50 PMpeterpathirana
05/05/2023, 3:52 PM