Skip to content

Conversation

@bjackman
Copy link
Contributor

Currently if the user sets --auth.method without --auth.header, if defaultAuther isn't defined then there is a nil deref.

Check for nil directly so we can give a helpeful error message instead.

Description

Additional Information

Checklist

Before submitting your PR, please indicate which issues are either fixed or closed by this PR. See GitHub Help: Closing issues using keywords.

  • I am aware the project is currently in maintenance-only mode. See README
  • I am aware that translations MUST be made through Transifex and that this PR is NOT a translation update
  • I am making a PR against the master branch.
  • I am sure File Browser can be successfully built. See builds and development.

Currently if the user sets --auth.method without --auth.header, if
defaultAuther isn't defined then there is a nil deref.

Check for nil directly so we can give a helpeful error message instead.
@bjackman bjackman requested a review from a team as a code owner December 27, 2025 17:41
@bjackman
Copy link
Contributor Author

To illustrate the issue:

2025/12/27 18:41:48 No config file used
2025/12/27 18:41:48 Using database: /home/brendan/src/filebrowser/db.tmp

Congratulations! You've set up your database to use with File Browser.
Now add your first user via 'filebrowser users add' and then you just
need to call the main command to boot up the server.
Sign up:                  false
Hide Login Button:        false
Create User Dir:          false
Logout Page:
Minimum Password Length:  12
Auth Method:              json
Shell:

Branding:
  Name:
  Files override:
  Disable external links:              false
  Disable used disk percentage graph:  false
  Color:
  Theme:

Server:
  Log:                       stdout
  Port:                      8080
  Base URL:
  Root:                      .
  Socket:
  Address:                   127.0.0.1
  TLS Cert:
  TLS Key:
  Token Expiration Time:     2h
  Exec Enabled:              false
  Thumbnails Enabled:        true
  Resize Preview:            true
  Type Detection by Header:  true

TUS:
  Chunk size:   10485760
  Retry count:  5

Defaults:
  Scope:                                 .
  HideDotfiles:                          false
  Locale:                                en
  View mode:                             list
  Single Click:                          false
  File Creation Mode:                    0o640
  Directory Creation Mode:               0o750
  Commands:
  Ace editor syntax highlighting theme:
  Sorting:
    By:   name
    Asc:  false
  Permissions:
    Admin:     false
    Execute:   true
    Create:    true
    Rename:    true
    Modify:    true
    Delete:    true
    Share:     true
    Download:  true

Auther configuration (raw):

{
  "recaptcha": null
}


~/src/filebrowser (master|…3) <3> nix
❯❯  go run . -d ./db.tmp config set --auth.method proxy
2025/12/27 18:42:02 No config file used
2025/12/27 18:42:02 Using database: /home/brendan/src/filebrowser/db.tmp
panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
github.com/filebrowser/filebrowser/v2/cmd.getProxyAuth(0xc00006fa10?, 0x0)
        github.com/filebrowser/filebrowser/v2/cmd/config.go:103 +0x166
github.com/filebrowser/filebrowser/v2/cmd.getAuthentication(0xc000114400, {0xc00006fb08?, 0xc000014320?, 0xcc7a00?})
        github.com/filebrowser/filebrowser/v2/cmd/config.go:181 +0xc5
github.com/filebrowser/filebrowser/v2/cmd.getSettings(0xc000114400, 0xc000196780, 0x28?, {0xfc25f8, 0xc0000ae370}, 0x0)
        github.com/filebrowser/filebrowser/v2/cmd/config.go:380 +0x22a
github.com/filebrowser/filebrowser/v2/cmd.init.func9(0xfb56c8?, {0xc0003586a8?, 0xc00006a9d0?, 0xc00006a9c0?}, 0xc00006fc50)
        github.com/filebrowser/filebrowser/v2/cmd/config_set.go:38 +0xcd
github.com/filebrowser/filebrowser/v2/cmd.init.withStore.func32(0xc000358618?, {0xc000304540?, 0xc00006fc70?, 0x1?}, 0x0?, 0x0?)
        github.com/filebrowser/filebrowser/v2/cmd/utils.go:198 +0x23
github.com/filebrowser/filebrowser/v2/cmd.init.withStore.withViperAndStore.func56(0x15ef5c0, {0xc000304540, 0x0, 0x4})
        github.com/filebrowser/filebrowser/v2/cmd/utils.go:192 +0x35e
github.com/spf13/cobra.(*Command).execute(0x15ef5c0, {0xc000304500, 0x4, 0x4})
        github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb02
github.com/spf13/cobra.(*Command).ExecuteC(0x15efb80)
        github.com/spf13/cobra@v1.10.2/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.10.2/command.go:1071
github.com/filebrowser/filebrowser/v2/cmd.Execute(...)
        github.com/filebrowser/filebrowser/v2/cmd/cmd.go:5
main.main()
        github.com/filebrowser/filebrowser/v2/main.go:10 +0x1a
exit status 2

@hacdias hacdias merged commit 60b1ee8 into filebrowser:master Dec 28, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants