From 7f1e509e1207e1d9306fdb3c11032c3bcb3fe55e Mon Sep 17 00:00:00 2001 From: jamesread Date: Wed, 26 Nov 2025 23:28:29 +0000 Subject: [PATCH] chore: Little fixes for OAuth2 login --- service/internal/auth/otjwt/jwt.go | 1 + service/internal/auth/otjwt/jwt_test.go | 2 +- service/internal/auth/otoauth2/restapi_auth_oauth2_providers.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/service/internal/auth/otjwt/jwt.go b/service/internal/auth/otjwt/jwt.go index 998c15e..103224a 100644 --- a/service/internal/auth/otjwt/jwt.go +++ b/service/internal/auth/otjwt/jwt.go @@ -214,6 +214,7 @@ func parseJwt(cfg *config.Config, token string) *authTypes.AuthenticatedUser { user := &authTypes.AuthenticatedUser{ Username: lookupClaimValueOrDefault(claims, cfg.AuthJwtClaimUsername, ""), UsergroupLine: parseGroupClaim(cfg.AuthJwtClaimUserGroup, claims), + Provider: "jwt", } return user diff --git a/service/internal/auth/otjwt/jwt_test.go b/service/internal/auth/otjwt/jwt_test.go index 718588b..d3f48a8 100644 --- a/service/internal/auth/otjwt/jwt_test.go +++ b/service/internal/auth/otjwt/jwt_test.go @@ -33,7 +33,7 @@ func generateRSAKeyPair(t *testing.T) (*rsa.PrivateKey, []byte) { pubPem := pem.EncodeToMemory( &pem.Block{ - Type: "RSA PUBLIC KEY", + Type: "PUBLIC KEY", Bytes: pkixPubKey, }, ) diff --git a/service/internal/auth/otoauth2/restapi_auth_oauth2_providers.go b/service/internal/auth/otoauth2/restapi_auth_oauth2_providers.go index 3cf6ad8..35f96ff 100644 --- a/service/internal/auth/otoauth2/restapi_auth_oauth2_providers.go +++ b/service/internal/auth/otoauth2/restapi_auth_oauth2_providers.go @@ -20,7 +20,7 @@ var oauth2ProviderDatabase = map[string]config.OAuth2Provider{ Title: "Google", Name: "google", Icon: "google", - UsernameField: "preferred_username", + UsernameField: "email", WhoamiUrl: "https://www.googleapis.com/oauth2/v3/userinfo", TokenUrl: endpoints.Google.TokenURL, AuthUrl: endpoints.Google.AuthURL,