Auth: Shorten passwd mode option (password still works) #98 #782

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2022-07-11 05:08:15 +02:00
parent 53211c29fc
commit 20a82efda4
15 changed files with 35 additions and 21 deletions

View file

@ -124,9 +124,9 @@ acceptance-stop:
acceptance-private-restart:
cp -f storage/acceptance/backup.db storage/acceptance/index.db
cp -f storage/acceptance/config/settingsBackup.yml storage/acceptance/config/settings.yml
./photoprism --auth-mode "password" --url "http://localhost:2343/" --upload-nsfw=false --db "sqlite" --dsn "./storage/acceptance/index.db" --import-path "./storage/acceptance/import" --port 2343 -c "./storage/acceptance/config" -o "./storage/acceptance/originals" -s "./storage/acceptance" --test --backup-path "./storage/acceptance/backup" --disable-backups start -d
./photoprism --auth-mode "passwd" --url "http://localhost:2343/" --upload-nsfw=false --db "sqlite" --dsn "./storage/acceptance/index.db" --import-path "./storage/acceptance/import" --port 2343 -c "./storage/acceptance/config" -o "./storage/acceptance/originals" -s "./storage/acceptance" --test --backup-path "./storage/acceptance/backup" --disable-backups start -d
acceptance-private-stop:
./photoprism --auth-mode "password" --url "http://localhost:2343/" --upload-nsfw=false --db "sqlite" --dsn "./storage/acceptance/index.db" --import-path "./storage/acceptance/import" --port 2343 -c "./storage/acceptance/config" -o "./storage/acceptance/originals" -s "./storage/acceptance" --test --backup-path "./storage/acceptance/backup" --disable-backups stop
./photoprism --auth-mode "passwd" --url "http://localhost:2343/" --upload-nsfw=false --db "sqlite" --dsn "./storage/acceptance/index.db" --import-path "./storage/acceptance/import" --port 2343 -c "./storage/acceptance/config" -o "./storage/acceptance/originals" -s "./storage/acceptance" --test --backup-path "./storage/acceptance/backup" --disable-backups stop
start:
./photoprism start -d
stop:

View file

@ -21,7 +21,7 @@ services:
environment:
PHOTOPRISM_UID: ${UID:-1000} # user id, should match your host user id
PHOTOPRISM_GID: ${GID:-1000} # group id
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # initial "admin" password (minimum 8 characters)
## Public server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_SITE_URL: "https://latest.localssl.dev/"

View file

@ -21,7 +21,7 @@ services:
environment:
PHOTOPRISM_UID: ${UID:-1000} # user id, should match your host user id
PHOTOPRISM_GID: ${GID:-1000} # group id
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # initial "admin" password (minimum 8 characters)
## Public server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_SITE_URL: "https://latest.localssl.dev/"

View file

@ -25,7 +25,7 @@ services:
- "go-mod:/go/pkg/mod"
shm_size: "2gb"
environment:
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # initial "admin" password (minimum 8 characters)
PHOTOPRISM_SITE_URL: "http://localhost:2342/"
PHOTOPRISM_SITE_CAPTION: "AI-Powered Photos App"

View file

@ -34,7 +34,7 @@ services:
## Switch to a non-root user after initialization (supported IDs are 33, 50-99, 500-600, and 900-1200):
PHOTOPRISM_UID: ${UID:-1000} # user id, should match your host user id
PHOTOPRISM_GID: ${GID:-1000} # group id
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # initial "admin" password (minimum 8 characters)
## External development server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_SITE_URL: "https://app.localssl.dev/"

View file

@ -60,7 +60,7 @@ services:
ports:
- "2342:2342" # HTTP port (host:container)
environment:
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "insecure" # YOUR INITIAL ADMIN PASSWORD (MINIMUM 8 CHARACTERS, USERNAME "admin")
PHOTOPRISM_SITE_URL: "http://localhost:2342/" # public server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_ORIGINALS_LIMIT: 5000 # file size limit for originals in MB (increase for high-res video)

View file

@ -55,7 +55,7 @@ services:
ports:
- "2342:2342" # HTTP port (host:container)
environment:
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "insecure" # YOUR INITIAL ADMIN PASSWORD (MINIMUM 8 CHARACTERS, USERNAME "admin")
PHOTOPRISM_SITE_URL: "http://localhost:2342/" # public server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_ORIGINALS_LIMIT: 5000 # file size limit for originals in MB (increase for high-res video)

View file

@ -132,7 +132,7 @@ services:
PHOTOPRISM_SITE_CAPTION: "AI-Powered Photos App"
PHOTOPRISM_SITE_DESCRIPTION: "" # meta site description
PHOTOPRISM_SITE_AUTHOR: "" # meta site author
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "_admin_password_" # YOUR INITIAL "admin" PASSWORD
PHOTOPRISM_ORIGINALS_LIMIT: 5000 # file size limit for originals in MB (increase for high-res video)
PHOTOPRISM_HTTP_COMPRESSION: "gzip" # improves transfer speed and bandwidth utilization (none or gzip)
@ -170,7 +170,7 @@ services:
## see https://docs.photoprism.app/getting-started/proxies/traefik/
traefik:
restart: always
image: traefik:v2.6
image: traefik:v2.8
container_name: traefik
ports:
- "80:80"

View file

@ -52,7 +52,7 @@ services:
ports:
- "2342:2342" # HTTP port (host:container)
environment:
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "insecure" # YOUR INITIAL ADMIN PASSWORD (MINIMUM 8 CHARACTERS, USERNAME "admin")
PHOTOPRISM_SITE_URL: "http://localhost:2342/" # public server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_ORIGINALS_LIMIT: 5000 # file size limit for originals in MB (increase for high-res video)

View file

@ -49,7 +49,7 @@ services:
ports:
- "2342:2342" # HTTP port (host:container)
environment:
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "insecure" # YOUR INITIAL ADMIN PASSWORD (MINIMUM 8 CHARACTERS, USERNAME "admin")
PHOTOPRISM_SITE_URL: "http://localhost:2342/" # public server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_ORIGINALS_LIMIT: 5000 # file size limit for originals in MB (increase for high-res video)

View file

@ -54,7 +54,7 @@ services:
ports:
- "2342:2342" # HTTP port (host:container)
environment:
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "insecure" # YOUR INITIAL ADMIN PASSWORD (MINIMUM 8 CHARACTERS, USERNAME "admin")
PHOTOPRISM_SITE_URL: "http://localhost:2342/" # public server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_ORIGINALS_LIMIT: 5000 # file size limit for originals in MB (increase for high-res video)

View file

@ -52,7 +52,7 @@ services:
ports:
- "2342:2342" # HTTP port (host:container)
environment:
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "insecure" # YOUR INITIAL ADMIN PASSWORD (MINIMUM 8 CHARACTERS, USERNAME "admin")
PHOTOPRISM_SITE_URL: "http://localhost:2342/" # public server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_ORIGINALS_LIMIT: 5000 # file size limit for originals in MB (increase for high-res video)

View file

@ -54,7 +54,7 @@ services:
ports:
- "2342:2342" # HTTP port (host:container)
environment:
PHOTOPRISM_AUTH_MODE: "password" # authentication mode (public, password)
PHOTOPRISM_AUTH_MODE: "passwd" # authentication mode (public, passwd)
PHOTOPRISM_ADMIN_PASSWORD: "insecure" # YOUR INITIAL ADMIN PASSWORD (MINIMUM 8 CHARACTERS, USERNAME "admin")
PHOTOPRISM_SITE_URL: "http://localhost:2342/" # public server URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_ORIGINALS_LIMIT: 5000 # file size limit for originals in MB (increase for high-res video)

View file

@ -9,8 +9,8 @@ import (
)
const (
AuthModePublic = "public"
AuthModePassword = "password"
AuthModePublic = "public"
AuthModePasswd = "passwd"
)
func isBcrypt(s string) bool {
@ -46,11 +46,18 @@ func (c *Config) AdminPassword() string {
func (c *Config) AuthMode() string {
if c.Public() {
return AuthModePublic
} else if m := strings.ToLower(strings.TrimSpace(c.options.AuthMode)); m != "" {
return m
}
return AuthModePassword
mode := strings.ToLower(strings.TrimSpace(c.options.AuthMode))
switch mode {
case AuthModePublic:
return AuthModePublic
case "", "pw", "pass", "passwd", "password", "passwort", "passwords":
return AuthModePasswd
default:
return AuthModePasswd
}
}
// Auth checks if authentication is required.

View file

@ -13,9 +13,16 @@ func TestAuthMode(t *testing.T) {
assert.Equal(t, AuthModePublic, c.AuthMode())
c.options.Public = false
c.options.Demo = false
assert.Equal(t, AuthModePassword, c.AuthMode())
assert.Equal(t, AuthModePasswd, c.AuthMode())
c.options.Demo = true
assert.Equal(t, AuthModePublic, c.AuthMode())
c.options.AuthMode = "pass"
assert.Equal(t, AuthModePublic, c.AuthMode())
c.options.Demo = false
c.options.AuthMode = "pass"
assert.Equal(t, AuthModePasswd, c.AuthMode())
c.options.AuthMode = "password"
assert.Equal(t, AuthModePasswd, c.AuthMode())
}
func TestAuth(t *testing.T) {