Compare commits

..

4 Commits

Author SHA1 Message Date
Stavros
fc7e395e66 feat: sort configured providers based on name length 2025-10-10 17:16:22 +03:00
Stavros
b940d681c3 feat: use recovery gin middleware in engine 2025-10-10 16:42:19 +03:00
Stavros
a1ec4a69cf fix: remove spaces before checking oauth name and username 2025-10-10 16:28:52 +03:00
github-actions[bot]
4047cea451 docs: regenerate readme sponsors list (#402)
Co-authored-by: GitHub <noreply@github.com>
2025-10-10 15:52:45 +03:00
2 changed files with 8 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import (
"net/http"
"net/url"
"os"
"sort"
"strings"
"time"
"tinyauth/internal/config"
@@ -157,6 +158,10 @@ func (app *BootstrapApp) Setup() error {
})
}
sort.Slice(configuredProviders, func(i, j int) bool {
return configuredProviders[i].Name < configuredProviders[j].Name
})
if authService.UserAuthConfigured() || ldapService != nil {
configuredProviders = append(configuredProviders, controller.Provider{
Name: "Username",
@@ -173,6 +178,7 @@ func (app *BootstrapApp) Setup() error {
// Create engine
engine := gin.New()
engine.Use(gin.Recovery())
if len(app.config.TrustedProxies) > 0 {
err := engine.SetTrustedProxies(strings.Split(app.config.TrustedProxies, ","))

View File

@@ -162,7 +162,7 @@ func (controller *OAuthController) oauthCallbackHandler(c *gin.Context) {
var name string
if user.Name != "" {
if strings.TrimSpace(user.Name) != "" {
log.Debug().Msg("Using name from OAuth provider")
name = user.Name
} else {
@@ -172,7 +172,7 @@ func (controller *OAuthController) oauthCallbackHandler(c *gin.Context) {
var username string
if user.PreferredUsername != "" {
if strings.TrimSpace(user.PreferredUsername) != "" {
log.Debug().Msg("Using preferred username from OAuth provider")
username = user.PreferredUsername
} else {