Skip to content
Open
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions client/transport/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ type AuthServerMetadata struct {
ResponseTypesSupported []string `json:"response_types_supported"`
GrantTypesSupported []string `json:"grant_types_supported,omitempty"`
TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported,omitempty"`
Resource string `json:"resource,omitempty"`
}

// OAuthHandler handles OAuth authentication for HTTP requests
Expand Down Expand Up @@ -561,6 +562,11 @@ func (h *OAuthHandler) RegisterClient(ctx context.Context, clientName string) er
"scope": strings.Join(h.config.Scopes, " "),
}

// Add resource parameter if available (RFC 8707)
if metadata.Resource != "" {
regRequest["resource"] = metadata.Resource
}

// Add client_secret if this is a confidential client
if h.config.ClientSecret != "" {
regRequest["token_endpoint_auth_method"] = "client_secret_basic"
Expand Down Expand Up @@ -646,6 +652,10 @@ func (h *OAuthHandler) ProcessAuthorizationResponse(ctx context.Context, code, s
data.Set("client_id", h.config.ClientID)
data.Set("redirect_uri", h.config.RedirectURI)

if metadata.Resource != "" {
data.Set("resource", metadata.Resource)
}

if h.config.ClientSecret != "" {
data.Set("client_secret", h.config.ClientSecret)
}
Expand Down Expand Up @@ -725,6 +735,10 @@ func (h *OAuthHandler) GetAuthorizationURL(ctx context.Context, state, codeChall
params.Set("redirect_uri", h.config.RedirectURI)
params.Set("state", state)

if metadata.Resource != "" {
params.Set("resource", metadata.Resource)
}

if len(h.config.Scopes) > 0 {
params.Set("scope", strings.Join(h.config.Scopes, " "))
}
Expand Down