-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/oauth2: Config.Exchange goes into a runaway for loop hammering my OAuth2 server's /token enpoint #64607
Comments
Can you share a trimmed down version of your code that triggers this, so we can reproduce? Thanks |
This comment was marked as off-topic.
This comment was marked as off-topic.
made it public |
more clues: sequenceDiagram
ClientApp->>Server: POST /token
Server->>DownstreamServer: POST /token
DownstreamServer-->>Server: TokenResponse
Server->>Server: Mint New Tokens
Server-->>ClientApp: TokenResponse
Doing this makes the client app go into a runaway loop. I made the following changes and no runaway loop. My downstream server is now just returning a mocked reponse. sequenceDiagram
ClientApp->>Server: POST /token
Server->>MockDownstreamServer: POST /token
MockDownstreamServer-->>Server: TokenResponse
Server->>Server: Mint New Tokens
Server-->>ClientApp: TokenResponse
Let's assume I am doing bad stuff in my server. It shouldn't make a client react by hammering me. |
This doesn't look like a problem with go oauth libs, and inserting traces into the client doesn't show it making repeated requests. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
Confirmed I had a recursion problem on the server side. Thanks for the slap in the head @seankhliao :) |
Go version
go version go1.21.5 windows/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
I have this in a private repo that I can share.
I am using a slight modified version of this app
I am running a simple echo app where I exposed a REST POST /token endpoint.
My handler doesn't do much, other than make an outbound REST call to get some info and then returns.
During the Exchange the client hammers my /token endpoint over and over again. I have seen this on 2 separate machines and can produce it pretty reliably.
The problem seems to be deep in the http library where there is a for loop in play. So probably not the oauth2 code.
I can repo it is running the 2 apps separately and using vscode where I debug both.
I have tracked it down to the
r, err := ContextClient(ctx).Do(req.WithContext(ctx))
btw: Sometimes it works.
I will happily share my repo with someone that can go deeper on this than I have been able to investigate so far.
What did you expect to see?
a single call to the /token endpoint that either succeeds for fails.
What did you see instead?
My external services /token endpoint is getting hammered.
The text was updated successfully, but these errors were encountered: