Skip to content

Commit 07a1dbd

Browse files
fix(core): Set token endpoint manually if client creds provided in server sdk_config (#1780)
### Proposed Changes We run the server sdk in IPC mode so it does not reach out to well-known on instantiation because well-known isnt running yet. This means the token endpoint is never set. So if a service using the server sdk wanted to do a decrypt for example (a request that needs an auth token) they would get an error. This will manually set the token endpoint on instantiation using the issuer provided in the yaml config. ### Checklist - [ ] I have added or updated unit tests - [ ] I have added or updated integration tests (if appropriate) - [ ] I have added or updated documentation ### Testing Instructions
1 parent ec46a3a commit 07a1dbd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

service/pkg/server/start.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"syscall"
1111

1212
"github.com/opentdf/platform/sdk"
13+
"github.com/opentdf/platform/service/internal/auth"
1314
"github.com/opentdf/platform/service/internal/config"
1415
"github.com/opentdf/platform/service/internal/server"
1516
"github.com/opentdf/platform/service/logger"
@@ -164,6 +165,14 @@ func Start(f ...StartOptions) error {
164165
// If client credentials are provided, use them
165166
if cfg.SDKConfig.ClientID != "" && cfg.SDKConfig.ClientSecret != "" {
166167
sdkOptions = append(sdkOptions, sdk.WithClientCredentials(cfg.SDKConfig.ClientID, cfg.SDKConfig.ClientSecret, nil))
168+
169+
oidcconfig, err := auth.DiscoverOIDCConfiguration(ctx, cfg.Server.Auth.Issuer, logger)
170+
if err != nil {
171+
return fmt.Errorf("could not retrieve oidc configuration: %w", err)
172+
}
173+
174+
// provide token endpoint -- sdk cannot discover it since well-known service isnt running yet
175+
sdkOptions = append(sdkOptions, sdk.WithTokenEndpoint(oidcconfig.TokenEndpoint))
167176
}
168177

169178
// If the mode is all, use IPC for the SDK client

0 commit comments

Comments
 (0)