fix: nil ptr deref when removing OIDC from deployment and accessing old users (#17501)

If OIDC is removed from a deployment, trying to create a workspace for a previous user
on OIDC would panic.
This commit is contained in:
Steven Masley
2025-04-23 08:45:26 -05:00
committed by GitHub
parent c106aee0d6
commit 71dbd0c888
2 changed files with 51 additions and 1 deletions

View File

@ -515,7 +515,9 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
}
var workspaceOwnerOIDCAccessToken string
if s.OIDCConfig != nil {
// The check `s.OIDCConfig != nil` is not as strict, since it can be an interface
// pointing to a typed nil.
if !reflect.ValueOf(s.OIDCConfig).IsNil() {
workspaceOwnerOIDCAccessToken, err = obtainOIDCAccessToken(ctx, s.Database, s.OIDCConfig, owner.ID)
if err != nil {
return nil, failJob(fmt.Sprintf("obtain OIDC access token: %s", err))