Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f014828ee6 | ||
|
|
bab6b7760b | ||
|
|
e278dbba65 | ||
|
|
5a8c28fa6d | ||
|
|
e7e2edf76c | ||
|
|
dd2d02e492 | ||
|
|
735e74a858 | ||
|
|
7fc2414476 | ||
|
|
822b8f8e05 | ||
|
|
2d63c288e4 | ||
|
|
218a96eebd | ||
|
|
4fbef557ee | ||
|
|
0a4c803650 | ||
|
|
68c5b8cd52 | ||
|
|
0cff87be24 | ||
|
|
a2fcb8b3b0 | ||
|
|
5eb9e95720 | ||
|
|
967d4e28de | ||
|
|
ee53803fc2 | ||
|
|
fa2ab280aa | ||
|
|
395801016b | ||
|
|
30ed82a70f | ||
|
|
ab643cd0c4 | ||
|
|
85e5beaa4a | ||
|
|
3cab34c68b | ||
|
|
8299f8ed06 | ||
|
|
da05c5048e | ||
|
|
071e1ec19b |
No files matched your search
+14
-10
@@ -2,20 +2,23 @@ version: 2
|
|||||||
jobs:
|
jobs:
|
||||||
linting:
|
linting:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/golang:1.9
|
- image: circleci/golang:1.10
|
||||||
working_directory: /go/src/github.com/filebrowser/filebrowser
|
working_directory: /go/src/github.com/filebrowser/filebrowser
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
name: Install Dependencies
|
name: Install Dependencies
|
||||||
command: |
|
command: |
|
||||||
cd cmd/filebrowser && go get ./... && cd ../..
|
curl -sL -o $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64
|
||||||
|
chmod +x $GOPATH/bin/dep
|
||||||
|
dep ensure -v
|
||||||
go get github.com/alecthomas/gometalinter
|
go get github.com/alecthomas/gometalinter
|
||||||
gometalinter --install
|
gometalinter --install
|
||||||
- run:
|
- run:
|
||||||
name: Run linting
|
name: Run linting
|
||||||
command: |
|
command: |
|
||||||
gometalinter --exclude="rice-box.go" \
|
gometalinter --exclude="rice-box.go" \
|
||||||
|
--deadline=300s \
|
||||||
-D goconst \
|
-D goconst \
|
||||||
-D gocyclo \
|
-D gocyclo \
|
||||||
-D vetshadow \
|
-D vetshadow \
|
||||||
@@ -24,30 +27,31 @@ jobs:
|
|||||||
-D gas
|
-D gas
|
||||||
build:
|
build:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/golang:1.9
|
- image: circleci/golang:1.10
|
||||||
working_directory: /go/src/github.com/filebrowser/filebrowser
|
working_directory: /go/src/github.com/filebrowser/filebrowser
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
name: Install Dependencies
|
name: Install Dependencies
|
||||||
command: |
|
command: |
|
||||||
cd cmd/filebrowser
|
curl -sL -o $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64
|
||||||
go get ./...
|
chmod +x $GOPATH/bin/dep
|
||||||
|
dep ensure -v
|
||||||
- run:
|
- run:
|
||||||
name: Building
|
name: Building
|
||||||
command: go build
|
command: go build github.com/filebrowser/filebrowser/cmd/filebrowser
|
||||||
deploy:
|
deploy:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/golang:1.9
|
- image: circleci/golang:1.10
|
||||||
working_directory: /go/src/github.com/filebrowser/filebrowser
|
working_directory: /go/src/github.com/filebrowser/filebrowser
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
name: Install Dependencies
|
name: Install Dependencies
|
||||||
command: |
|
command: |
|
||||||
cd cmd/filebrowser
|
curl -sL -o $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64
|
||||||
go get ./...
|
chmod +x $GOPATH/bin/dep
|
||||||
cd ../..
|
dep ensure -v
|
||||||
- run:
|
- run:
|
||||||
name: Deploy
|
name: Deploy
|
||||||
command: curl -sL https://git.io/goreleaser | bash
|
command: curl -sL https://git.io/goreleaser | bash
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
### Instructions (remove before submitting):
|
### Instructions (remove before submitting):
|
||||||
|
|
||||||
1. Are you asking for help with using Caddy or File Manager? Please use our forum instead: https://forum.caddyserver.com.
|
1. Are you asking for help with using Caddy or File Browser? Please use our forum instead: https://forum.caddyserver.com.
|
||||||
2. If you are filing a bug report, please answer the following questions.
|
2. If you are filing a bug report, please answer the following questions.
|
||||||
3. If your issue is not a bug report, you do not need to use this template.
|
3. If your issue is not a bug report, you do not need to use this template.
|
||||||
4. If not using with Caddy, ignore questions 1 and 2.
|
4. If not using with Caddy, ignore questions 1 and 2.
|
||||||
|
|
||||||
### 1. Have you downloaded File Manager from caddyserver.com? If yes, when have you done that? If no, and you are running a custom build, which is the revision of File Manager's repository?
|
### 1. Have you downloaded File Browser from caddyserver.com? If yes, when have you done that? If no, and you are running a custom build, which is the revision of File Browser's repository?
|
||||||
|
|
||||||
### 2. What is your entire Caddyfile?
|
### 2. What is your entire Caddyfile?
|
||||||
```text
|
```text
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ yarn-error.log*
|
|||||||
.vscode
|
.vscode
|
||||||
package-lock.json
|
package-lock.json
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
vendor
|
||||||
+11
-5
@@ -19,18 +19,24 @@ build:
|
|||||||
- mips64
|
- mips64
|
||||||
- mipsle
|
- mipsle
|
||||||
- mips64le
|
- mips64le
|
||||||
|
goarm:
|
||||||
|
- 5
|
||||||
|
- 6
|
||||||
|
- 7
|
||||||
ignore:
|
ignore:
|
||||||
|
- goos: darwin
|
||||||
|
goarch: 386
|
||||||
- goos: openbsd
|
- goos: openbsd
|
||||||
goarch: arm
|
goarch: arm
|
||||||
goarm: 6
|
|
||||||
- goos: freebsd
|
- goos: freebsd
|
||||||
goarch: arm
|
goarch: arm
|
||||||
goarm: 6
|
- goos: netbsd
|
||||||
- goos: linux
|
goarch: arm
|
||||||
goarch: arm64
|
- goos: solaris
|
||||||
|
goarch: arm
|
||||||
|
|
||||||
archive:
|
archive:
|
||||||
name_template: "{{.Os}}-{{.Arch}}-{{ .ProjectName }}"
|
name_template: "{{.Os}}-{{.Arch}}{{if .Arm}}v{{.Arm}}{{end}}-{{ .ProjectName }}"
|
||||||
format: tar.gz
|
format: tar.gz
|
||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
|
|||||||
+5
-5
@@ -1,11 +1,12 @@
|
|||||||
|
|
||||||
FROM golang:alpine
|
FROM golang:alpine
|
||||||
|
|
||||||
COPY . /go/src/github.com/filebrowser/filebrowser
|
COPY . /go/src/github.com/filebrowser/filebrowser
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/filebrowser/filebrowser
|
WORKDIR /go/src/github.com/filebrowser/filebrowser
|
||||||
RUN apk add --no-cache git
|
RUN apk add --no-cache git curl && \
|
||||||
RUN go get ./...
|
curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 && \
|
||||||
|
chmod +x /usr/local/bin/dep
|
||||||
|
RUN dep ensure -vendor-only
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/filebrowser/filebrowser/cmd/filebrowser
|
WORKDIR /go/src/github.com/filebrowser/filebrowser/cmd/filebrowser
|
||||||
RUN CGO_ENABLED=0 go build -a
|
RUN CGO_ENABLED=0 go build -a
|
||||||
@@ -20,5 +21,4 @@ EXPOSE 80
|
|||||||
|
|
||||||
COPY Docker.json /config.json
|
COPY Docker.json /config.json
|
||||||
|
|
||||||
ENTRYPOINT ["/filebrowser"]
|
ENTRYPOINT ["/filebrowser", "--config", "/config.json"]
|
||||||
CMD ["--config", "/config.json"]
|
|
||||||
Generated
+423
@@ -0,0 +1,423 @@
|
|||||||
|
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||||
|
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/BurntSushi/toml"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "a368813c5e648fee92e5f6c30e3944ff9d5e8895"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/GeertJohan/go.rice"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"embedded"
|
||||||
|
]
|
||||||
|
revision = "c02ca9a983da5807ddf7d796784928f5be4afd09"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/aead/chacha20"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"chacha"
|
||||||
|
]
|
||||||
|
revision = "c8d29375923a8e1d2a0f0dc0fc1d8a0aba5b97ba"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/asdine/storm"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"codec",
|
||||||
|
"codec/json",
|
||||||
|
"index",
|
||||||
|
"internal",
|
||||||
|
"q"
|
||||||
|
]
|
||||||
|
revision = "68fc73b635f890fe7ba2f3b15ce80c85b28a744f"
|
||||||
|
version = "v2.0.2"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/bifurcation/mint"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"syntax"
|
||||||
|
]
|
||||||
|
revision = "340be3ae8c0ff8edce24cf59e7acdb1432bd5ce5"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/chaseadamsio/goorgeous"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "dcf1ef873b8987bf12596fe6951c48347986eb2f"
|
||||||
|
version = "v1.1.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/codahale/aesnicheck"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "349fcc471aaccc29cd074e1275f1a494323826cd"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/coreos/bbolt"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "583e8937c61f1af6513608ccc75c97b6abdf4ff9"
|
||||||
|
version = "v1.3.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/daaku/go.zipexe"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "a5fe2436ffcb3236e175e5149162b41cd28bd27d"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/dgrijalva/jwt-go"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"request"
|
||||||
|
]
|
||||||
|
revision = "dbeaa9332f19a944acb5736b4456cfcc02140e29"
|
||||||
|
version = "v3.1.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/dsnet/compress"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"bzip2",
|
||||||
|
"bzip2/internal/sais",
|
||||||
|
"internal",
|
||||||
|
"internal/errors",
|
||||||
|
"internal/prefix"
|
||||||
|
]
|
||||||
|
revision = "cc9eb1d7ad760af14e8f918698f745e80377af4f"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/flynn/go-shlex"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "3f9db97f856818214da2e1057f8ad84803971cff"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/fsnotify/fsnotify"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9"
|
||||||
|
version = "v1.4.7"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/gohugoio/hugo"
|
||||||
|
packages = ["parser"]
|
||||||
|
revision = "25e88ccabe9b04c42ffb43528c86743f623fac46"
|
||||||
|
version = "v0.36.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/golang/snappy"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "553a641470496b2327abcac10b36396bd98e45c9"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/gorilla/websocket"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
|
||||||
|
version = "v1.2.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/hacdias/fileutils"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "76b1c6ab906773727a1ce2f7fb22830685166f85"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/hacdias/varutils"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "82d3b57f667a756cfc4b1535951b46878881f3e1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/hashicorp/go-syslog"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "326bf4a7f709d263f964a6a96558676b103f3534"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/hashicorp/golang-lru"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"simplelru"
|
||||||
|
]
|
||||||
|
revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/hashicorp/hcl"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"hcl/ast",
|
||||||
|
"hcl/parser",
|
||||||
|
"hcl/scanner",
|
||||||
|
"hcl/strconv",
|
||||||
|
"hcl/token",
|
||||||
|
"json/parser",
|
||||||
|
"json/scanner",
|
||||||
|
"json/token"
|
||||||
|
]
|
||||||
|
revision = "23c074d0eceb2b8a5bfdbb271ab780cde70f05a8"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/kardianos/osext"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "ae77be60afb1dcacde03767a8c37337fad28ac14"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/lucas-clemente/aes12"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "cd47fb39b79f867c6e4e5cd39cf7abd799f71670"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/lucas-clemente/fnv128a"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "393af48d391698c6ae4219566bfbdfef67269997"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/lucas-clemente/quic-go"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"h2quic",
|
||||||
|
"internal/ackhandler",
|
||||||
|
"internal/congestion",
|
||||||
|
"internal/crypto",
|
||||||
|
"internal/flowcontrol",
|
||||||
|
"internal/handshake",
|
||||||
|
"internal/protocol",
|
||||||
|
"internal/utils",
|
||||||
|
"internal/wire",
|
||||||
|
"qerr"
|
||||||
|
]
|
||||||
|
revision = "30851b9a3b4e958490b476fe72adafa67641361a"
|
||||||
|
version = "v0.7.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/lucas-clemente/quic-go-certificates"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "d2f86524cced5186554df90d92529757d22c1cb6"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/magiconair/properties"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "c3beff4c2358b44d0493c7dda585e7db7ff28ae6"
|
||||||
|
version = "v1.7.6"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/mholt/archiver"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "26cf5bb32d07aa4e8d0de15f56ce516f4641d7df"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/mholt/caddy"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"caddyfile",
|
||||||
|
"caddyhttp/httpserver",
|
||||||
|
"caddyhttp/staticfiles",
|
||||||
|
"caddytls"
|
||||||
|
]
|
||||||
|
revision = "d3f338ddab9ee24b376b5c9c51e202581e2d43ba"
|
||||||
|
version = "v0.10.11"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/miekg/dns"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "5364553f1ee9cddc7ac8b62dce148309c386695b"
|
||||||
|
version = "v1.0.4"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/mitchellh/mapstructure"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "00c29f56e2386353d58c599509e8dc3801b0d716"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/nwaples/rardecode"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "e06696f847aeda6f39a8f0b7cdff193b7690aef6"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/pelletier/go-toml"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "acdc4509485b587f5e675510c4f2c63e90ff68a8"
|
||||||
|
version = "v1.1.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/pierrec/lz4"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "2fcda4cb7018ce05a25959d2fe08c83e3329f169"
|
||||||
|
version = "v1.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/pierrec/xxHash"
|
||||||
|
packages = ["xxHash32"]
|
||||||
|
revision = "f051bb7f1d1aaf1b5a665d74fb6b0217712c69f7"
|
||||||
|
version = "v0.1.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/robfig/cron"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "b024fc5ea0e34bc3f83d9941c8d60b0622bfaca4"
|
||||||
|
version = "v1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/russross/blackfriday"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "4048872b16cc0fc2c5fd9eacf0ed2c2fedaa0c8c"
|
||||||
|
version = "v1.5"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/shurcooL/sanitized_anchor_name"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "86672fcb3f950f35f2e675df2240550f2a50762f"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/spf13/afero"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"mem"
|
||||||
|
]
|
||||||
|
revision = "bb8f1927f2a9d3ab41c9340aa034f6b803f4359c"
|
||||||
|
version = "v1.0.2"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/spf13/cast"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "8965335b8c7107321228e3e3702cab9832751bac"
|
||||||
|
version = "v1.2.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/spf13/jwalterweatherman"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "7c0cea34c8ece3fbeb2b27ab9b59511d360fb394"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/spf13/pflag"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66"
|
||||||
|
version = "v1.0.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/spf13/viper"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "25b30aa063fc18e48662b86996252eabdcf2f0c7"
|
||||||
|
version = "v1.0.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/ulikunitz/xz"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"internal/hash",
|
||||||
|
"internal/xlog",
|
||||||
|
"lzma"
|
||||||
|
]
|
||||||
|
revision = "0c6b41e72360850ca4f98dc341fd999726ea007f"
|
||||||
|
version = "v0.5.4"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/xenolf/lego"
|
||||||
|
packages = ["acme"]
|
||||||
|
revision = "67c86d860a797ce2483f50d9174d4ed24984bef2"
|
||||||
|
version = "v0.4.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/crypto"
|
||||||
|
packages = [
|
||||||
|
"bcrypt",
|
||||||
|
"blowfish",
|
||||||
|
"curve25519",
|
||||||
|
"ed25519",
|
||||||
|
"ed25519/internal/edwards25519",
|
||||||
|
"hkdf",
|
||||||
|
"ocsp"
|
||||||
|
]
|
||||||
|
revision = "49796115aa4b964c318aad4f3084fdb41e9aa067"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/net"
|
||||||
|
packages = [
|
||||||
|
"bpf",
|
||||||
|
"http2",
|
||||||
|
"http2/hpack",
|
||||||
|
"idna",
|
||||||
|
"internal/iana",
|
||||||
|
"internal/socket",
|
||||||
|
"ipv4",
|
||||||
|
"ipv6",
|
||||||
|
"lex/httplex",
|
||||||
|
"publicsuffix"
|
||||||
|
]
|
||||||
|
revision = "cbe0f9307d0156177f9dd5dc85da1a31abc5f2fb"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/sys"
|
||||||
|
packages = ["unix"]
|
||||||
|
revision = "88d2dcc510266da9f7f8c7f34e1940716cab5f5c"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "golang.org/x/text"
|
||||||
|
packages = [
|
||||||
|
"collate",
|
||||||
|
"collate/build",
|
||||||
|
"internal/colltab",
|
||||||
|
"internal/gen",
|
||||||
|
"internal/tag",
|
||||||
|
"internal/triegen",
|
||||||
|
"internal/ucd",
|
||||||
|
"language",
|
||||||
|
"secure/bidirule",
|
||||||
|
"transform",
|
||||||
|
"unicode/bidi",
|
||||||
|
"unicode/cldr",
|
||||||
|
"unicode/norm",
|
||||||
|
"unicode/rangetable"
|
||||||
|
]
|
||||||
|
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
||||||
|
version = "v0.3.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "gopkg.in/natefinch/lumberjack.v2"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "a96e63847dc3c67d17befa69c303767e2f84e54f"
|
||||||
|
version = "v2.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "gopkg.in/square/go-jose.v1"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"cipher",
|
||||||
|
"json"
|
||||||
|
]
|
||||||
|
revision = "aa2e30fdd1fe9dd3394119af66451ae790d50e0d"
|
||||||
|
version = "v1.1.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "gopkg.in/yaml.v2"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "7f97868eec74b32b0982dd158a51a446d1da7eb5"
|
||||||
|
version = "v2.1.1"
|
||||||
|
|
||||||
|
[solve-meta]
|
||||||
|
analyzer-name = "dep"
|
||||||
|
analyzer-version = 1
|
||||||
|
inputs-digest = "1f68bed4490068370884abaa296aa651c27b3f2e0d0451a1ab567f059d44f820"
|
||||||
|
solver-name = "gps-cdcl"
|
||||||
|
solver-version = 1
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/GeertJohan/go.rice"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/asdine/storm"
|
||||||
|
version = "2.0.2"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/dgrijalva/jwt-go"
|
||||||
|
version = "3.1.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/gohugoio/hugo"
|
||||||
|
version = "0.36.1"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/gorilla/websocket"
|
||||||
|
version = "1.2.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/hacdias/fileutils"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/hacdias/varutils"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/mholt/archiver"
|
||||||
|
# TODO: switch to version when it's available
|
||||||
|
# this is for Archiver.Write() which was introduced in 548c791
|
||||||
|
revision = "26cf5bb32d07aa4e8d0de15f56ce516f4641d7df"
|
||||||
|
# version = "2.0.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/mholt/caddy"
|
||||||
|
version = "0.10.11"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/mitchellh/mapstructure"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/robfig/cron"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/spf13/pflag"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/spf13/viper"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/crypto"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "gopkg.in/natefinch/lumberjack.v2"
|
||||||
|
version = "2.1.0"
|
||||||
|
|
||||||
|
[[override]]
|
||||||
|
name = "github.com/russross/blackfriday"
|
||||||
|
version = "^1.0.0"
|
||||||
|
|
||||||
|
[prune]
|
||||||
|
go-tests = true
|
||||||
|
unused-packages = true
|
||||||
@@ -32,7 +32,7 @@ Listings of your files, available in two styles: mosaic and list. You can delete
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
File Manager editor is powered by [Codemirror](https://codemirror.net/) and if you're working with markdown files with metadata, both parts will be separated from each other so you can focus on the content.
|
File Browser editor is powered by [Codemirror](https://codemirror.net/) and if you're working with markdown files with metadata, both parts will be separated from each other so you can focus on the content.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@ package bolt
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/asdine/storm"
|
"github.com/asdine/storm"
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigStore is a configuration store.
|
// ConfigStore is a configuration store.
|
||||||
@@ -14,7 +14,7 @@ type ConfigStore struct {
|
|||||||
func (c ConfigStore) Get(name string, to interface{}) error {
|
func (c ConfigStore) Get(name string, to interface{}) error {
|
||||||
err := c.DB.Get("config", name, to)
|
err := c.DB.Get("config", name, to)
|
||||||
if err == storm.ErrNotFound {
|
if err == storm.ErrNotFound {
|
||||||
return fm.ErrNotExist
|
return fb.ErrNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|||||||
+15
-15
@@ -3,7 +3,7 @@ package bolt
|
|||||||
import (
|
import (
|
||||||
"github.com/asdine/storm"
|
"github.com/asdine/storm"
|
||||||
"github.com/asdine/storm/q"
|
"github.com/asdine/storm/q"
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ShareStore is a shareable links store.
|
// ShareStore is a shareable links store.
|
||||||
@@ -12,55 +12,55 @@ type ShareStore struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get gets a Share Link from an hash.
|
// Get gets a Share Link from an hash.
|
||||||
func (s ShareStore) Get(hash string) (*fm.ShareLink, error) {
|
func (s ShareStore) Get(hash string) (*fb.ShareLink, error) {
|
||||||
var v fm.ShareLink
|
var v fb.ShareLink
|
||||||
err := s.DB.One("Hash", hash, &v)
|
err := s.DB.One("Hash", hash, &v)
|
||||||
if err == storm.ErrNotFound {
|
if err == storm.ErrNotFound {
|
||||||
return nil, fm.ErrNotExist
|
return nil, fb.ErrNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
return &v, err
|
return &v, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPermanent gets the permanent link from a path.
|
// GetPermanent gets the permanent link from a path.
|
||||||
func (s ShareStore) GetPermanent(path string) (*fm.ShareLink, error) {
|
func (s ShareStore) GetPermanent(path string) (*fb.ShareLink, error) {
|
||||||
var v fm.ShareLink
|
var v fb.ShareLink
|
||||||
err := s.DB.Select(q.Eq("Path", path), q.Eq("Expires", false)).First(&v)
|
err := s.DB.Select(q.Eq("Path", path), q.Eq("Expires", false)).First(&v)
|
||||||
if err == storm.ErrNotFound {
|
if err == storm.ErrNotFound {
|
||||||
return nil, fm.ErrNotExist
|
return nil, fb.ErrNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
return &v, err
|
return &v, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetByPath gets all the links for a specific path.
|
// GetByPath gets all the links for a specific path.
|
||||||
func (s ShareStore) GetByPath(hash string) ([]*fm.ShareLink, error) {
|
func (s ShareStore) GetByPath(hash string) ([]*fb.ShareLink, error) {
|
||||||
var v []*fm.ShareLink
|
var v []*fb.ShareLink
|
||||||
err := s.DB.Find("Path", hash, &v)
|
err := s.DB.Find("Path", hash, &v)
|
||||||
if err == storm.ErrNotFound {
|
if err == storm.ErrNotFound {
|
||||||
return v, fm.ErrNotExist
|
return v, fb.ErrNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
return v, err
|
return v, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets retrieves all the shareable links.
|
// Gets retrieves all the shareable links.
|
||||||
func (s ShareStore) Gets() ([]*fm.ShareLink, error) {
|
func (s ShareStore) Gets() ([]*fb.ShareLink, error) {
|
||||||
var v []*fm.ShareLink
|
var v []*fb.ShareLink
|
||||||
err := s.DB.All(&v)
|
err := s.DB.All(&v)
|
||||||
if err == storm.ErrNotFound {
|
if err == storm.ErrNotFound {
|
||||||
return v, fm.ErrNotExist
|
return v, fb.ErrNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
return v, err
|
return v, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save stores a Share Link on the database.
|
// Save stores a Share Link on the database.
|
||||||
func (s ShareStore) Save(l *fm.ShareLink) error {
|
func (s ShareStore) Save(l *fb.ShareLink) error {
|
||||||
return s.DB.Save(l)
|
return s.DB.Save(l)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes a Share Link from the database.
|
// Delete deletes a Share Link from the database.
|
||||||
func (s ShareStore) Delete(hash string) error {
|
func (s ShareStore) Delete(hash string) error {
|
||||||
return s.DB.DeleteStruct(&fm.ShareLink{Hash: hash})
|
return s.DB.DeleteStruct(&fb.ShareLink{Hash: hash})
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,7 @@ func Parse(c *caddy.Controller, plugin string) ([]*filebrowser.FileBrowser, erro
|
|||||||
scope := "."
|
scope := "."
|
||||||
database := ""
|
database := ""
|
||||||
noAuth := false
|
noAuth := false
|
||||||
|
alterRecaptcha := false
|
||||||
reCaptchaKey := ""
|
reCaptchaKey := ""
|
||||||
reCaptchaSecret := ""
|
reCaptchaSecret := ""
|
||||||
|
|
||||||
@@ -158,6 +159,16 @@ func Parse(c *caddy.Controller, plugin string) ([]*filebrowser.FileBrowser, erro
|
|||||||
if u.ViewMode != filebrowser.MosaicViewMode && u.ViewMode != filebrowser.ListViewMode {
|
if u.ViewMode != filebrowser.MosaicViewMode && u.ViewMode != filebrowser.ListViewMode {
|
||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
}
|
}
|
||||||
|
case "alternative_recaptcha":
|
||||||
|
if !c.NextArg() {
|
||||||
|
alterRecaptcha = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
alterRecaptcha, err = strconv.ParseBool(c.Val())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
case "recaptcha_key":
|
case "recaptcha_key":
|
||||||
if !c.NextArg() {
|
if !c.NextArg() {
|
||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
@@ -227,10 +238,16 @@ func Parse(c *caddy.Controller, plugin string) ([]*filebrowser.FileBrowser, erro
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recaptchaHost := "https://www.google.com"
|
||||||
|
if alterRecaptcha {
|
||||||
|
recaptchaHost = "https://recaptcha.net"
|
||||||
|
}
|
||||||
|
|
||||||
m := &filebrowser.FileBrowser{
|
m := &filebrowser.FileBrowser{
|
||||||
NoAuth: noAuth,
|
NoAuth: noAuth,
|
||||||
BaseURL: "",
|
BaseURL: "",
|
||||||
PrefixURL: "",
|
PrefixURL: "",
|
||||||
|
ReCaptchaHost: recaptchaHost,
|
||||||
ReCaptchaKey: reCaptchaKey,
|
ReCaptchaKey: reCaptchaKey,
|
||||||
ReCaptchaSecret: reCaptchaSecret,
|
ReCaptchaSecret: reCaptchaSecret,
|
||||||
DefaultUser: u,
|
DefaultUser: u,
|
||||||
|
|||||||
+11
-1
@@ -44,6 +44,7 @@ var (
|
|||||||
allowNew bool
|
allowNew bool
|
||||||
allowPublish bool
|
allowPublish bool
|
||||||
showVer bool
|
showVer bool
|
||||||
|
alterRecaptcha bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -64,6 +65,7 @@ func init() {
|
|||||||
flag.BoolVar(&allowPublish, "allow-publish", true, "Default allow publish option for new users")
|
flag.BoolVar(&allowPublish, "allow-publish", true, "Default allow publish option for new users")
|
||||||
flag.BoolVar(&allowNew, "allow-new", true, "Default allow new option for new users")
|
flag.BoolVar(&allowNew, "allow-new", true, "Default allow new option for new users")
|
||||||
flag.BoolVar(&noAuth, "no-auth", false, "Disables authentication")
|
flag.BoolVar(&noAuth, "no-auth", false, "Disables authentication")
|
||||||
|
flag.BoolVar(&alterRecaptcha, "alternative-recaptcha", false, "Use recaptcha.net for serving and handling, useful in China")
|
||||||
flag.StringVar(&locale, "locale", "", "Default locale for new users, set it empty to enable auto detect from browser")
|
flag.StringVar(&locale, "locale", "", "Default locale for new users, set it empty to enable auto detect from browser")
|
||||||
flag.StringVar(&staticg, "staticgen", "", "Static Generator you want to enable")
|
flag.StringVar(&staticg, "staticgen", "", "Static Generator you want to enable")
|
||||||
flag.BoolVarP(&showVer, "version", "v", false, "Show version")
|
flag.BoolVarP(&showVer, "version", "v", false, "Show version")
|
||||||
@@ -86,6 +88,7 @@ func setupViper() {
|
|||||||
viper.SetDefault("BaseURL", "")
|
viper.SetDefault("BaseURL", "")
|
||||||
viper.SetDefault("PrefixURL", "")
|
viper.SetDefault("PrefixURL", "")
|
||||||
viper.SetDefault("ViewMode", filebrowser.MosaicViewMode)
|
viper.SetDefault("ViewMode", filebrowser.MosaicViewMode)
|
||||||
|
viper.SetDefault("AlternativeRecaptcha", false)
|
||||||
viper.SetDefault("ReCaptchaKey", "")
|
viper.SetDefault("ReCaptchaKey", "")
|
||||||
viper.SetDefault("ReCaptchaSecret", "")
|
viper.SetDefault("ReCaptchaSecret", "")
|
||||||
|
|
||||||
@@ -97,7 +100,7 @@ func setupViper() {
|
|||||||
viper.BindPFlag("Commands", flag.Lookup("commands"))
|
viper.BindPFlag("Commands", flag.Lookup("commands"))
|
||||||
viper.BindPFlag("AllowCommands", flag.Lookup("allow-commands"))
|
viper.BindPFlag("AllowCommands", flag.Lookup("allow-commands"))
|
||||||
viper.BindPFlag("AllowEdit", flag.Lookup("allow-edit"))
|
viper.BindPFlag("AllowEdit", flag.Lookup("allow-edit"))
|
||||||
viper.BindPFlag("AlowNew", flag.Lookup("allow-new"))
|
viper.BindPFlag("AllowNew", flag.Lookup("allow-new"))
|
||||||
viper.BindPFlag("AllowPublish", flag.Lookup("allow-publish"))
|
viper.BindPFlag("AllowPublish", flag.Lookup("allow-publish"))
|
||||||
viper.BindPFlag("Locale", flag.Lookup("locale"))
|
viper.BindPFlag("Locale", flag.Lookup("locale"))
|
||||||
viper.BindPFlag("StaticGen", flag.Lookup("staticgen"))
|
viper.BindPFlag("StaticGen", flag.Lookup("staticgen"))
|
||||||
@@ -105,6 +108,7 @@ func setupViper() {
|
|||||||
viper.BindPFlag("BaseURL", flag.Lookup("baseurl"))
|
viper.BindPFlag("BaseURL", flag.Lookup("baseurl"))
|
||||||
viper.BindPFlag("PrefixURL", flag.Lookup("prefixurl"))
|
viper.BindPFlag("PrefixURL", flag.Lookup("prefixurl"))
|
||||||
viper.BindPFlag("ViewMode", flag.Lookup("view-mode"))
|
viper.BindPFlag("ViewMode", flag.Lookup("view-mode"))
|
||||||
|
viper.BindPFlag("AlternativeRecaptcha", flag.Lookup("alternative-recaptcha"))
|
||||||
viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key"))
|
viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key"))
|
||||||
viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret"))
|
viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret"))
|
||||||
|
|
||||||
@@ -186,10 +190,16 @@ func handler() http.Handler {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recaptchaHost := "https://www.google.com"
|
||||||
|
if viper.GetBool("AlternativeRecaptcha") {
|
||||||
|
recaptchaHost = "https://recaptcha.net"
|
||||||
|
}
|
||||||
|
|
||||||
fm := &filebrowser.FileBrowser{
|
fm := &filebrowser.FileBrowser{
|
||||||
NoAuth: viper.GetBool("NoAuth"),
|
NoAuth: viper.GetBool("NoAuth"),
|
||||||
BaseURL: viper.GetString("BaseURL"),
|
BaseURL: viper.GetString("BaseURL"),
|
||||||
PrefixURL: viper.GetString("PrefixURL"),
|
PrefixURL: viper.GetString("PrefixURL"),
|
||||||
|
ReCaptchaHost: recaptchaHost,
|
||||||
ReCaptchaKey: viper.GetString("ReCaptchaKey"),
|
ReCaptchaKey: viper.GetString("ReCaptchaKey"),
|
||||||
ReCaptchaSecret: viper.GetString("ReCaptchaSecret"),
|
ReCaptchaSecret: viper.GetString("ReCaptchaSecret"),
|
||||||
DefaultUser: &filebrowser.User{
|
DefaultUser: &filebrowser.User{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Package filebrowser provides a web interface to access your files
|
Package filebrowser provides a web interface to access your files
|
||||||
wherever you are. To use this package as a middleware for your app,
|
wherever you are. To use this package as a middleware for your app,
|
||||||
you'll need to import both File Manager and File Manager HTTP packages.
|
you'll need to import both File Browser and File Browser HTTP packages.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fm "github.com/filebrowser/filebrowser"
|
||||||
@@ -49,11 +49,11 @@ functions:
|
|||||||
m.SetPrefixURL("/")
|
m.SetPrefixURL("/")
|
||||||
|
|
||||||
The Prefix URL is a part of the path that is already stripped from the
|
The Prefix URL is a part of the path that is already stripped from the
|
||||||
r.URL.Path variable before the request arrives to File Manager's handler.
|
r.URL.Path variable before the request arrives to File Browser's handler.
|
||||||
This is a function that will rarely be used. You can see one example on Caddy
|
This is a function that will rarely be used. You can see one example on Caddy
|
||||||
filemanager plugin.
|
filemanager plugin.
|
||||||
|
|
||||||
The Base URL is the URL path where you want File Manager to be available in. If
|
The Base URL is the URL path where you want File Browser to be available in. If
|
||||||
you want to be available at the root path, you should call:
|
you want to be available at the root path, you should call:
|
||||||
|
|
||||||
m.SetBaseURL("/")
|
m.SetBaseURL("/")
|
||||||
@@ -62,7 +62,7 @@ But if you want to access it at '/admin', you would call:
|
|||||||
|
|
||||||
m.SetBaseURL("/admin")
|
m.SetBaseURL("/admin")
|
||||||
|
|
||||||
Now, that you already have a File Manager instance created, you just need to
|
Now, that you already have a File Browser instance created, you just need to
|
||||||
add it to your handlers using m.ServeHTTP which is compatible to http.Handler.
|
add it to your handlers using m.ServeHTTP which is compatible to http.Handler.
|
||||||
We also have a m.ServeWithErrorsHTTP that returns the status code and an error.
|
We also have a m.ServeWithErrorsHTTP that returns the status code and an error.
|
||||||
|
|
||||||
|
|||||||
@@ -134,13 +134,12 @@ func (i *File) GetListing(u *User, r *http.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(f.Mode().String(), "L") {
|
if strings.HasPrefix(f.Mode().String(), "L") {
|
||||||
// It's a symbolic link
|
// It's a symbolic link. We try to follow it. If it doesn't work,
|
||||||
// The FileInfo from Readdir treats symbolic link as a file only.
|
// we stay with the link information instead if the target's.
|
||||||
info, err := os.Stat(f.Name())
|
info, err := os.Stat(f.Name())
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return err
|
f = info
|
||||||
}
|
}
|
||||||
f = info
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
|
|||||||
+11
-10
@@ -22,8 +22,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Version is the current File Manager version.
|
// Version is the current File Browser version.
|
||||||
Version = "1.5.2"
|
Version = "1.7.1"
|
||||||
|
|
||||||
ListViewMode = "list"
|
ListViewMode = "list"
|
||||||
MosaicViewMode = "mosaic"
|
MosaicViewMode = "mosaic"
|
||||||
@@ -58,7 +58,7 @@ type FileBrowser struct {
|
|||||||
Store *Store
|
Store *Store
|
||||||
|
|
||||||
// PrefixURL is a part of the URL that is already trimmed from the request URL before it
|
// PrefixURL is a part of the URL that is already trimmed from the request URL before it
|
||||||
// arrives to our handlers. It may be useful when using File Manager as a middleware
|
// arrives to our handlers. It may be useful when using File Browser as a middleware
|
||||||
// such as in caddy-filemanager plugin. It is only useful in certain situations.
|
// such as in caddy-filemanager plugin. It is only useful in certain situations.
|
||||||
PrefixURL string
|
PrefixURL string
|
||||||
|
|
||||||
@@ -71,7 +71,8 @@ type FileBrowser struct {
|
|||||||
// there will only exist one user, called "admin".
|
// there will only exist one user, called "admin".
|
||||||
NoAuth bool
|
NoAuth bool
|
||||||
|
|
||||||
// ReCaptcha Site key and secret.
|
// ReCaptcha host, key and secret.
|
||||||
|
ReCaptchaHost string
|
||||||
ReCaptchaKey string
|
ReCaptchaKey string
|
||||||
ReCaptchaSecret string
|
ReCaptchaSecret string
|
||||||
|
|
||||||
@@ -114,9 +115,9 @@ type FSBuilder func(scope string) FileSystem
|
|||||||
|
|
||||||
// Setup loads the configuration from the database and configures
|
// Setup loads the configuration from the database and configures
|
||||||
// the Assets and the Cron job. It must always be run after
|
// the Assets and the Cron job. It must always be run after
|
||||||
// creating a File Manager object.
|
// creating a File Browser object.
|
||||||
func (m *FileBrowser) Setup() error {
|
func (m *FileBrowser) Setup() error {
|
||||||
// Creates a new File Manager instance with the Users
|
// Creates a new File Browser instance with the Users
|
||||||
// map and Assets box.
|
// map and Assets box.
|
||||||
m.Assets = rice.MustFindBox("./node_modules/filebrowser-frontend/dist")
|
m.Assets = rice.MustFindBox("./node_modules/filebrowser-frontend/dist")
|
||||||
m.Cron = cron.New()
|
m.Cron = cron.New()
|
||||||
@@ -220,7 +221,7 @@ func (m *FileBrowser) Setup() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RootURL returns the actual URL where
|
// RootURL returns the actual URL where
|
||||||
// File Manager interface can be accessed.
|
// File Browser interface can be accessed.
|
||||||
func (m FileBrowser) RootURL() string {
|
func (m FileBrowser) RootURL() string {
|
||||||
return m.PrefixURL + m.BaseURL
|
return m.PrefixURL + m.BaseURL
|
||||||
}
|
}
|
||||||
@@ -234,7 +235,7 @@ func (m *FileBrowser) SetPrefixURL(url string) {
|
|||||||
m.PrefixURL = strings.TrimSuffix(url, "/")
|
m.PrefixURL = strings.TrimSuffix(url, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetBaseURL updates the baseURL of a File Manager
|
// SetBaseURL updates the baseURL of a File Browser
|
||||||
// object.
|
// object.
|
||||||
func (m *FileBrowser) SetBaseURL(url string) {
|
func (m *FileBrowser) SetBaseURL(url string) {
|
||||||
url = strings.TrimPrefix(url, "/")
|
url = strings.TrimPrefix(url, "/")
|
||||||
@@ -243,7 +244,7 @@ func (m *FileBrowser) SetBaseURL(url string) {
|
|||||||
m.BaseURL = strings.TrimSuffix(url, "/")
|
m.BaseURL = strings.TrimSuffix(url, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach attaches a static generator to the current File Manager.
|
// Attach attaches a static generator to the current File Browser.
|
||||||
func (m *FileBrowser) Attach(s StaticGen) error {
|
func (m *FileBrowser) Attach(s StaticGen) error {
|
||||||
if reflect.TypeOf(s).Kind() != reflect.Ptr {
|
if reflect.TypeOf(s).Kind() != reflect.Ptr {
|
||||||
return errors.New("data should be a pointer to interface, not interface")
|
return errors.New("data should be a pointer to interface, not interface")
|
||||||
@@ -289,7 +290,7 @@ func (m FileBrowser) ShareCleaner() {
|
|||||||
func (m FileBrowser) Runner(event string, path string, destination string, user *User) error {
|
func (m FileBrowser) Runner(event string, path string, destination string, user *User) error {
|
||||||
commands := []string{}
|
commands := []string{}
|
||||||
|
|
||||||
// Get the commands from the File Manager instance itself.
|
// Get the commands from the File Browser instance itself.
|
||||||
if val, ok := m.Commands[event]; ok {
|
if val, ok := m.Commands[event]; ok {
|
||||||
commands = append(commands, val...)
|
commands = append(commands, val...)
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -9,10 +9,10 @@ import (
|
|||||||
|
|
||||||
"github.com/dgrijalva/jwt-go"
|
"github.com/dgrijalva/jwt-go"
|
||||||
"github.com/dgrijalva/jwt-go/request"
|
"github.com/dgrijalva/jwt-go/request"
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
)
|
)
|
||||||
|
|
||||||
const reCaptchaAPI = "https://www.google.com/recaptcha/api/siteverify"
|
const reCaptchaAPI = "/recaptcha/api/siteverify"
|
||||||
|
|
||||||
type cred struct {
|
type cred struct {
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
@@ -21,14 +21,14 @@ type cred struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reCaptcha checks the reCaptcha code.
|
// reCaptcha checks the reCaptcha code.
|
||||||
func reCaptcha(secret string, response string) (bool, error) {
|
func reCaptcha(host, secret, response string) (bool, error) {
|
||||||
body := url.Values{}
|
body := url.Values{}
|
||||||
body.Set("secret", secret)
|
body.Set("secret", secret)
|
||||||
body.Add("response", response)
|
body.Add("response", response)
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
resp, err := client.Post(reCaptchaAPI, "application/x-www-form-urlencoded", strings.NewReader(body.Encode()))
|
resp, err := client.Post(host+reCaptchaAPI, "application/x-www-form-urlencoded", strings.NewReader(body.Encode()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ func reCaptcha(secret string, response string) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// authHandler processes the authentication for the user.
|
// authHandler processes the authentication for the user.
|
||||||
func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func authHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// NoAuth instances shouldn't call this method.
|
// NoAuth instances shouldn't call this method.
|
||||||
if c.NoAuth {
|
if c.NoAuth {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
@@ -69,7 +69,7 @@ func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, er
|
|||||||
|
|
||||||
// If ReCaptcha is enabled, check the code.
|
// If ReCaptcha is enabled, check the code.
|
||||||
if len(c.ReCaptchaSecret) > 0 {
|
if len(c.ReCaptchaSecret) > 0 {
|
||||||
ok, err := reCaptcha(c.ReCaptchaSecret, cred.ReCaptcha)
|
ok, err := reCaptcha(c.ReCaptchaHost, c.ReCaptchaSecret, cred.ReCaptcha)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusForbidden, err
|
return http.StatusForbidden, err
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the password is correct.
|
// Checks if the password is correct.
|
||||||
if !fm.CheckPasswordHash(cred.Password, u.Password) {
|
if !fb.CheckPasswordHash(cred.Password, u.Password) {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, er
|
|||||||
|
|
||||||
// renewAuthHandler is used when the front-end already has a JWT token
|
// renewAuthHandler is used when the front-end already has a JWT token
|
||||||
// and is checking if it is up to date. If so, updates its info.
|
// and is checking if it is up to date. If so, updates its info.
|
||||||
func renewAuthHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func renewAuthHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
ok, u := validateAuth(c, r)
|
ok, u := validateAuth(c, r)
|
||||||
if !ok {
|
if !ok {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
@@ -108,15 +108,15 @@ func renewAuthHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
|
|
||||||
// claims is the JWT claims.
|
// claims is the JWT claims.
|
||||||
type claims struct {
|
type claims struct {
|
||||||
fm.User
|
fb.User
|
||||||
jwt.StandardClaims
|
jwt.StandardClaims
|
||||||
}
|
}
|
||||||
|
|
||||||
// printToken prints the final JWT token to the user.
|
// printToken prints the final JWT token to the user.
|
||||||
func printToken(c *fm.Context, w http.ResponseWriter) (int, error) {
|
func printToken(c *fb.Context, w http.ResponseWriter) (int, error) {
|
||||||
// Creates a copy of the user and removes it password
|
// Creates a copy of the user and removes it password
|
||||||
// hash so it never arrives to the user.
|
// hash so it never arrives to the user.
|
||||||
u := fm.User{}
|
u := fb.User{}
|
||||||
u = *c.User
|
u = *c.User
|
||||||
u.Password = ""
|
u.Password = ""
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ func printToken(c *fm.Context, w http.ResponseWriter) (int, error) {
|
|||||||
u,
|
u,
|
||||||
jwt.StandardClaims{
|
jwt.StandardClaims{
|
||||||
ExpiresAt: time.Now().Add(time.Hour * 24).Unix(),
|
ExpiresAt: time.Now().Add(time.Hour * 24).Unix(),
|
||||||
Issuer: "File Manager",
|
Issuer: "File Browser",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ func (e extractor) ExtractToken(r *http.Request) (string, error) {
|
|||||||
|
|
||||||
// validateAuth is used to validate the authentication and returns the
|
// validateAuth is used to validate the authentication and returns the
|
||||||
// User if it is valid.
|
// User if it is valid.
|
||||||
func validateAuth(c *fm.Context, r *http.Request) (bool, *fm.User) {
|
func validateAuth(c *fb.Context, r *http.Request) (bool, *fb.User) {
|
||||||
if c.NoAuth {
|
if c.NoAuth {
|
||||||
c.User = c.DefaultUser
|
c.User = c.DefaultUser
|
||||||
return true, c.User
|
return true, c.User
|
||||||
|
|||||||
+3
-3
@@ -7,14 +7,14 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
"github.com/hacdias/fileutils"
|
"github.com/hacdias/fileutils"
|
||||||
"github.com/mholt/archiver"
|
"github.com/mholt/archiver"
|
||||||
)
|
)
|
||||||
|
|
||||||
// downloadHandler creates an archive in one of the supported formats (zip, tar,
|
// downloadHandler creates an archive in one of the supported formats (zip, tar,
|
||||||
// tar.gz or tar.bz2) and sends it to be downloaded.
|
// tar.gz or tar.bz2) and sends it to be downloaded.
|
||||||
func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func downloadHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// If the file isn't a directory, serve it using http.ServeFile. We display it
|
// If the file isn't a directory, serve it using http.ServeFile. We display it
|
||||||
// inline if it is requested.
|
// inline if it is requested.
|
||||||
if !c.File.IsDir {
|
if !c.File.IsDir {
|
||||||
@@ -77,7 +77,7 @@ func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func downloadFileHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func downloadFileHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
file, err := os.Open(c.File.Path)
|
file, err := os.Open(c.File.Path)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
|||||||
+21
-20
@@ -10,13 +10,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Handler returns a function compatible with http.HandleFunc.
|
// Handler returns a function compatible with http.HandleFunc.
|
||||||
func Handler(m *fm.FileBrowser) http.Handler {
|
func Handler(m *fb.FileBrowser) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
code, err := serve(&fm.Context{
|
code, err := serve(&fb.Context{
|
||||||
FileBrowser: m,
|
FileBrowser: m,
|
||||||
User: nil,
|
User: nil,
|
||||||
File: nil,
|
File: nil,
|
||||||
@@ -37,9 +37,9 @@ func Handler(m *fm.FileBrowser) http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// serve is the main entry point of this HTML application.
|
// serve is the main entry point of this HTML application.
|
||||||
func serve(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func serve(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Checks if the URL contains the baseURL and strips it. Otherwise, it just
|
// Checks if the URL contains the baseURL and strips it. Otherwise, it just
|
||||||
// returns a 404 fm.Error because we're not supposed to be here!
|
// returns a 404 fb.Error because we're not supposed to be here!
|
||||||
p := strings.TrimPrefix(r.URL.Path, c.BaseURL)
|
p := strings.TrimPrefix(r.URL.Path, c.BaseURL)
|
||||||
|
|
||||||
if len(p) >= len(r.URL.Path) && c.BaseURL != "" {
|
if len(p) >= len(r.URL.Path) && c.BaseURL != "" {
|
||||||
@@ -93,7 +93,7 @@ func serve(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// staticHandler handles the static assets path.
|
// staticHandler handles the static assets path.
|
||||||
func staticHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func staticHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if r.URL.Path != "/static/manifest.json" {
|
if r.URL.Path != "/static/manifest.json" {
|
||||||
http.FileServer(c.Assets.HTTPBox()).ServeHTTP(w, r)
|
http.FileServer(c.Assets.HTTPBox()).ServeHTTP(w, r)
|
||||||
return 0, nil
|
return 0, nil
|
||||||
@@ -103,7 +103,7 @@ func staticHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// apiHandler is the main entry point for the /api endpoint.
|
// apiHandler is the main entry point for the /api endpoint.
|
||||||
func apiHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func apiHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if r.URL.Path == "/auth/get" {
|
if r.URL.Path == "/auth/get" {
|
||||||
return authHandler(c, w, r)
|
return authHandler(c, w, r)
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ func apiHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, err
|
|||||||
|
|
||||||
if c.Router == "checksum" || c.Router == "download" {
|
if c.Router == "checksum" || c.Router == "download" {
|
||||||
var err error
|
var err error
|
||||||
c.File, err = fm.GetInfo(r.URL, c.FileBrowser, c.User)
|
c.File, err = fb.GetInfo(r.URL, c.FileBrowser, c.User)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrorToHTTP(err, false), err
|
return ErrorToHTTP(err, false), err
|
||||||
}
|
}
|
||||||
@@ -173,11 +173,11 @@ func apiHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// serveChecksum calculates the hash of a file. Supports MD5, SHA1, SHA256 and SHA512.
|
// serveChecksum calculates the hash of a file. Supports MD5, SHA1, SHA256 and SHA512.
|
||||||
func checksumHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func checksumHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
query := r.URL.Query().Get("algo")
|
query := r.URL.Query().Get("algo")
|
||||||
|
|
||||||
val, err := c.File.Checksum(query)
|
val, err := c.File.Checksum(query)
|
||||||
if err == fm.ErrInvalidOption {
|
if err == fb.ErrInvalidOption {
|
||||||
return http.StatusBadRequest, err
|
return http.StatusBadRequest, err
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
@@ -205,7 +205,7 @@ func splitURL(path string) (string, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// renderFile renders a file using a template with some needed variables.
|
// renderFile renders a file using a template with some needed variables.
|
||||||
func renderFile(c *fm.Context, w http.ResponseWriter, file string) (int, error) {
|
func renderFile(c *fb.Context, w http.ResponseWriter, file string) (int, error) {
|
||||||
tpl := template.Must(template.New("file").Parse(c.Assets.MustString(file)))
|
tpl := template.Must(template.New("file").Parse(c.Assets.MustString(file)))
|
||||||
|
|
||||||
var contentType string
|
var contentType string
|
||||||
@@ -223,12 +223,13 @@ func renderFile(c *fm.Context, w http.ResponseWriter, file string) (int, error)
|
|||||||
w.Header().Set("Content-Type", contentType+"; charset=utf-8")
|
w.Header().Set("Content-Type", contentType+"; charset=utf-8")
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"BaseURL": c.RootURL(),
|
"BaseURL": c.RootURL(),
|
||||||
"NoAuth": c.NoAuth,
|
"NoAuth": c.NoAuth,
|
||||||
"Version": fm.Version,
|
"Version": fb.Version,
|
||||||
"CSS": template.CSS(c.CSS),
|
"CSS": template.CSS(c.CSS),
|
||||||
"ReCaptcha": c.ReCaptchaKey != "" && c.ReCaptchaSecret != "",
|
"ReCaptcha": c.ReCaptchaKey != "" && c.ReCaptchaSecret != "",
|
||||||
"ReCaptchaKey": c.ReCaptchaKey,
|
"ReCaptchaHost": c.ReCaptchaHost,
|
||||||
|
"ReCaptchaKey": c.ReCaptchaKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.StaticGen != nil {
|
if c.StaticGen != nil {
|
||||||
@@ -245,9 +246,9 @@ func renderFile(c *fm.Context, w http.ResponseWriter, file string) (int, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sharePage build the share page.
|
// sharePage build the share page.
|
||||||
func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func sharePage(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
s, err := c.Store.Share.Get(r.URL.Path)
|
s, err := c.Store.Share.Get(r.URL.Path)
|
||||||
if err == fm.ErrNotExist {
|
if err == fb.ErrNotExist {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return renderFile(c, w, "static/share/404.html")
|
return renderFile(c, w, "static/share/404.html")
|
||||||
}
|
}
|
||||||
@@ -270,7 +271,7 @@ func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, erro
|
|||||||
return ErrorToHTTP(err, false), err
|
return ErrorToHTTP(err, false), err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.File = &fm.File{
|
c.File = &fb.File{
|
||||||
Path: s.Path,
|
Path: s.Path,
|
||||||
Name: info.Name(),
|
Name: info.Name(),
|
||||||
ModTime: info.ModTime(),
|
ModTime: info.ModTime(),
|
||||||
|
|||||||
+10
-10
@@ -13,7 +13,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
"github.com/hacdias/fileutils"
|
"github.com/hacdias/fileutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ func sanitizeURL(url string) string {
|
|||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func resourceHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
r.URL.Path = sanitizeURL(r.URL.Path)
|
r.URL.Path = sanitizeURL(r.URL.Path)
|
||||||
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
@@ -62,9 +62,9 @@ func resourceHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
return http.StatusNotImplemented, nil
|
return http.StatusNotImplemented, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func resourceGetHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Gets the information of the directory/file.
|
// Gets the information of the directory/file.
|
||||||
f, err := fm.GetInfo(r.URL, c.FileBrowser, c.User)
|
f, err := fb.GetInfo(r.URL, c.FileBrowser, c.User)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrorToHTTP(err, false), err
|
return ErrorToHTTP(err, false), err
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ func resourceGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
|||||||
return renderJSON(w, f)
|
return renderJSON(w, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func listingHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func listingHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
f := c.File
|
f := c.File
|
||||||
f.Kind = "listing"
|
f.Kind = "listing"
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ func listingHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int,
|
|||||||
return renderJSON(w, f)
|
return renderJSON(w, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func resourceDeleteHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Prevent the removal of the root directory.
|
// Prevent the removal of the root directory.
|
||||||
if r.URL.Path == "/" || !c.User.AllowEdit {
|
if r.URL.Path == "/" || !c.User.AllowEdit {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
@@ -158,7 +158,7 @@ func resourceDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request
|
|||||||
return http.StatusOK, nil
|
return http.StatusOK, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourcePostPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func resourcePostPutHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if !c.User.AllowNew && r.Method == http.MethodPost {
|
if !c.User.AllowNew && r.Method == http.MethodPost {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ func resourcePostPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Reques
|
|||||||
return http.StatusOK, nil
|
return http.StatusOK, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourcePublishSchedule(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func resourcePublishSchedule(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
publish := r.Header.Get("Publish")
|
publish := r.Header.Get("Publish")
|
||||||
schedule := r.Header.Get("Schedule")
|
schedule := r.Header.Get("Schedule")
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ func resourcePublishSchedule(c *fm.Context, w http.ResponseWriter, r *http.Reque
|
|||||||
return http.StatusOK, nil
|
return http.StatusOK, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourcePublish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func resourcePublish(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
path := filepath.Join(c.User.Scope, r.URL.Path)
|
path := filepath.Join(c.User.Scope, r.URL.Path)
|
||||||
|
|
||||||
// Before save command handler.
|
// Before save command handler.
|
||||||
@@ -293,7 +293,7 @@ func resourcePublish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// resourcePatchHandler is the entry point for resource handler.
|
// resourcePatchHandler is the entry point for resource handler.
|
||||||
func resourcePatchHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func resourcePatchHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if !c.User.AllowEdit {
|
if !c.User.AllowEdit {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -6,12 +6,12 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
|
|
||||||
type modifySettingsRequest struct {
|
type modifySettingsRequest struct {
|
||||||
*modifyRequest
|
modifyRequest
|
||||||
Data struct {
|
Data struct {
|
||||||
CSS string `json:"css"`
|
CSS string `json:"css"`
|
||||||
Commands map[string][]string `json:"commands"`
|
Commands map[string][]string `json:"commands"`
|
||||||
@@ -28,7 +28,7 @@ type option struct {
|
|||||||
func parsePutSettingsRequest(r *http.Request) (*modifySettingsRequest, error) {
|
func parsePutSettingsRequest(r *http.Request) (*modifySettingsRequest, error) {
|
||||||
// Checks if the request body is empty.
|
// Checks if the request body is empty.
|
||||||
if r.Body == nil {
|
if r.Body == nil {
|
||||||
return nil, fm.ErrEmptyRequest
|
return nil, fb.ErrEmptyRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses the request body and checks if it's well formed.
|
// Parses the request body and checks if it's well formed.
|
||||||
@@ -40,13 +40,13 @@ func parsePutSettingsRequest(r *http.Request) (*modifySettingsRequest, error) {
|
|||||||
|
|
||||||
// Checks if the request type is right.
|
// Checks if the request type is right.
|
||||||
if mod.What != "settings" {
|
if mod.What != "settings" {
|
||||||
return nil, fm.ErrWrongDataType
|
return nil, fb.ErrWrongDataType
|
||||||
}
|
}
|
||||||
|
|
||||||
return mod, nil
|
return mod, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func settingsHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func settingsHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if r.URL.Path != "" && r.URL.Path != "/" {
|
if r.URL.Path != "" && r.URL.Path != "/" {
|
||||||
return http.StatusNotFound, nil
|
return http.StatusNotFound, nil
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ type settingsGetRequest struct {
|
|||||||
StaticGen []option `json:"staticGen"`
|
StaticGen []option `json:"staticGen"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func settingsGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func settingsGetHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if !c.User.Admin {
|
if !c.User.Admin {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ func settingsGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
|||||||
return renderJSON(w, result)
|
return renderJSON(w, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func settingsPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func settingsPutHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if !c.User.Admin {
|
if !c.User.Admin {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -1,17 +1,17 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/base64"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
)
|
)
|
||||||
|
|
||||||
func shareHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func shareHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
r.URL.Path = sanitizeURL(r.URL.Path)
|
r.URL.Path = sanitizeURL(r.URL.Path)
|
||||||
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
@@ -26,10 +26,10 @@ func shareHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, e
|
|||||||
return http.StatusNotImplemented, nil
|
return http.StatusNotImplemented, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func shareGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func shareGetHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
path := filepath.Join(c.User.Scope, r.URL.Path)
|
path := filepath.Join(c.User.Scope, r.URL.Path)
|
||||||
s, err := c.Store.Share.GetByPath(path)
|
s, err := c.Store.Share.GetByPath(path)
|
||||||
if err == fm.ErrNotExist {
|
if err == fb.ErrNotExist {
|
||||||
return http.StatusNotFound, nil
|
return http.StatusNotFound, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,10 +51,10 @@ func shareGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
return renderJSON(w, s)
|
return renderJSON(w, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func sharePostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func sharePostHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
path := filepath.Join(c.User.Scope, r.URL.Path)
|
path := filepath.Join(c.User.Scope, r.URL.Path)
|
||||||
|
|
||||||
var s *fm.ShareLink
|
var s *fb.ShareLink
|
||||||
expire := r.URL.Query().Get("expires")
|
expire := r.URL.Query().Get("expires")
|
||||||
unit := r.URL.Query().Get("unit")
|
unit := r.URL.Query().Get("unit")
|
||||||
|
|
||||||
@@ -67,14 +67,14 @@ func sharePostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes, err := fm.GenerateRandomBytes(32)
|
bytes, err := fb.GenerateRandomBytes(6)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
str := hex.EncodeToString(bytes)
|
str := base64.URLEncoding.EncodeToString(bytes)
|
||||||
|
|
||||||
s = &fm.ShareLink{
|
s = &fb.ShareLink{
|
||||||
Path: path,
|
Path: path,
|
||||||
Hash: str,
|
Hash: str,
|
||||||
Expires: expire != "",
|
Expires: expire != "",
|
||||||
@@ -108,9 +108,9 @@ func sharePostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
return renderJSON(w, s)
|
return renderJSON(w, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func shareDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func shareDeleteHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
s, err := c.Store.Share.Get(strings.TrimPrefix(r.URL.Path, "/"))
|
s, err := c.Store.Share.Get(strings.TrimPrefix(r.URL.Path, "/"))
|
||||||
if err == fm.ErrNotExist {
|
if err == fb.ErrNotExist {
|
||||||
return http.StatusNotFound, nil
|
return http.StatusNotFound, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+31
-31
@@ -9,7 +9,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
)
|
)
|
||||||
|
|
||||||
type modifyRequest struct {
|
type modifyRequest struct {
|
||||||
@@ -18,13 +18,13 @@ type modifyRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type modifyUserRequest struct {
|
type modifyUserRequest struct {
|
||||||
*modifyRequest
|
modifyRequest
|
||||||
Data *fm.User `json:"data"`
|
Data *fb.User `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// usersHandler is the entry point of the users API. It's just a router
|
// usersHandler is the entry point of the users API. It's just a router
|
||||||
// to send the request to its
|
// to send the request to its
|
||||||
func usersHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func usersHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// If the user isn't admin and isn't making a PUT
|
// If the user isn't admin and isn't making a PUT
|
||||||
// request, then return forbidden.
|
// request, then return forbidden.
|
||||||
if !c.User.Admin && r.Method != http.MethodPut {
|
if !c.User.Admin && r.Method != http.MethodPut {
|
||||||
@@ -47,7 +47,7 @@ func usersHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, e
|
|||||||
|
|
||||||
// getUserID returns the id from the user which is present
|
// getUserID returns the id from the user which is present
|
||||||
// in the request url. If the url is invalid and doesn't
|
// in the request url. If the url is invalid and doesn't
|
||||||
// contain a valid ID, it returns an fm.Error.
|
// contain a valid ID, it returns an fb.Error.
|
||||||
func getUserID(r *http.Request) (int, error) {
|
func getUserID(r *http.Request) (int, error) {
|
||||||
// Obtains the ID in string from the URL and converts
|
// Obtains the ID in string from the URL and converts
|
||||||
// it into an integer.
|
// it into an integer.
|
||||||
@@ -63,11 +63,11 @@ func getUserID(r *http.Request) (int, error) {
|
|||||||
|
|
||||||
// getUser returns the user which is present in the request
|
// getUser returns the user which is present in the request
|
||||||
// body. If the body is empty or the JSON is invalid, it
|
// body. If the body is empty or the JSON is invalid, it
|
||||||
// returns an fm.Error.
|
// returns an fb.Error.
|
||||||
func getUser(c *fm.Context, r *http.Request) (*fm.User, string, error) {
|
func getUser(c *fb.Context, r *http.Request) (*fb.User, string, error) {
|
||||||
// Checks if the request body is empty.
|
// Checks if the request body is empty.
|
||||||
if r.Body == nil {
|
if r.Body == nil {
|
||||||
return nil, "", fm.ErrEmptyRequest
|
return nil, "", fb.ErrEmptyRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses the request body and checks if it's well formed.
|
// Parses the request body and checks if it's well formed.
|
||||||
@@ -79,14 +79,14 @@ func getUser(c *fm.Context, r *http.Request) (*fm.User, string, error) {
|
|||||||
|
|
||||||
// Checks if the request type is right.
|
// Checks if the request type is right.
|
||||||
if mod.What != "user" {
|
if mod.What != "user" {
|
||||||
return nil, "", fm.ErrWrongDataType
|
return nil, "", fb.ErrWrongDataType
|
||||||
}
|
}
|
||||||
|
|
||||||
mod.Data.FileSystem = c.NewFS(mod.Data.Scope)
|
mod.Data.FileSystem = c.NewFS(mod.Data.Scope)
|
||||||
return mod.Data, mod.Which, nil
|
return mod.Data, mod.Which, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func usersGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func usersGetHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Request for the default user data.
|
// Request for the default user data.
|
||||||
if r.URL.Path == "/base" {
|
if r.URL.Path == "/base" {
|
||||||
return renderJSON(w, c.DefaultUser)
|
return renderJSON(w, c.DefaultUser)
|
||||||
@@ -118,7 +118,7 @@ func usersGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
}
|
}
|
||||||
|
|
||||||
u, err := c.Store.Users.Get(id, c.NewFS)
|
u, err := c.Store.Users.Get(id, c.NewFS)
|
||||||
if err == fm.ErrExist {
|
if err == fb.ErrExist {
|
||||||
return http.StatusNotFound, err
|
return http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ func usersGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
return renderJSON(w, u)
|
return renderJSON(w, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func usersPostHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if r.URL.Path != "/" {
|
if r.URL.Path != "/" {
|
||||||
return http.StatusMethodNotAllowed, nil
|
return http.StatusMethodNotAllowed, nil
|
||||||
}
|
}
|
||||||
@@ -142,22 +142,22 @@ func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
|
|
||||||
// Checks if username isn't empty.
|
// Checks if username isn't empty.
|
||||||
if u.Username == "" {
|
if u.Username == "" {
|
||||||
return http.StatusBadRequest, fm.ErrEmptyUsername
|
return http.StatusBadRequest, fb.ErrEmptyUsername
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if scope isn't empty.
|
// Checks if scope isn't empty.
|
||||||
if u.Scope == "" {
|
if u.Scope == "" {
|
||||||
return http.StatusBadRequest, fm.ErrEmptyScope
|
return http.StatusBadRequest, fb.ErrEmptyScope
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if password isn't empty.
|
// Checks if password isn't empty.
|
||||||
if u.Password == "" {
|
if u.Password == "" {
|
||||||
return http.StatusBadRequest, fm.ErrEmptyPassword
|
return http.StatusBadRequest, fb.ErrEmptyPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize rules if they're not initialized.
|
// Initialize rules if they're not initialized.
|
||||||
if u.Rules == nil {
|
if u.Rules == nil {
|
||||||
u.Rules = []*fm.Rule{}
|
u.Rules = []*fb.Rule{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the view mode is empty, initialize with the default one.
|
// If the view mode is empty, initialize with the default one.
|
||||||
@@ -181,17 +181,17 @@ func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hashes the password.
|
// Hashes the password.
|
||||||
pw, err := fm.HashPassword(u.Password)
|
pw, err := fb.HashPassword(u.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
u.Password = pw
|
u.Password = pw
|
||||||
u.ViewMode = fm.MosaicViewMode
|
u.ViewMode = fb.MosaicViewMode
|
||||||
|
|
||||||
// Saves the user to the database.
|
// Saves the user to the database.
|
||||||
err = c.Store.Users.Save(u)
|
err = c.Store.Users.Save(u)
|
||||||
if err == fm.ErrExist {
|
if err == fb.ErrExist {
|
||||||
return http.StatusConflict, err
|
return http.StatusConflict, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ func checkFS(path string) (int, error) {
|
|||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func usersDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func usersDeleteHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
if r.URL.Path == "/" {
|
if r.URL.Path == "/" {
|
||||||
return http.StatusMethodNotAllowed, nil
|
return http.StatusMethodNotAllowed, nil
|
||||||
}
|
}
|
||||||
@@ -240,8 +240,8 @@ func usersDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
|||||||
|
|
||||||
// Deletes the user from the database.
|
// Deletes the user from the database.
|
||||||
err = c.Store.Users.Delete(id)
|
err = c.Store.Users.Delete(id)
|
||||||
if err == fm.ErrNotExist {
|
if err == fb.ErrNotExist {
|
||||||
return http.StatusNotFound, fm.ErrNotExist
|
return http.StatusNotFound, fb.ErrNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -251,7 +251,7 @@ func usersDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
|||||||
return http.StatusOK, nil
|
return http.StatusOK, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func usersPutHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// New users should be created on /api/users.
|
// New users should be created on /api/users.
|
||||||
if r.URL.Path == "/" {
|
if r.URL.Path == "/" {
|
||||||
return http.StatusMethodNotAllowed, nil
|
return http.StatusMethodNotAllowed, nil
|
||||||
@@ -298,14 +298,14 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
// Updates the Password.
|
// Updates the Password.
|
||||||
if which == "password" {
|
if which == "password" {
|
||||||
if u.Password == "" {
|
if u.Password == "" {
|
||||||
return http.StatusBadRequest, fm.ErrEmptyPassword
|
return http.StatusBadRequest, fb.ErrEmptyPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
if id == c.User.ID && c.User.LockPassword {
|
if id == c.User.ID && c.User.LockPassword {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c.User.Password, err = fm.HashPassword(u.Password)
|
c.User.Password, err = fb.HashPassword(u.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -320,17 +320,17 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
|
|
||||||
// If can only be all.
|
// If can only be all.
|
||||||
if which != "all" {
|
if which != "all" {
|
||||||
return http.StatusBadRequest, fm.ErrInvalidUpdateField
|
return http.StatusBadRequest, fb.ErrInvalidUpdateField
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if username isn't empty.
|
// Checks if username isn't empty.
|
||||||
if u.Username == "" {
|
if u.Username == "" {
|
||||||
return http.StatusBadRequest, fm.ErrEmptyUsername
|
return http.StatusBadRequest, fb.ErrEmptyUsername
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if filesystem isn't empty.
|
// Checks if filesystem isn't empty.
|
||||||
if u.Scope == "" {
|
if u.Scope == "" {
|
||||||
return http.StatusBadRequest, fm.ErrEmptyScope
|
return http.StatusBadRequest, fb.ErrEmptyScope
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the scope exists.
|
// Checks if the scope exists.
|
||||||
@@ -340,7 +340,7 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
|
|
||||||
// Initialize rules if they're not initialized.
|
// Initialize rules if they're not initialized.
|
||||||
if u.Rules == nil {
|
if u.Rules == nil {
|
||||||
u.Rules = []*fm.Rule{}
|
u.Rules = []*fb.Rule{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize commands if not initialized.
|
// Initialize commands if not initialized.
|
||||||
@@ -350,7 +350,7 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
|
|
||||||
// Gets the current saved user from the in-memory map.
|
// Gets the current saved user from the in-memory map.
|
||||||
suser, err := c.Store.Users.Get(id, c.NewFS)
|
suser, err := c.Store.Users.Get(id, c.NewFS)
|
||||||
if err == fm.ErrNotExist {
|
if err == fb.ErrNotExist {
|
||||||
return http.StatusNotFound, nil
|
return http.StatusNotFound, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
|
|
||||||
// Changes the password if the request wants it.
|
// Changes the password if the request wants it.
|
||||||
if u.Password != "" {
|
if u.Password != "" {
|
||||||
pw, err := fm.HashPassword(u.Password)
|
pw, err := fb.HashPassword(u.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-10
@@ -12,7 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,8 +27,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// command handles the requests for VCS related commands: git, svn and mercurial
|
// command handles the requests for VCS related commands: git, svn and mercurial
|
||||||
func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func command(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Upgrades the connection to a websocket and checks for fm.Errors.
|
// Upgrades the connection to a websocket and checks for fb.Errors.
|
||||||
conn, err := upgrader.Upgrade(w, r, nil)
|
conn, err := upgrader.Upgrade(w, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -57,13 +57,14 @@ func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
|||||||
allowed := false
|
allowed := false
|
||||||
|
|
||||||
for _, cmd := range c.User.Commands {
|
for _, cmd := range c.User.Commands {
|
||||||
if cmd == command[0] {
|
if regexp.MustCompile(cmd).MatchString(command[0]) {
|
||||||
allowed = true
|
allowed = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !allowed {
|
if !allowed {
|
||||||
err = conn.WriteMessage(websocket.BinaryMessage, cmdNotAllowed)
|
err = conn.WriteMessage(websocket.TextMessage, cmdNotAllowed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -71,9 +72,9 @@ func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
|||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the program is talled is installed on the computer.
|
// Check if the program is installed on the computer.
|
||||||
if _, err = exec.LookPath(command[0]); err != nil {
|
if _, err = exec.LookPath(command[0]); err != nil {
|
||||||
err = conn.WriteMessage(websocket.BinaryMessage, cmdNotImplemented)
|
err = conn.WriteMessage(websocket.TextMessage, cmdNotImplemented)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -92,7 +93,7 @@ func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
|||||||
cmd.Stderr = buff
|
cmd.Stderr = buff
|
||||||
cmd.Stdout = buff
|
cmd.Stdout = buff
|
||||||
|
|
||||||
// Starts the command and checks for fm.Errors.
|
// Starts the command and checks for fb.Errors.
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
@@ -240,8 +241,8 @@ func parseSearch(value string) *searchOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search searches for a file or directory.
|
// search searches for a file or directory.
|
||||||
func search(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Upgrades the connection to a websocket and checks for fm.Errors.
|
// Upgrades the connection to a websocket and checks for fb.Errors.
|
||||||
conn, err := upgrader.Upgrade(w, r, nil)
|
conn, err := upgrader.Upgrade(w, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|||||||
+1
-1
@@ -3,6 +3,6 @@
|
|||||||
"author": "File Browser contributors",
|
"author": "File Browser contributors",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"filebrowser-frontend": "^1.0.3"
|
"filebrowser-frontend": "1.4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
bf6bef64f1544a286116fe3a9366ac9addaa2dd5
|
874cb4f3e39c52014a4874f9a20e0f6a13cffbec
|
||||||
+4
-4
@@ -10,7 +10,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
"github.com/hacdias/varutils"
|
"github.com/hacdias/varutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ func (h Hugo) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hook is the pre-api handler.
|
// Hook is the pre-api handler.
|
||||||
func (h Hugo) Hook(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func (h Hugo) Hook(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// If we are not using HTTP Post, we shall return Method Not Allowed
|
// If we are not using HTTP Post, we shall return Method Not Allowed
|
||||||
// since we are only working with this method.
|
// since we are only working with this method.
|
||||||
if r.Method != http.MethodPost {
|
if r.Method != http.MethodPost {
|
||||||
@@ -108,7 +108,7 @@ func (h Hugo) Hook(c *fm.Context, w http.ResponseWriter, r *http.Request) (int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Publish publishes a post.
|
// Publish publishes a post.
|
||||||
func (h Hugo) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func (h Hugo) Publish(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
filename := filepath.Join(c.User.Scope, r.URL.Path)
|
filename := filepath.Join(c.User.Scope, r.URL.Path)
|
||||||
|
|
||||||
// We only run undraft command if it is a file.
|
// We only run undraft command if it is a file.
|
||||||
@@ -125,7 +125,7 @@ func (h Hugo) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Preview handles the preview path.
|
// Preview handles the preview path.
|
||||||
func (h *Hugo) Preview(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func (h *Hugo) Preview(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Get a new temporary path if there is none.
|
// Get a new temporary path if there is none.
|
||||||
if h.previewPath == "" {
|
if h.previewPath == "" {
|
||||||
path, err := ioutil.TempDir("", "")
|
path, err := ioutil.TempDir("", "")
|
||||||
|
|||||||
+4
-4
@@ -9,7 +9,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
fm "github.com/filebrowser/filebrowser"
|
fb "github.com/filebrowser/filebrowser"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Jekyll is the Jekyll static website generator.
|
// Jekyll is the Jekyll static website generator.
|
||||||
@@ -39,12 +39,12 @@ func (j Jekyll) SettingsPath() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hook is the pre-api handler.
|
// Hook is the pre-api handler.
|
||||||
func (j Jekyll) Hook(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func (j Jekyll) Hook(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publish publishes a post.
|
// Publish publishes a post.
|
||||||
func (j Jekyll) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func (j Jekyll) Publish(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
filename := filepath.Join(c.User.Scope, r.URL.Path)
|
filename := filepath.Join(c.User.Scope, r.URL.Path)
|
||||||
|
|
||||||
// We only run undraft command if it is a file.
|
// We only run undraft command if it is a file.
|
||||||
@@ -59,7 +59,7 @@ func (j Jekyll) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Preview handles the preview path.
|
// Preview handles the preview path.
|
||||||
func (j *Jekyll) Preview(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func (j *Jekyll) Preview(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Get a new temporary path if there is none.
|
// Get a new temporary path if there is none.
|
||||||
if j.previewPath == "" {
|
if j.previewPath == "" {
|
||||||
path, err := ioutil.TempDir("", "")
|
path, err := ioutil.TempDir("", "")
|
||||||
|
|||||||
Reference in new issue
Block a user