🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Option to allow auto-login during development.
Deluanc09468e13545
diff --git a/conf/configuration.go b/conf/configuration.goindex 49d356f87..20d222ce5 100644--- a/conf/configuration.go+++ b/conf/configuration.go@@ -63,6 +63,7 @@ type configOptions struct {// DevFlags. These are used to enable/disable debugging and incomplete featuresDevLogSourceLine boolDevAutoCreateAdminPassword string+ DevAutoLoginUsername stringDevPreCacheAlbumArtwork boolDevFastAccessCoverArt boolDevOldCacheLayout bool@@ -220,6 +221,7 @@ func init() {// DevFlags. These are used to enable/disable debugging and incomplete featuresviper.SetDefault("devlogsourceline", false)viper.SetDefault("devautocreateadminpassword", "")+ viper.SetDefault("devautologinusername", "")viper.SetDefault("devprecachealbumartwork", false)viper.SetDefault("devoldcachelayout", false)viper.SetDefault("devFastAccessCoverArt", false)diff --git a/server/auth.go b/server/auth.goindex 1fb3dca2a..65c202d0f 100644--- a/server/auth.go+++ b/server/auth.go@@ -207,6 +207,10 @@ func UsernameFromReverseProxyHeader(r *http.Request) string {return username}+func UsernameFromConfig(r *http.Request) string {+ return conf.Server.DevAutoLoginUsername+}+func contextWithUser(ctx context.Context, ds model.DataStore, username string) (context.Context, error) {user, err := ds.User(ctx).FindByUsername(username)if err == nil {@@ -235,7 +239,7 @@ func authenticateRequest(ds model.DataStore, r *http.Request, findUsernameFns ..func Authenticator(ds model.DataStore) func(next http.Handler) http.Handler {return func(next http.Handler) http.Handler {return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {- ctx, err := authenticateRequest(ds, r, UsernameFromToken, UsernameFromReverseProxyHeader)+ ctx, err := authenticateRequest(ds, r, UsernameFromConfig, UsernameFromToken, UsernameFromReverseProxyHeader)if err != nil {_ = rest.RespondWithError(w, http.StatusUnauthorized, "Not authenticated")return@@ -268,9 +272,12 @@ func JWTRefresher(next http.Handler) http.Handler {}func handleLoginFromHeaders(ds model.DataStore, r *http.Request) map[string]interface{} {- username := UsernameFromReverseProxyHeader(r)+ username := UsernameFromConfig(r)if username == "" {- return nil+ username = UsernameFromReverseProxyHeader(r)+ if username == "" {+ return nil+ }}userRepo := ds.User(r.Context())