mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: instrument github oauth2 limits (#11532)
* chore: instrument github oauth2 limits Rate limit information for github oauth2 providers instrumented in prometheus
This commit is contained in:
@ -85,6 +85,8 @@ type FakeIDP struct {
|
||||
// to test something like PKI auth vs a client_secret.
|
||||
hookAuthenticateClient func(t testing.TB, req *http.Request) (url.Values, error)
|
||||
serve bool
|
||||
// optional middlewares
|
||||
middlewares chi.Middlewares
|
||||
}
|
||||
|
||||
func StatusError(code int, err error) error {
|
||||
@ -115,6 +117,12 @@ func WithAuthorizedRedirectURL(hook func(redirectURL string) error) func(*FakeID
|
||||
}
|
||||
}
|
||||
|
||||
func WithMiddlewares(mws ...func(http.Handler) http.Handler) func(*FakeIDP) {
|
||||
return func(f *FakeIDP) {
|
||||
f.middlewares = append(f.middlewares, mws...)
|
||||
}
|
||||
}
|
||||
|
||||
// WithRefresh is called when a refresh token is used. The email is
|
||||
// the email of the user that is being refreshed assuming the claims are correct.
|
||||
func WithRefresh(hook func(email string) error) func(*FakeIDP) {
|
||||
@ -570,6 +578,7 @@ func (f *FakeIDP) httpHandler(t testing.TB) http.Handler {
|
||||
t.Helper()
|
||||
|
||||
mux := chi.NewMux()
|
||||
mux.Use(f.middlewares...)
|
||||
// This endpoint is required to initialize the OIDC provider.
|
||||
// It is used to get the OIDC configuration.
|
||||
mux.Get("/.well-known/openid-configuration", func(rw http.ResponseWriter, r *http.Request) {
|
||||
|
Reference in New Issue
Block a user