Compare commits

..

1 Commits

Author SHA1 Message Date
GitHub
ef91a42489 docs: regenerate readme sponsors list 2026-03-30 16:31:19 +00:00
4 changed files with 5 additions and 18 deletions

View File

@@ -206,17 +206,11 @@ func (controller *OAuthController) oauthCallbackHandler(c *gin.Context) {
return return
} }
if service.ID() != req.Provider {
tlog.App.Error().Msgf("OAuth service ID mismatch: expected %s, got %s", service.ID(), req.Provider)
c.Redirect(http.StatusTemporaryRedirect, fmt.Sprintf("%s/error", controller.config.AppURL))
return
}
sessionCookie := repository.Session{ sessionCookie := repository.Session{
Username: username, Username: username,
Name: name, Name: name,
Email: user.Email, Email: user.Email,
Provider: service.ID(), Provider: req.Provider,
OAuthGroups: utils.CoalesceToString(user.Groups), OAuthGroups: utils.CoalesceToString(user.Groups),
OAuthName: service.Name(), OAuthName: service.Name(),
OAuthSub: user.Sub, OAuthSub: user.Sub,

View File

@@ -10,7 +10,6 @@ import (
type OAuthServiceImpl interface { type OAuthServiceImpl interface {
Name() string Name() string
ID() string
NewRandom() string NewRandom() string
GetAuthURL(state string, verifier string) string GetAuthURL(state string, verifier string) string
GetToken(code string, verifier string) (*oauth2.Token, error) GetToken(code string, verifier string) (*oauth2.Token, error)
@@ -40,7 +39,7 @@ func (broker *OAuthBrokerService) Init() error {
broker.services[name] = presetFunc(cfg) broker.services[name] = presetFunc(cfg)
tlog.App.Debug().Str("service", name).Msg("Loaded OAuth service from preset") tlog.App.Debug().Str("service", name).Msg("Loaded OAuth service from preset")
} else { } else {
broker.services[name] = NewOAuthService(cfg, name) broker.services[name] = NewOAuthService(cfg)
tlog.App.Debug().Str("service", name).Msg("Loaded OAuth service from config") tlog.App.Debug().Str("service", name).Msg("Loaded OAuth service from config")
} }
} }

View File

@@ -11,7 +11,7 @@ func newGoogleOAuthService(config config.OAuthServiceConfig) *OAuthService {
config.AuthURL = endpoints.Google.AuthURL config.AuthURL = endpoints.Google.AuthURL
config.TokenURL = endpoints.Google.TokenURL config.TokenURL = endpoints.Google.TokenURL
config.UserinfoURL = "https://openidconnect.googleapis.com/v1/userinfo" config.UserinfoURL = "https://openidconnect.googleapis.com/v1/userinfo"
return NewOAuthService(config, "google") return NewOAuthService(config)
} }
func newGitHubOAuthService(config config.OAuthServiceConfig) *OAuthService { func newGitHubOAuthService(config config.OAuthServiceConfig) *OAuthService {
@@ -19,5 +19,5 @@ func newGitHubOAuthService(config config.OAuthServiceConfig) *OAuthService {
config.Scopes = scopes config.Scopes = scopes
config.AuthURL = endpoints.GitHub.AuthURL config.AuthURL = endpoints.GitHub.AuthURL
config.TokenURL = endpoints.GitHub.TokenURL config.TokenURL = endpoints.GitHub.TokenURL
return NewOAuthService(config, "github").WithUserinfoExtractor(githubExtractor) return NewOAuthService(config).WithUserinfoExtractor(githubExtractor)
} }

View File

@@ -17,10 +17,9 @@ type OAuthService struct {
config *oauth2.Config config *oauth2.Config
ctx context.Context ctx context.Context
userinfoExtractor UserinfoExtractor userinfoExtractor UserinfoExtractor
id string
} }
func NewOAuthService(config config.OAuthServiceConfig, id string) *OAuthService { func NewOAuthService(config config.OAuthServiceConfig) *OAuthService {
httpClient := &http.Client{ httpClient := &http.Client{
Timeout: 30 * time.Second, Timeout: 30 * time.Second,
Transport: &http.Transport{ Transport: &http.Transport{
@@ -46,7 +45,6 @@ func NewOAuthService(config config.OAuthServiceConfig, id string) *OAuthService
}, },
ctx: ctx, ctx: ctx,
userinfoExtractor: defaultExtractor, userinfoExtractor: defaultExtractor,
id: id,
} }
} }
@@ -59,10 +57,6 @@ func (s *OAuthService) Name() string {
return s.serviceCfg.Name return s.serviceCfg.Name
} }
func (s *OAuthService) ID() string {
return s.id
}
func (s *OAuthService) NewRandom() string { func (s *OAuthService) NewRandom() string {
// The generate verifier function just creates a random string, // The generate verifier function just creates a random string,
// so we can use it to generate a random state as well // so we can use it to generate a random state as well