Compare commits
21 Commits
v2.0.0-rc.
...
v2.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20d80bb054 | ||
|
|
cbdf3cafb6 | ||
|
|
1259fc1bbc | ||
|
|
4cf1f2f6b4 | ||
|
|
a90bb28cae | ||
|
|
e86dfbe8ff | ||
|
|
437a238aca | ||
|
|
e5fa0772c6 | ||
|
|
ba5c67d9da | ||
|
|
f3d007025e | ||
|
|
e7a39808dd | ||
|
|
2b7aa7a0c9 | ||
|
|
4d8f0c532b | ||
|
|
367e251a0e | ||
|
|
cc6f2f8bec | ||
|
|
007fde8186 | ||
|
|
552f8168ea | ||
|
|
42426e3e69 | ||
|
|
e706391934 | ||
|
|
58ff28f84d | ||
|
|
74a1ecbb89 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@
|
|||||||
*.bak
|
*.bak
|
||||||
_old
|
_old
|
||||||
rice-box.go
|
rice-box.go
|
||||||
|
.idea/
|
||||||
@@ -5,7 +5,6 @@ install: skip
|
|||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- docker-ce
|
|
||||||
- pass
|
- pass
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|||||||
@@ -10,4 +10,6 @@ import (
|
|||||||
type Auther interface {
|
type Auther interface {
|
||||||
// Auth is called to authenticate a request.
|
// Auth is called to authenticate a request.
|
||||||
Auth(r *http.Request, s *users.Storage, root string) (*users.User, error)
|
Auth(r *http.Request, s *users.Storage, root string) (*users.User, error)
|
||||||
|
// LoginPage indicates if this auther needs a login page.
|
||||||
|
LoginPage() bool
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ func (a JSONAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users
|
|||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoginPage tells that json auth doesn't require a login page.
|
||||||
|
func (a JSONAuth) LoginPage() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
const reCaptchaAPI = "/recaptcha/api/siteverify"
|
const reCaptchaAPI = "/recaptcha/api/siteverify"
|
||||||
|
|
||||||
// ReCaptcha identifies a recaptcha conenction.
|
// ReCaptcha identifies a recaptcha conenction.
|
||||||
|
|||||||
@@ -17,3 +17,8 @@ type NoAuth struct{}
|
|||||||
func (a NoAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error) {
|
func (a NoAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error) {
|
||||||
return sto.Get(root, uint(1))
|
return sto.Get(root, uint(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoginPage tells that no auth doesn't require a login page.
|
||||||
|
func (a NoAuth) LoginPage() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,3 +27,8 @@ func (a ProxyAuth) Auth(r *http.Request, sto *users.Storage, root string) (*user
|
|||||||
|
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoginPage tells that proxy auth doesn't require a login page.
|
||||||
|
func (a ProxyAuth) LoginPage() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var cmdsCmd = &cobra.Command{
|
var cmdsCmd = &cobra.Command{
|
||||||
Use: "cmds",
|
Use: "cmds",
|
||||||
Version: rootCmd.Version,
|
Short: "Command runner management utility",
|
||||||
Short: "Command runner management utility",
|
Long: `Command runner management utility.`,
|
||||||
Long: `Command runner management utility.`,
|
Args: cobra.NoArgs,
|
||||||
Args: cobra.NoArgs,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func printEvents(m map[string][]string) {
|
func printEvents(m map[string][]string) {
|
||||||
|
|||||||
@@ -20,11 +20,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var configCmd = &cobra.Command{
|
var configCmd = &cobra.Command{
|
||||||
Use: "config",
|
Use: "config",
|
||||||
Version: rootCmd.Version,
|
Short: "Configuration management utility",
|
||||||
Short: "Configuration management utility",
|
Long: `Configuration management utility.`,
|
||||||
Long: `Configuration management utility.`,
|
Args: cobra.NoArgs,
|
||||||
Args: cobra.NoArgs,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func addConfigFlags(flags *pflag.FlagSet) {
|
func addConfigFlags(flags *pflag.FlagSet) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ The path must be for a json or yaml file.`,
|
|||||||
checkErr(err)
|
checkErr(err)
|
||||||
key = settings.Key
|
key = settings.Key
|
||||||
} else {
|
} else {
|
||||||
key = generateRandomBytes(64)
|
key = generateKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
file := settingsFile{}
|
file := settingsFile{}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ override the options.`,
|
|||||||
authMethod, auther := getAuthentication(flags)
|
authMethod, auther := getAuthentication(flags)
|
||||||
|
|
||||||
s := &settings.Settings{
|
s := &settings.Settings{
|
||||||
Key: generateRandomBytes(64), // 256 bit
|
Key: generateKey(),
|
||||||
Signup: mustGetBool(flags, "signup"),
|
Signup: mustGetBool(flags, "signup"),
|
||||||
Shell: strings.Split(strings.TrimSpace(mustGetString(flags, "shell")), " "),
|
Shell: strings.Split(strings.TrimSpace(mustGetString(flags, "shell")), " "),
|
||||||
AuthMethod: authMethod,
|
AuthMethod: authMethod,
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var hashCmd = &cobra.Command{
|
var hashCmd = &cobra.Command{
|
||||||
Use: "hash <password>",
|
Use: "hash <password>",
|
||||||
Version: rootCmd.Version,
|
Short: "Hashes a password",
|
||||||
Short: "Hashes a password",
|
Long: `Hashes a password using bcrypt algorithm.`,
|
||||||
Long: `Hashes a password using bcrypt algorithm.`,
|
Args: cobra.ExactArgs(1),
|
||||||
Args: cobra.ExactArgs(1),
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
pwd, err := users.HashPwd(args[0])
|
pwd, err := users.HashPwd(args[0])
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/filebrowser/filebrowser/v2/settings"
|
"github.com/filebrowser/filebrowser/v2/settings"
|
||||||
"github.com/filebrowser/filebrowser/v2/storage"
|
"github.com/filebrowser/filebrowser/v2/storage"
|
||||||
"github.com/filebrowser/filebrowser/v2/users"
|
"github.com/filebrowser/filebrowser/v2/users"
|
||||||
"github.com/filebrowser/filebrowser/v2/version"
|
|
||||||
homedir "github.com/mitchellh/go-homedir"
|
homedir "github.com/mitchellh/go-homedir"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@@ -55,9 +54,8 @@ func addServerFlags(flags *pflag.FlagSet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "filebrowser",
|
Use: "filebrowser",
|
||||||
Version: version.Version,
|
Short: "A stylish web-based file browser",
|
||||||
Short: "A stylish web-based file browser",
|
|
||||||
Long: `File Browser CLI lets you create the database to use with File Browser,
|
Long: `File Browser CLI lets you create the database to use with File Browser,
|
||||||
manage your users and all the configurations without acessing the
|
manage your users and all the configurations without acessing the
|
||||||
web interface.
|
web interface.
|
||||||
@@ -215,7 +213,7 @@ func setupLog(logMethod string) {
|
|||||||
|
|
||||||
func quickSetup(flags *pflag.FlagSet, d pythonData) {
|
func quickSetup(flags *pflag.FlagSet, d pythonData) {
|
||||||
set := &settings.Settings{
|
set := &settings.Settings{
|
||||||
Key: generateRandomBytes(64), // 256 bit
|
Key: generateKey(),
|
||||||
Signup: false,
|
Signup: false,
|
||||||
Defaults: settings.UserDefaults{
|
Defaults: settings.UserDefaults{
|
||||||
Scope: ".",
|
Scope: ".",
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ func init() {
|
|||||||
|
|
||||||
var rulesCmd = &cobra.Command{
|
var rulesCmd = &cobra.Command{
|
||||||
Use: "rules",
|
Use: "rules",
|
||||||
Version: rootCmd.Version,
|
|
||||||
Short: "Rules management utility",
|
Short: "Rules management utility",
|
||||||
Long: `On each subcommand you'll have available at least two flags:
|
Long: `On each subcommand you'll have available at least two flags:
|
||||||
"username" and "id". You must either set only one of them
|
"username" and "id". You must either set only one of them
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var upgradeCmd = &cobra.Command{
|
var upgradeCmd = &cobra.Command{
|
||||||
Use: "upgrade",
|
Use: "upgrade",
|
||||||
Version: rootCmd.Version,
|
Short: "Upgrades an old configuration",
|
||||||
Short: "Upgrades an old configuration",
|
|
||||||
Long: `Upgrades an old configuration. This command DOES NOT
|
Long: `Upgrades an old configuration. This command DOES NOT
|
||||||
import share links because they are incompatible with
|
import share links because they are incompatible with
|
||||||
this version.`,
|
this version.`,
|
||||||
|
|||||||
@@ -18,11 +18,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var usersCmd = &cobra.Command{
|
var usersCmd = &cobra.Command{
|
||||||
Use: "users",
|
Use: "users",
|
||||||
Version: rootCmd.Version,
|
Short: "Users management utility",
|
||||||
Short: "Users management utility",
|
Long: `Users management utility.`,
|
||||||
Long: `Users management utility.`,
|
Args: cobra.NoArgs,
|
||||||
Args: cobra.NoArgs,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func printUsers(users []*users.User) {
|
func printUsers(users []*users.User) {
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ list or set it to 0.`,
|
|||||||
checkErr(usernameConflictError(user.Username, conflictuous.ID, user.ID))
|
checkErr(usernameConflictError(user.Username, conflictuous.ID, user.ID))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// If it doesn't exist, set the ID to 0 to automatically get a new
|
||||||
|
// one that make sense in this DB.
|
||||||
|
user.ID = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
err = d.store.Users.Save(user)
|
err = d.store.Users.Save(user)
|
||||||
|
|||||||
28
cmd/utils.go
28
cmd/utils.go
@@ -1,7 +1,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -10,6 +9,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/asdine/storm"
|
"github.com/asdine/storm"
|
||||||
|
"github.com/filebrowser/filebrowser/v2/settings"
|
||||||
"github.com/filebrowser/filebrowser/v2/storage"
|
"github.com/filebrowser/filebrowser/v2/storage"
|
||||||
"github.com/filebrowser/filebrowser/v2/storage/bolt"
|
"github.com/filebrowser/filebrowser/v2/storage/bolt"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -41,12 +41,10 @@ func mustGetUint(flags *pflag.FlagSet, flag string) uint {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateRandomBytes(n int) []byte {
|
func generateKey() []byte {
|
||||||
b := make([]byte, n)
|
k, err := settings.GenerateKey()
|
||||||
_, err := rand.Read(b)
|
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
// Note that err == nil only if we read len(b) bytes.
|
return k
|
||||||
return b
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type cobraFunc func(cmd *cobra.Command, args []string)
|
type cobraFunc func(cmd *cobra.Command, args []string)
|
||||||
@@ -64,18 +62,20 @@ type pythonData struct {
|
|||||||
|
|
||||||
func dbExists(path string) (bool, error) {
|
func dbExists(path string) (bool, error) {
|
||||||
stat, err := os.Stat(path)
|
stat, err := os.Stat(path)
|
||||||
|
if err == nil {
|
||||||
|
return stat.Size() != 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return false, nil
|
d := filepath.Dir(path)
|
||||||
} else if err != nil {
|
_, err = os.Stat(d)
|
||||||
return false, err
|
if os.IsNotExist(err) {
|
||||||
|
os.MkdirAll(d, 0700)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if stat.Size() == 0 {
|
return false, err
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return true, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func python(fn pythonFunc, cfg pythonConfig) cobraFunc {
|
func python(fn pythonFunc, cfg pythonConfig) cobraFunc {
|
||||||
|
|||||||
@@ -1,32 +1,20 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"text/template"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/filebrowser/filebrowser/v2/version"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(versionCmd)
|
rootCmd.AddCommand(versionCmd)
|
||||||
cmdsCmd.AddCommand(versionCmd)
|
|
||||||
configCmd.AddCommand(versionCmd)
|
|
||||||
hashCmd.AddCommand(versionCmd)
|
|
||||||
upgradeCmd.AddCommand(versionCmd)
|
|
||||||
rulesCmd.AddCommand(versionCmd)
|
|
||||||
usersCmd.AddCommand(versionCmd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var versionCmd = &cobra.Command{
|
var versionCmd = &cobra.Command{
|
||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Print the version number of File Browser",
|
Short: "Print the version number",
|
||||||
Long: `All software has versions. This is File Browser's`,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
// https://github.com/spf13/cobra/issues/724
|
fmt.Println("File Browser Version " + version.Version)
|
||||||
t := template.New("version")
|
|
||||||
template.Must(t.Parse(rootCmd.VersionTemplate()))
|
|
||||||
err := t.Execute(rootCmd.OutOrStdout(), rootCmd)
|
|
||||||
if err != nil {
|
|
||||||
rootCmd.Println(err)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package files
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/maruel/natural"
|
"github.com/maruel/natural"
|
||||||
)
|
)
|
||||||
@@ -68,7 +69,7 @@ func (l byName) Less(i, j int) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return natural.Less(l.Items[i].Name, l.Items[j].Name)
|
return natural.Less(strings.ToLower(l.Items[j].Name), strings.ToLower(l.Items[i].Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
// By Size
|
// By Size
|
||||||
|
|||||||
2
frontend
2
frontend
Submodule frontend updated: 2ed87febcb...9c3f563f83
4
go.mod
4
go.mod
@@ -21,12 +21,12 @@ require (
|
|||||||
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect
|
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect
|
||||||
github.com/kr/pretty v0.1.0 // indirect
|
github.com/kr/pretty v0.1.0 // indirect
|
||||||
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1
|
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1
|
||||||
github.com/mholt/archiver v3.1.0+incompatible
|
github.com/mholt/archiver v3.1.1+incompatible
|
||||||
github.com/mholt/caddy v0.11.1
|
github.com/mholt/caddy v0.11.1
|
||||||
github.com/mitchellh/go-homedir v1.0.0
|
github.com/mitchellh/go-homedir v1.0.0
|
||||||
github.com/nwaples/rardecode v1.0.0 // indirect
|
github.com/nwaples/rardecode v1.0.0 // indirect
|
||||||
github.com/pelletier/go-toml v1.2.0
|
github.com/pelletier/go-toml v1.2.0
|
||||||
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
|
github.com/pierrec/lz4 v0.0.0-20190131084431-473cd7ce01a1 // indirect
|
||||||
github.com/spf13/afero v1.1.2
|
github.com/spf13/afero v1.1.2
|
||||||
github.com/spf13/cobra v0.0.3
|
github.com/spf13/cobra v0.0.3
|
||||||
github.com/spf13/pflag v1.0.3
|
github.com/spf13/pflag v1.0.3
|
||||||
|
|||||||
5
go.sum
5
go.sum
@@ -57,6 +57,8 @@ github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1 h1:PEhRT94KBTY4E0Kd
|
|||||||
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1/go.mod h1:wI697HNhDFM/vBruYM3ckbszQ2+DOIeH9qdBKMdf288=
|
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1/go.mod h1:wI697HNhDFM/vBruYM3ckbszQ2+DOIeH9qdBKMdf288=
|
||||||
github.com/mholt/archiver v3.1.0+incompatible h1:S1rFZ7umHtN6cG+6cusrfoXTMPqp6u/R89iKxBYJd4w=
|
github.com/mholt/archiver v3.1.0+incompatible h1:S1rFZ7umHtN6cG+6cusrfoXTMPqp6u/R89iKxBYJd4w=
|
||||||
github.com/mholt/archiver v3.1.0+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
|
github.com/mholt/archiver v3.1.0+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
|
||||||
|
github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU=
|
||||||
|
github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
|
||||||
github.com/mholt/caddy v0.11.1 h1:oNfejqftVesLoFxw53Gh17aBPNbTxQ9xJw1pn4IiAPk=
|
github.com/mholt/caddy v0.11.1 h1:oNfejqftVesLoFxw53Gh17aBPNbTxQ9xJw1pn4IiAPk=
|
||||||
github.com/mholt/caddy v0.11.1/go.mod h1:Wb1PlT4DAYSqOEd03MsqkdkXnTxA8v9pKjdpxbqM1kY=
|
github.com/mholt/caddy v0.11.1/go.mod h1:Wb1PlT4DAYSqOEd03MsqkdkXnTxA8v9pKjdpxbqM1kY=
|
||||||
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
|
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
|
||||||
@@ -67,8 +69,11 @@ github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMB
|
|||||||
github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
|
github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
|
||||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
|
github.com/pierrec/lz4 v0.0.0-20190131084431-473cd7ce01a1 h1:0utzB5Mn6QyMzIeOn+oD7pjKQLjJwfM9bz6TkPPdxcw=
|
||||||
|
github.com/pierrec/lz4 v0.0.0-20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||||
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
|
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
|
||||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||||
|
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type authToken struct {
|
|||||||
type extractor []string
|
type extractor []string
|
||||||
|
|
||||||
func (e extractor) ExtractToken(r *http.Request) (string, error) {
|
func (e extractor) ExtractToken(r *http.Request) (string, error) {
|
||||||
token, _ := request.AuthorizationHeaderExtractor.ExtractToken(r)
|
token, _ := request.HeaderExtractor{"X-Auth"}.ExtractToken(r)
|
||||||
|
|
||||||
// Checks if the token isn't empty and if it contains two dots.
|
// Checks if the token isn't empty and if it contains two dots.
|
||||||
// The former prevents incompatibility with URLs that previously
|
// The former prevents incompatibility with URLs that previously
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *data, box *
|
|||||||
|
|
||||||
staticURL := strings.TrimPrefix(d.server.BaseURL+"/static", "/")
|
staticURL := strings.TrimPrefix(d.server.BaseURL+"/static", "/")
|
||||||
|
|
||||||
|
auther, err := d.store.Auth.Get(d.settings.AuthMethod)
|
||||||
|
if err != nil {
|
||||||
|
return http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"Name": d.settings.Branding.Name,
|
"Name": d.settings.Branding.Name,
|
||||||
"DisableExternal": d.settings.Branding.DisableExternal,
|
"DisableExternal": d.settings.Branding.DisableExternal,
|
||||||
@@ -29,6 +34,7 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *data, box *
|
|||||||
"StaticURL": staticURL,
|
"StaticURL": staticURL,
|
||||||
"Signup": d.settings.Signup,
|
"Signup": d.settings.Signup,
|
||||||
"NoAuth": d.settings.AuthMethod == auth.MethodNoAuth,
|
"NoAuth": d.settings.AuthMethod == auth.MethodNoAuth,
|
||||||
|
"LoginPage": auther.LoginPage(),
|
||||||
"CSS": false,
|
"CSS": false,
|
||||||
"ReCaptcha": false,
|
"ReCaptcha": false,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package settings
|
package settings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/filebrowser/filebrowser/v2/rules"
|
"github.com/filebrowser/filebrowser/v2/rules"
|
||||||
@@ -41,3 +42,15 @@ type Server struct {
|
|||||||
func (s *Server) Clean() {
|
func (s *Server) Clean() {
|
||||||
s.BaseURL = strings.TrimSuffix(s.BaseURL, "/")
|
s.BaseURL = strings.TrimSuffix(s.BaseURL, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GenerateKey generates a key of 256 bits.
|
||||||
|
func GenerateKey() ([]byte, error) {
|
||||||
|
b := make([]byte, 64)
|
||||||
|
_, err := rand.Read(b)
|
||||||
|
// Note that err == nil only if we read len(b) bytes.
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ func convertUsersToNew(old []*oldUser) ([]*users.User, error) {
|
|||||||
|
|
||||||
for _, oldUser := range old {
|
for _, oldUser := range old {
|
||||||
user := &users.User{
|
user := &users.User{
|
||||||
ID: uint(oldUser.ID),
|
|
||||||
Username: oldUser.Username,
|
Username: oldUser.Username,
|
||||||
Password: oldUser.Password,
|
Password: oldUser.Password,
|
||||||
Scope: oldUser.Scope,
|
Scope: oldUser.Scope,
|
||||||
|
|||||||
@@ -89,11 +89,11 @@ func (s *Storage) Save(user *User) error {
|
|||||||
// id must be a string for username lookup or a uint for id lookup. If id
|
// id must be a string for username lookup or a uint for id lookup. If id
|
||||||
// is neither, a ErrInvalidDataType will be returned.
|
// is neither, a ErrInvalidDataType will be returned.
|
||||||
func (s *Storage) Delete(id interface{}) (err error) {
|
func (s *Storage) Delete(id interface{}) (err error) {
|
||||||
switch id.(type) {
|
switch id := id.(type) {
|
||||||
case string:
|
case string:
|
||||||
err = s.back.DeleteByUsername(id.(string))
|
err = s.back.DeleteByUsername(id)
|
||||||
case uint:
|
case uint:
|
||||||
err = s.back.DeleteByID(id.(uint))
|
err = s.back.DeleteByID(id)
|
||||||
default:
|
default:
|
||||||
err = errors.ErrInvalidDataType
|
err = errors.ErrInvalidDataType
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ package version
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// Version is the current File Browser version.
|
// Version is the current File Browser version.
|
||||||
Version = "v2.0.0-rc.2"
|
Version = "v2.0.3"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user