mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
chore: instrument external oauth2 requests (#11519)
* chore: instrument external oauth2 requests External requests made by oauth2 configs are now instrumented into prometheus metrics.
This commit is contained in:
@ -2,10 +2,13 @@ package testutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/promoauth"
|
||||
)
|
||||
|
||||
type OAuth2Config struct {
|
||||
@ -13,6 +16,10 @@ type OAuth2Config struct {
|
||||
TokenSourceFunc OAuth2TokenSource
|
||||
}
|
||||
|
||||
func (*OAuth2Config) Do(_ context.Context, _ promoauth.Oauth2Source, req *http.Request) (*http.Response, error) {
|
||||
return http.DefaultClient.Do(req)
|
||||
}
|
||||
|
||||
func (*OAuth2Config) AuthCodeURL(state string, _ ...oauth2.AuthCodeOption) string {
|
||||
return "/?state=" + url.QueryEscape(state)
|
||||
}
|
||||
|
Reference in New Issue
Block a user