Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: oidc check 200 (#14865)

p0nyab8e70c5a396
diff --git a/backend/api/v1/idp_service.go b/backend/api/v1/idp_service.go
index 2373440b9d..20e6d233d8 100644
--- a/backend/api/v1/idp_service.go
+++ b/backend/api/v1/idp_service.go
@@ -429,14 +429,14 @@ func convertIdentityProviderConfigFromStore(identityProviderConfig *storepb.Iden
}, nil
} else if v := identityProviderConfig.GetOidcConfig(); v != nil {
// Fetch openid configuration to get the auth endpoint and supported scopes.
- openidConfigration, err := oidc.GetOpenIDConfiguration(v.Issuer)
+ openidConfiguration, err := oidc.GetOpenIDConfiguration(v.Issuer)
if err != nil {
return nil, errors.Wrap(err, "failed to fetch openid configuration")
}
scopes := oidc.DefaultScopes
// Some IdPs like authning.cn doesn't expose "username" as part of standard claims.
// We need to check if it's supported by the IdP and add it to the scopes.
- if slices.Contains(openidConfigration.ScopesSupported, "username") {
+ if slices.Contains(openidConfiguration.ScopesSupported, "username") {
scopes = append(scopes, "username")
}
fieldMapping := v1pb.FieldMapping{
@@ -455,7 +455,7 @@ func convertIdentityProviderConfigFromStore(identityProviderConfig *storepb.Iden
SkipTlsVerify: v.SkipTlsVerify,
AuthStyle: v1pb.OAuth2AuthStyle(v.AuthStyle),
Scopes: scopes,
- AuthEndpoint: openidConfigration.AuthorizationEndpoint,
+ AuthEndpoint: openidConfiguration.AuthorizationEndpoint,
},
},
}, nil
diff --git a/backend/plugin/idp/oidc/oidc.go b/backend/plugin/idp/oidc/oidc.go
index 9e9857337f..269eb405e5 100644
--- a/backend/plugin/idp/oidc/oidc.go
+++ b/backend/plugin/idp/oidc/oidc.go
@@ -5,6 +5,7 @@ import (
"context"
"crypto/tls"
"encoding/json"
+ "io"
"log/slog"
"net/http"
"strings"
@@ -200,9 +201,18 @@ func GetOpenIDConfiguration(issuer string) (*OpenIDConfigurationResponse, error)
}
defer resp.Body.Close()
+ b, err := io.ReadAll(resp.Body)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to read body")
+ }
+
+ if resp.StatusCode != http.StatusOK {
+ return nil, errors.Errorf("received non-200 response code, code: %d, body: %s", resp.StatusCode, string(b))
+ }
+
var config OpenIDConfigurationResponse
- if err := json.NewDecoder(resp.Body).Decode(&config); err != nil {
- return nil, errors.Wrap(err, "unmarshal openid configuration")
+ if err := json.Unmarshal(b, &config); err != nil {
+ return nil, errors.Wrapf(err, "unmarshal openid configuration, body: %s", string(b))
}
openidConfigResponseCache[issuer] = &config