@@ -24,6 +24,7 @@ import (
24
24
"github.com/go-jose/go-jose/v3"
25
25
"github.com/golang-jwt/jwt/v4"
26
26
"github.com/google/uuid"
27
+ "github.com/prometheus/client_golang/prometheus"
27
28
"github.com/stretchr/testify/assert"
28
29
"github.com/stretchr/testify/require"
29
30
"golang.org/x/oauth2"
@@ -33,6 +34,7 @@ import (
33
34
"cdr.dev/slog/sloggers/slogtest"
34
35
"github.com/coder/coder/v2/coderd"
35
36
"github.com/coder/coder/v2/coderd/externalauth"
37
+ "github.com/coder/coder/v2/coderd/promoauth"
36
38
"github.com/coder/coder/v2/coderd/util/syncmap"
37
39
"github.com/coder/coder/v2/codersdk"
38
40
)
@@ -943,9 +945,10 @@ func (f *FakeIDP) ExternalAuthConfig(t testing.TB, id string, custom *ExternalAu
943
945
handle (email , rw , r )
944
946
}
945
947
}
948
+ instrumentF := promoauth .NewFactory (prometheus .NewRegistry ())
946
949
cfg := & externalauth.Config {
947
- OAuth2Config : f . OIDCConfig (t , nil ),
948
- ID : id ,
950
+ InstrumentedOAuth2Config : instrumentF . New ( f . clientID , f . OIDCConfig (t , nil ) ),
951
+ ID : id ,
949
952
// No defaults for these fields by omitting the type
950
953
Type : "" ,
951
954
DisplayIcon : f .WellknownConfig ().UserInfoURL ,
@@ -959,7 +962,10 @@ func (f *FakeIDP) ExternalAuthConfig(t testing.TB, id string, custom *ExternalAu
959
962
return cfg
960
963
}
961
964
962
- func (f * FakeIDP ) OAuthConfig (scopes ... string ) * oauth2.Config {
965
+ // OIDCConfig returns the OIDC config to use for Coderd.
966
+ func (f * FakeIDP ) OIDCConfig (t testing.TB , scopes []string , opts ... func (cfg * coderd.OIDCConfig )) * coderd.OIDCConfig {
967
+ t .Helper ()
968
+
963
969
if len (scopes ) == 0 {
964
970
scopes = []string {"openid" , "email" , "profile" }
965
971
}
@@ -976,15 +982,6 @@ func (f *FakeIDP) OAuthConfig(scopes ...string) *oauth2.Config {
976
982
RedirectURL : "https://redirect.com" ,
977
983
Scopes : scopes ,
978
984
}
979
- f .cfg = oauthCfg
980
- return oauthCfg
981
- }
982
-
983
- // OIDCConfig returns the OIDC config to use for Coderd.
984
- func (f * FakeIDP ) OIDCConfig (t testing.TB , scopes []string , opts ... func (cfg * coderd.OIDCConfig )) * coderd.OIDCConfig {
985
- t .Helper ()
986
-
987
- oauthCfg := f .OAuthConfig (scopes ... )
988
985
989
986
ctx := oidc .ClientContext (context .Background (), f .HTTPClient (nil ))
990
987
p , err := oidc .NewProvider (ctx , f .provider .Issuer )
@@ -1013,6 +1010,7 @@ func (f *FakeIDP) OIDCConfig(t testing.TB, scopes []string, opts ...func(cfg *co
1013
1010
opt (cfg )
1014
1011
}
1015
1012
1013
+ f .cfg = oauthCfg
1016
1014
return cfg
1017
1015
}
1018
1016
0 commit comments