Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: x/oauth2: allow making raw post requests to server #72028

Open
janisz opened this issue Feb 28, 2025 · 1 comment
Open

proposal: x/oauth2: allow making raw post requests to server #72028

janisz opened this issue Feb 28, 2025 · 1 comment
Labels
LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool Proposal
Milestone

Comments

@janisz
Copy link

janisz commented Feb 28, 2025

Proposal Details

Allow making raw HTTP POST requests to the authz server

This PR adds functionality to make token-style HTTP requests to an arbitrary endpoint of the authz server, instead of just for retrieving tokens.

Use case: the main motivation was to support for OAuth2 token revocation per RFC7009. The token revocation endpoint requires client credentials, and implementing it outside of this library requires effectively re-implementing the auth style auto-sensing & caching.

This seemed the most convenient way of leveraging the library for token revocation. If desired, I can also make this less general to only support token revocation, but a.o.t. this would require figuring out the revocation URLs for all supported providers, which is outside my current time budget.

@gopherbot gopherbot added this to the Proposal milestone Feb 28, 2025
@seankhliao seankhliao changed the title proposal: golang.org/x/oauth2: Allow making raw HTTP POST requests to the authz server proposal: x/oauth2: allow making raw post requests to server Feb 28, 2025
@gabyhelp gabyhelp added the LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool label Feb 28, 2025
@seankhliao
Copy link
Member

imo this makes it too easy to misuse and leak credentials against an unintended server.

I think it should be:

type Endpoint struct{
    RevokeURL string
    // ... 
}

// Revoke a token using Endpoint.RevokeURL if available, otherwise return an error.
func (c *Config) Revoke(ctx context.Context, token *Token) error

People can add the revocation URLs for well known providers as they need them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool Proposal
Projects
None yet
Development

No branches or pull requests

4 participants