From c2cb0e9fe2c768065e1b9d5d7c337394e84ea4dd Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Thu, 2 May 2024 11:19:19 -0500 Subject: [PATCH] chore: testIDP to be usable as primary auth (#13132) Flags printed to console show as external or primary auth. Usage assumes only 1 static oidc_member for now --- scripts/testidp/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/testidp/main.go b/scripts/testidp/main.go index 9feae443ab..28aac286a7 100644 --- a/scripts/testidp/main.go +++ b/scripts/testidp/main.go @@ -84,7 +84,14 @@ func RunIDP() func(t *testing.T) { return func(t *testing.T) { idp := oidctest.NewFakeIDP(t, oidctest.WithServing(), - oidctest.WithStaticUserInfo(jwt.MapClaims{}), + oidctest.WithStaticUserInfo(jwt.MapClaims{ + // This is a static set of auth fields. Might be beneficial to make flags + // to allow different values here. This is only required for using the + // testIDP as primary auth. External auth does not ever fetch these fields. + "email": "oidc_member@coder.com", + "preferred_username": "oidc_member", + "email_verified": true, + }), oidctest.WithDefaultIDClaims(jwt.MapClaims{}), oidctest.WithDefaultExpire(*expiry), oidctest.WithStaticCredentials(*clientID, *clientSecret), @@ -133,6 +140,8 @@ func RunIDP() func(t *testing.T) { data, err := json.Marshal([]withClientSecret{cfg}) require.NoError(t, err) log.Printf(`--external-auth-providers='%s'`, string(data)) + log.Println("As primary OIDC auth") + log.Printf(`--oidc-issuer-url=%s --oidc-client-id=%s --oidc-client-secret=%s`, idp.IssuerURL().String(), *clientID, *clientSecret) log.Println("Press Ctrl+C to exit") c := make(chan os.Signal, 1)