Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,10 @@ func getTokenEndpoint(c config) (string, error) {
return "", errors.New("platform_issuer is not set, or is not a string")
}

oidcConfigURL := issuerURL + "/.well-known/openid-configuration"
oidcConfigURL, err := url.JoinPath(issuerURL, ".well-known/openid-configuration")
if err != nil {
return "", fmt.Errorf("invalid issuer URL %q: %w", issuerURL, err)
}

req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, oidcConfigURL, nil)
if err != nil {
Expand Down
10 changes: 7 additions & 3 deletions service/internal/auth/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log/slog"
"net/http"
"net/url"

"github.com/opentdf/platform/service/logger"
)
Expand All @@ -32,8 +33,11 @@ type OIDCConfiguration struct {
// DiscoverOPENIDConfiguration discovers the openid configuration for the issuer provided
func DiscoverOIDCConfiguration(ctx context.Context, issuer string, logger *logger.Logger) (*OIDCConfiguration, error) {
logger.DebugContext(ctx, "discovering openid configuration", slog.String("issuer", issuer))
url := fmt.Sprintf("%s%s", issuer, DiscoveryPath)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
discoveryURL, err := url.JoinPath(issuer, DiscoveryPath)
if err != nil {
return nil, fmt.Errorf("invalid issuer URL %q: %w", issuer, err)
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, discoveryURL, nil)
if err != nil {
return nil, err
}
Expand All @@ -44,7 +48,7 @@ func DiscoverOIDCConfiguration(ctx context.Context, issuer string, logger *logge
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to discover idp at %s: %s", url, resp.Status)
return nil, fmt.Errorf("failed to discover idp at %s: %s", discoveryURL, resp.Status)
}
defer resp.Body.Close()

Expand Down
Loading