Compare commits

...

271 Commits

Author SHA1 Message Date
Henrique Dias
64d6d9e93b chore: version v2.0.12 2019-05-21 10:59:36 +01:00
Henrique Dias
68902312cc fix: cannot find frontend 2019-05-21 10:59:05 +01:00
Henrique Dias
a52b50b706 chore: version v2.0.11 2019-05-21 08:50:13 +01:00
Henrique Dias
2527bdbfe1 Check if keys exist in map. Fixes: #736 (#737)
Check if keys exist in map. Fixes: #736
2019-05-21 08:46:50 +01:00
cnone
473aaf13be Check if keys exist in map. Fixes: #736 2019-05-21 01:57:01 +03:00
Henrique Dias
0844b597f8 feat: update languages 2019-05-20 22:07:06 +01:00
Henrique Dias
b3a822b4e8 fix: address 2019-05-20 22:05:22 +01:00
Henrique Dias
788fadbd5e fix: remove docker-latest 2019-05-20 22:01:30 +01:00
Henrique Dias
40f29e1e9b chore: version v2.0.10 2019-05-20 21:55:30 +01:00
Henrique Dias
a036a25e1d fix: compile for linux/amd64 2019-05-20 21:44:21 +01:00
Henrique Dias
abed362dc5 Make --auth.method parameter optional when changing auth parameters Fixes: #715 (#732)
Make --auth.method parameter optional when changing auth parameters Fixes: #715
2019-05-20 18:45:12 +01:00
cnone
ce78299464 Fix panic with checkerr 2019-05-20 19:20:41 +03:00
cnone
030f6607f0 Refactor the code 2019-05-20 04:55:36 +03:00
cnone
c3a4e33245 Fix linter issue 2019-05-19 22:05:42 +03:00
cnone
aabf0843ab Make auth parameters optional 2019-05-19 22:03:26 +03:00
cnone
748e4acfb6 Fix empty json auth parameter bug 2019-05-19 17:31:25 +03:00
cnone
6e48a6b512 Make --auth.method parameter optional Fixes: #715 2019-05-19 17:13:34 +03:00
Henrique Dias
88500ab219 chore: version v2.0.9 2019-05-17 12:29:56 +01:00
Henrique Dias
d0f8c141e1 feat: adds support for unix sockets (#729)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-17 11:48:06 +01:00
Henrique Dias
34a1bf1380 fix: correct frontend commit
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-14 09:11:17 +01:00
Henrique Dias
b87ba12a7d Merge pull request #727 from alexandrestein/weakClientFileName
Update download names file for weak clients
2019-05-14 09:06:01 +01:00
Alexandre Stein
b3b5db351f Update download names file for weak clients 2019-05-13 16:30:18 +02:00
Henrique Dias
9562e06b92 chore: version v2.0.8 2019-05-12 21:09:05 +01:00
Henrique Dias
7fc4899507 chore: versioning with ldflags (#726)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-12 21:08:43 +01:00
Henrique Dias
d649ae6ff7 feat: use new docs links 2019-05-12 10:58:44 +01:00
Henrique Dias
a65cb32d70 chore: setting untracked version [ci skip] 2019-05-12 09:50:10 +01:00
Henrique Dias
f1a7bc54ea chore: version v2.0.7 2019-05-12 09:50:01 +01:00
Henrique Dias
8e1815944b chore: add major docker image 2019-05-12 09:25:04 +01:00
Henrique Dias
db924c475a feat: tidy go mod 2019-05-12 09:23:52 +01:00
Henrique Dias
d970bb7de7 feat: use npm ci on ci 2019-05-12 09:23:11 +01:00
Henrique Dias
1fa91adae4 chore: go mod tidy 2019-05-12 09:21:34 +01:00
Henrique Dias
604487920d fixes: requiring a trailing slash (#669) 2019-05-12 09:20:53 +01:00
Henrique Dias
72e74d421c fix: don't return 404 if the prefix doesn't exist
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-12 09:04:09 +01:00
Henrique Dias
df5fc427ef chore: setting untracked version [ci skip] 2019-05-12 00:48:33 +01:00
Henrique Dias
12088154fe chore: version v2.0.6 2019-05-12 00:48:26 +01:00
Henrique Dias
8ec27734bb chore: fix ci 2019-05-12 00:44:56 +01:00
Henrique Dias
1e6a0939a2 chore: don't build docker twice
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-11 23:49:16 +01:00
Henrique Dias
e58daaac83 feat: push single tag
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-11 23:34:56 +01:00
Henrique Dias
7d0f25e530 push immediatelly
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-11 23:22:05 +01:00
Henrique Dias
cba41a1a32 feat: improve wizard
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-11 23:15:52 +01:00
Henrique Dias
997f21fc55 feat: inject ca-certificates through alpine
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-11 23:02:37 +01:00
Henrique Dias
4590884a34 chore: add cleanup phases
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-05-11 22:56:25 +01:00
Henrique Dias
cc6689ac3a chore: use circle ci (#725)
Former-commit-id: 3f2b9bf4d651e626e7658849fd0f1caefa4cbe1b [formerly 978d6c75dab9f724c7aff2a31cc3d3d0bb5e84d0] [formerly 4df409b8627f55ec6fee20f0698e7a2b06380f6d [formerly d60b3ebb28179b2d928e695bec7ccbd7494ef4e1]]
Former-commit-id: 24fec7fe931aaecf3fa91d9e9050c16c49909cd9 [formerly dbfae033cad45b7139de0238ea656e74e727f3e5]
Former-commit-id: a3fddbb4692b968e481ed7ffe3065b635aca2df7
2019-05-11 22:40:11 +01:00
Henrique Dias
3ab225a101 chore: remove caddy (#724)
feat: remove caddy bug repo

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 4345a1d1b37df8b2d626c12e30415e13f70d5127 [formerly cbee013f5a8550dcd02efa3b3dc9a753126d5324] [formerly 6af0fc7ef5f751265163b91c5f7d004c822d72ae [formerly 0a37918677]]
Former-commit-id: f4493baf307b933be0fc9faec048ba0a707b0cdb [formerly 5dd46cd82f833b56fe5ef6017e7eaeaea6eb3ceb]
Former-commit-id: efecca4f50951099c2dea55bd904ce9077c21a0c
2019-05-11 19:35:50 +01:00
Henrique Dias
b8169b6ebe chore: setting untracked version [ci skip]
Former-commit-id: e4bda0276fdf6150744386cf41db53006763a2b7 [formerly a41a0964082de4cc378f49645d0731fda6e39ceb] [formerly 4277ee0909bfa8da9707f29b0c1c45fbb9d24a0d [formerly b13bed82e2]]
Former-commit-id: bf930d79708485d8bb7916cb37133788c309c806 [formerly 747db44298bcf930e9cc2e134ee20fe1fc162aa9]
Former-commit-id: 0be75c39fb7a88c0fb475ca17d8744df0af69abe
2019-05-11 11:41:36 +01:00
Henrique Dias
e5b8684e7f chore: version v2.0.5
Former-commit-id: 356cfa9fe1e90a7cb037b9e1ceecea45aaf44908 [formerly b13ea2a48ba77b026b8129a3614a606037e1e0d1] [formerly 826ed64b6cc019c905211388cf1ef4a4bf9f3e3d [formerly e00c8b606f]]
Former-commit-id: 293a7c66cbd0b7777dccbf4b7480fee2d1a9891d [formerly 760a541b948062a69b0d12db2272cdb7bc0da01a]
Former-commit-id: eb09feea73c0b926f93f08c774b2c4bf0829845d
2019-05-11 11:41:29 +01:00
Henrique Dias
912c4b4eee chore:; fix ci
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 614b6af4a41d5c311a2610ecc34a2f061fb84ed4 [formerly 6fc21c6c5cb48f53d3f8ed9e47308b62828d8aea] [formerly 602f31162786c0ef1702996df946a87b257cd9b6 [formerly f9d175d7c4]]
Former-commit-id: 6e49a267d6a15e2d5f620ef3c4088af74727a595 [formerly 82f4a74daa59a1a628aa7c0978766af83aadaecf]
Former-commit-id: 5908367f18080cae2b70719090f7ca6cb0dd46b3
2019-05-11 11:40:53 +01:00
Henrique Dias
b8dfd79dfe chore: setting untracked version [ci skip]
Former-commit-id: d365cf44114615b1974bca28041f6794c9cce71f [formerly 0cf80ffb0e33addac168404fd15c2fa58072e6cf] [formerly 649c1403af6999d42e8943a9739fea5554234338 [formerly dc1a63c352]]
Former-commit-id: fabb9e4fa36b6753b13586fe86e643ae5bae25b8 [formerly 5d7bf3a33660e7c22611fe2f51a48a91e8fd8bcb]
Former-commit-id: 04f8dea3942ea6ac95085ce732082a00bf31d9e3
2019-05-11 11:21:13 +01:00
Henrique Dias
579f3ccd7d chore: version v2.0.5
Former-commit-id: a9912c8643b629ab562354183bf629cb5f05a5b3 [formerly 7e6fa099800828b87dfeefa47469308c9f86d8c6] [formerly 19b9738b04e9e899306c1155e9ea2960f7e99889 [formerly e4d72d76bd]]
Former-commit-id: 6056c50e78d29656f185bbac2a766b1df934ae5b [formerly 40e1cca78150c8d76441b7ada67784b46c4b0a3a]
Former-commit-id: c5965154be95686aac6c6b0258892685f7abb26b
2019-05-11 11:21:06 +01:00
Henrique Dias
f5b3ab8db6 feat: use go 1.12x
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 1099ae5d7f6c132cf891e060de7c88f96d656f09 [formerly ea50b2c0686431e5728258fd02ad3a9e907c9349] [formerly 33237bb474abe7524a51501f797ca7cdae44c33f [formerly 30f685a347]]
Former-commit-id: 0669d58fb6dc75a63b6e16857d7a4e09a6ba806f [formerly f4d38b4fbf2a7aa234c1c7cacc743fc386f5fa20]
Former-commit-id: 8391f23eaa62ca9a4599c327b8418d9593ad110b
2019-05-11 11:20:00 +01:00
Henrique Dias
51f34eaadb chore: setting untracked version [ci skip]
Former-commit-id: 25a3a8573d7aa98ddb44e93e1592bcf75a9bdd8c [formerly 0ac5fd3c659c0f6b13a191111b2ef5aaa1ea0b32] [formerly 478e9344bbc49b40662e60477b735fd667247833 [formerly f1b7e268e5]]
Former-commit-id: 8161191fd46defb50b75245da3778cbed961ec1e [formerly 721665ab8f48faa582bbe93daa892f09ea47ddd7]
Former-commit-id: 7a9238d3e212fed0076aa8b9c4081cc2fcfa111a
2019-05-11 10:50:10 +01:00
Henrique Dias
6699993088 chore: version v2.0.5
Former-commit-id: e1da801b5a2ec24fedbcd0acf730c635b5c4d09e [formerly c3db76c64b0bbdc7d854db3315ed8d1031eb14ac] [formerly e524dabea7aafe4dd0216783021c2e3822ce091a [formerly 815ee40110]]
Former-commit-id: 10ed3ee9044af8cc2c6a7885fb5124b695f8d121 [formerly d599cd5328e8e1b9614b9f59d2a6331d9480a82f]
Former-commit-id: 2bf752c693c8dbffa6a94c5acefdf0fcb192bd02
2019-05-11 10:50:01 +01:00
Henrique Dias
4257a775c8 chore: only update filebrowser
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 43a156f17dc5f31a8f05db09c8dc2993e66e12d3 [formerly 127be0e964f108ccb270ea3e406f8adbad529b95] [formerly 427f9ed0116200977d93a3738beded5ec0ec1801 [formerly 1679a7393d]]
Former-commit-id: 554f0e934b99e16d9feaf8b2f860bedaa0806637 [formerly 1931a7700751e4b0a004d1e35399ba877e890a8d]
Former-commit-id: 956e6fd658ca8a73ecc5e4f306bad4e1203e4c51
2019-05-11 10:49:38 +01:00
Henrique Dias
331c7bf387 chore: fix push ricebox
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: aadad9829076baffe239bbb87a2edc6565236710 [formerly 5f7905abd73a12f695081bdf16c08c88a39cc85e] [formerly ba5ff2c403dad0cbd3ec85c189193aa613834490 [formerly 549dec46e0]]
Former-commit-id: 222f34123a2247808f3512c5d4cfd21d47ae56ed [formerly 53e355ebdf6bfe6e2c26614e492047a66a44e308]
Former-commit-id: e9f355cddfb848ad07f038e6bfb7c5c1f45f057d
2019-05-11 10:24:26 +01:00
Henrique Dias
4c64aa7d11 chore: update dependencies
Former-commit-id: 8944a3ab76433102eaab1f9b4ac60c75801cc18e [formerly 4d94ff5e03e9c6a57c0d05ee4f89954b987a607d] [formerly b6021a4ccf0477bf7ce8f551937fc6b29f0316a8 [formerly bd93aeb50d]]
Former-commit-id: 8c408f330360d41a2a8ffdf43036598222476622 [formerly d1f12f0f532a256bdd22711b22d3387c735a9dee]
Former-commit-id: c147d2767e53b1152997cea1e2e99e0848f6d1f9
2019-05-11 08:27:17 +01:00
Henrique Dias
1f8ec36eef Merge pull request #721 from ttys3/fixup-isBinary
fixup func isBinary to handle CJK runes correctly

Former-commit-id: 08c8613759eed7d4790c9fea99273f60e88531a0 [formerly 82af4df6a155423555865a4d16a62c74befcefd1] [formerly 20751c4cd90807c51145c5284573509f26e5c934 [formerly 22bbad84fb]]
Former-commit-id: 4561311363fd52b51838e71408ff270c2f376c97 [formerly e6452a14dd39fa07dc8d77a2b47b7a03b58c0029]
Former-commit-id: aca07de59fcdb2f079b839572cb431c792719158
2019-05-09 07:50:13 +01:00
荒野無燈
586bb63ee7 fixup func isBinary to handle CJK runes correctly
Former-commit-id: 880817e9e688f7126eb5e3010f5fc37110b28448 [formerly d44d541d75c625a474ca7c8f9adcc52e20ee69e0] [formerly fbbaf7b6a31ed09944700f1ffa98c0baca9ae0f3 [formerly 1c42539522]]
Former-commit-id: 2a647332f2d80741f7ac9cd4eccffbf8a0dd5348 [formerly ef7355350d4d1276911bcdd8b4aaaf1b82efe50c]
Former-commit-id: 7c6d116b6bda492cc9544dc4a46d95cd225c1b39
2019-05-08 02:15:37 +08:00
Henrique Dias
2ca921b01b docs: revert url changes [ci skip]
Former-commit-id: 33f4f97b069cafdee7ee9461fbe91dbf5885d71a [formerly d42ada8a5bed3bf9cacd65eefa3cd5f6fc5fe43a] [formerly a428467913503af725d8f9ac3099bd2b7b5060bc [formerly 805ad33c1b]]
Former-commit-id: c0341fea4bbf7329067cfdd268d9bfe642932b47 [formerly 7503f34487a60ace9c81c95f7f6a929380bfa023]
Former-commit-id: b586408c96e4be271f6c694a78b2c6bd7e52271f
2019-04-21 09:23:52 +01:00
Henrique Dias
61cf3eb11a docs: update docs urls [ci skip]
Former-commit-id: 2db0740d8571138993b7c933b7cb46f9ab4ddc57 [formerly 7bcdd52642fe46f34990d3edd45a92bdae4d8a91] [formerly 5e20ef92fb92d4ec507a57966c5effeba2679292 [formerly a9249c3d3f]]
Former-commit-id: e85d33b6ca46ac6c5bc7153cdd429f641b30f4a9 [formerly 16d558f99a3dc84a6f882758c37aba353fb0df96]
Former-commit-id: 99126f4311acb74de88055ab3e4d7e7d0984ba46
2019-04-20 21:32:25 +01:00
Henrique Dias
a1573b2b64 chore: setting untracked version [ci skip]
Former-commit-id: 69e1e7a5bf250234f72945f283e8e0c40b975888 [formerly c28dd4a3a2f33bd1bfd66dfebd4c3e095ce13a03] [formerly d85546c1ccacfa3ae42dcf9920d18a0856ca04a3 [formerly 3df6243224]]
Former-commit-id: de1a3e4855876e10d4dae49e7af11112355565ea [formerly 46d269421e87447f89ade8be883fa72dff56c88f]
Former-commit-id: 56bd1dce6b6e6ad7bbd6dfc265a7fe53098b7a0c
2019-04-20 14:56:20 +01:00
Henrique Dias
de2c2021d7 chore: version v2.0.4
Former-commit-id: ed0fcd880038c88122f3791bb7e1dd72aebc4490 [formerly 1528e0038353c351ab614fd13c79c8c03a0b7c5a] [formerly e1164b51bd061190976d5d9bd6f50352279ebead [formerly 477ad73ef1]]
Former-commit-id: 06c62a56d5bc335e1092a81bf5e28b7c9a257f82 [formerly f690c1178915409b6ea62d0e4a126d5a05228a2b]
Former-commit-id: 4a51dbc5c2ec941ba2a6f66b3f811d38faf11bdd
2019-04-20 14:56:14 +01:00
Henrique Dias
243b12d4c2 refactor: cleanup comments
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 09c20fe153894ff9f7d076d7470b015240c2e0ea [formerly 5d924777fe9ceb19a894eb8d450ab6b47a99d1e6] [formerly c4e99a1cee5b217f76cf2db05827c115ee1ef45c [formerly cc79548206]]
Former-commit-id: d3504f478810703708c751c3fefbfec11453d8c5 [formerly 205fbb1cef0aebedb15c27d7c73316262583b3cd]
Former-commit-id: 4339b62732ce10bfabe4193dd81a07a741c1ecf2
2019-04-20 14:22:19 +01:00
Henrique Dias
fa86894550 lint: lint the code
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 984c56e0b9a9169b10c6017fbd68ab4fbd3868d7 [formerly 27c43314222c723a220b9b1d2141e1509ed05627] [formerly 0a9f6c47bff2d653035c93765ea08ade73ec450c [formerly b7fdcc3ee9]]
Former-commit-id: c27e7fa41f20f433a9a0a97ecc40ab78968b43dc [formerly 185db4a17969cd4fb76cc2b06bd58221c9c6c100]
Former-commit-id: 9b26d1b0642c61cd38f7cdf422f95b2bf9a9614d
2019-04-20 14:15:28 +01:00
Henrique Dias
4a1e21baec feat: update frontend module
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 0f4090228826b7fe1a7796289f4edac117281a5d [formerly df795ff9dd1a3dee923ee66b9159096b10e8e379] [formerly 950e67628643132a899b4f2fcd39c63f01b68800 [formerly c4bef0d616]]
Former-commit-id: 7e0163bd1048f484b1226619791f37c223c7f140 [formerly 078ec68f3a8f6e0cf560c5df3a47a4409efb530e]
Former-commit-id: a205c1e984c0969fb36a86627800419ac8914d77
2019-04-20 14:00:55 +01:00
Henrique Dias
0607e0df2d feat: per-user auto directory creation (#676)
Former-commit-id: 4356d3e09da55e5f64acd9c476ba536635d4b2c0 [formerly d888715b1e26e822af92f1fbfd5090003104d6b7] [formerly 91adee94700e7ae1c08fc00679b74e67948ac2f3 [formerly f72addc780]]
Former-commit-id: e40b20d11bf17bb0704680c3c41a4f8219248c03 [formerly 9886a9ec0fe230506b346eed1d82b105fca537eb]
Former-commit-id: bba8644c9c61dd04853cac9748d27a453b9607d5
2019-04-20 13:45:09 +01:00
Henrique Dias
c2f1d07abc fix: linting
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 0801f7da250662001ee6a4ffe77fd29bc72c3e81 [formerly 53cec10bada3f6e91184a3e9cbbe7426e08c5b42] [formerly b6362562ac985ec2c756c856b4b17d0dbabb265c [formerly 50867e48c4]]
Former-commit-id: 9fce1885ddb7894f540ea64b0ce674a9c5b92cf1 [formerly af5baa67f3ed8eea4f596f35837c58f01dcead8c]
Former-commit-id: b16b8bcdc1f76b205c3db9386b837d6d30d7f189
2019-02-27 20:55:45 +00:00
Henrique Dias
0d1074b6d9 fix: remove unecessary print
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: fc014a4e87fa75993f0cf8f64240effb3e2584d4 [formerly 5202c884e0a57d8c6bf978e7d08a00101d47808e] [formerly 66868567bca840214788a0519c8c3ad9ccbbc37c [formerly 41bd80fefb]]
Former-commit-id: f4b3c79d5dae50caa25789fd863458bf9961f437 [formerly 644718708ce007762ad18433a67eb5e321d1eae7]
Former-commit-id: 7270c35dbcbb668ddbc8c422cb78bcb4ff8ea56f
2019-02-27 20:48:17 +00:00
荒野無燈
65a53514d5 global settings: add createUserDir option. new feature: auto create user home dir while adding user.
Former-commit-id: 331a76abdc611236ccc761d0fd9a814ed1ee0c35 [formerly 0c1024a5b8109c84d213e0cbdbe05e10eb5793d4] [formerly 467e1789f55c410ff2ca9e9ef125d9fe28410bc9 [formerly e8570e4dba]]
Former-commit-id: 1eed58870b6e009d84806db6b55efc5fc3983e2a [formerly 3e9083f7758e72bd307ed23c4b512a8ab5adc523]
Former-commit-id: 5023ef77eb92636e62fde511ea609114e667a7d7
2019-02-19 11:55:18 +08:00
Henrique Dias
ce68f48fb4 fix: clarify bolt package name
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: f46856bd84680104e797c78ae1c5b24a4bf4abb2 [formerly 5e687a969645645c17e69267f5410d5dd25b001d] [formerly 0ad00c12d715b805d51b7ffaa17283525e5e21f1 [formerly fbcf1ea995]]
Former-commit-id: eaf1b6aa326396828785065f53498e02a2f95b78 [formerly 30a76c7b8bd306bb92312aa7071cc3829a2171e4]
Former-commit-id: b60dcd6ac13649e759affd60b0e8346b243ef072
2019-02-16 21:23:02 +00:00
Henrique Dias
5a03c75dc3 chore: setting untracked version [ci skip]
Former-commit-id: 323a39fa2ae4fb60c7edefe7187fac8e79b5e95e [formerly ca42b3110ec4bb05809b07fbdcecec8df2def8b7] [formerly 2b987bc5e6612c2bd24943539c988a1f06a092b6 [formerly cf985676b9]]
Former-commit-id: 879575488c9618522f056dfda9d912957309555e [formerly e2dcead90587fa4ce55855640685c6b5bb8dc88d]
Former-commit-id: b775da1a1cd25482c40d5c6161f559445ff5cc5a
2019-02-15 13:06:19 +00:00
Henrique Dias
20d80bb054 chore: version v2.0.3
Former-commit-id: 946abfab3889ee4df0dda76220b13cc0ebc4d3c9 [formerly 34dff77bc4f5b12eb8e47e379d21caa0e55dd947] [formerly a3b1b9741b197f1fed9b53688c61d1fd474cdd43 [formerly eeb6f3207e]]
Former-commit-id: d6191757d2495b28af08ed8e7de6dd46c90e7eb3 [formerly a49750caf93d703eb77df3d7fba2c0c234249fd5]
Former-commit-id: 98ac0d3e5e19a270f0c57dd5e59b3ee22fc05af5
2019-02-15 13:05:33 +00:00
Henrique Dias
cbdf3cafb6 fix: possible fix for proxy auth requiring login page
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: aa32ec7e27f24aee497d3c1a6bb3cda4f3f30265 [formerly 92f1d95d44e0a1c0b8dd6d81b467829c8832acc8] [formerly d8c05dc476ae88b730547cce1e3644c69ee17278 [formerly 84f108f1c5]]
Former-commit-id: 9f766a5b8ef847569fb8f4f16540c256fa9ca92f [formerly 0b6b1e48435b3fe5819327e311f08eb179a19b3e]
Former-commit-id: 046dfa8350d2f1b4e7fb789fb026069e137437ef
2019-02-15 12:58:45 +00:00
Henrique Dias
1259fc1bbc feat: remove version cmd (#675)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
Former-commit-id: 04a60c58f20d63ca7b25731c41e144bcf0f538cc [formerly e6e179799b64779515051df53352df5e63edc259] [formerly 0689eba81ff5f7ee3ea75db37b91cef4d6d8f35c [formerly 85899acae6]]
Former-commit-id: 96ca0cadb94131ddd3b57f0f11ad629edf687e40 [formerly 50130c75d39e67b15a645e7f4879acf34a5d6620]
Former-commit-id: 53b8120673a82217c3625de161d4ec57a96e1470
2019-02-15 12:54:44 +01:00
kolaente
4cf1f2f6b4 update dependencies (#668)
Former-commit-id: 8987aa3ca60368e28dbb54e7830f76ae9d8863da [formerly 3fad0ef36350b59b3a9ab613ae51df58c57abd49] [formerly 062602db41695fee69a8e7626442741fcd5d592a [formerly 4a4f635816]]
Former-commit-id: 9f624413cae53841cd306672b3cc8d6bc8c9a5ef [formerly c5df323016df89b2eb1ded85ba80ac8e2af0f52c]
Former-commit-id: 15a16269ed81b00917b5097e203cda55de8fa120
2019-02-08 14:37:14 +01:00
1138-4EB
a90bb28cae Create directory of database if it does not exist (#650)
* fix: create directory of database if it does not exist

* fix code quality issue


Former-commit-id: 88c95717436489ff9014d88374775cc4c3f265b3 [formerly dc56f2c1c3bf46aac9a23e700780743ad15866c8] [formerly 92c2f9a68d575fb6e13453df6690c72f05ca9598 [formerly de205177f2]]
Former-commit-id: d0888c2f73fa691b900ddc7cbece6dbef985da96 [formerly a7495f66547f1814d31b1ca41148133d23198fd5]
Former-commit-id: a60afcd1fc6aa5cc88559025d7b3176b60117544
2019-02-03 15:51:17 +01:00
Alexei Yuzhakov
e86dfbe8ff fix: case dependency and sorting order (#661) (#662)
Former-commit-id: a772b30907a92818e5c109adc0d382af7ddf40dc [formerly 589c237e7f1230f16970c0b68263d4174dbe98f6] [formerly c3a0e4964d028dc06e5076869dd92975eb3c4699 [formerly 17b514510b]]
Former-commit-id: 8e2c49d8fc18df68bb3172fbb98a97c98a5eb818 [formerly bc396cbf040a5016a26cd5387b14e9f55f8b74c6]
Former-commit-id: bda1997f4292c213e907ed0d8e566c5ab931edb9
2019-02-03 15:50:08 +01:00
Henrique Dias
437a238aca chore: setting untracked version [ci skip]
Former-commit-id: 43d2b1b4fda66a7ae412a5091e93d35c8befc341 [formerly 32d7d602dc1e4a9696fb7fb8230493cccbbece0d] [formerly 7f4524b9c180a1ee538b630902724252203dd439 [formerly 4a2573830e]]
Former-commit-id: 0927241d911bcbdc8d8dec216fa019e5243f9805 [formerly 483ca4ba1feb2de599615d6e738bd3568fd5e783]
Former-commit-id: b16c5e4a58438aafc5e64e30bb9fb031253c8051
2019-01-29 09:10:21 +00:00
Henrique Dias
e5fa0772c6 chore: version v2.0.2
Former-commit-id: d9e5bcaa8ba7c947ca2910e144456286b2e7dfb2 [formerly b35a7f02953dfa884ecb59b45cc7a9173c1dc247] [formerly b207ecb8ac3d2ddd9ebc12cf12ec0cf3badee056 [formerly b2c70377d1]]
Former-commit-id: 134324213f643fe4637eade2348139a78aaaafbb [formerly a3d41a8bbceacb5f2719353d969a1e3b1ef7118a]
Former-commit-id: 64796269842b1c5860b0f22405506bfca4b2e7e0
2019-01-29 09:10:06 +00:00
Henrique Dias
ba5c67d9da fix: external auth by using a different auth header (#649)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: e7c2574e40390d402443b23dd7aee5e5b18e5131 [formerly 20463dd5229b0e1f572a883e83db9e43bf8c8ff6] [formerly d2910cf8b18b20b13a46ffad23183c89325ef06b [formerly b5e61bc979]]
Former-commit-id: d26442e70963119ed3e6abd1ae894294eb12f1ed [formerly 9b49bbd9a959595ef0c26eeadd1fcac96e2b338c]
Former-commit-id: 1c8b2261607cdb88a3c685311e165e517234e498
2019-01-29 09:06:30 +00:00
1138-4EB
f3d007025e remove addon docker-ce from travis
Former-commit-id: 169fb5f6a61249e5420bd8cbf758b961847f86f5 [formerly 05042727df836dfa48a7099f8c6b18bf4052ea52] [formerly b1f252a7bfbeb01e97e2b930bd9b65eca72bed63 [formerly 14a3b5a417]]
Former-commit-id: 2642889d6f7d445e2e63c7f4cf09581598bb6ff6 [formerly 4fcb552e7678e609b0f706e9e31f5fc2e49d5330]
Former-commit-id: 014ce24c903c0eb9e6dabe3fa89cf2c609b2d5aa
2019-01-28 03:35:05 +01:00
Henrique Dias
e7a39808dd chore: setting untracked version [ci skip]
Former-commit-id: 9ef650ed689aac71ec52c4613c7a7b35721604ad [formerly c539dee8f5474a48c9b5291b8ab1aede6896ebe1] [formerly 9db5ced0957f01e287205c2001c47c03b6543f44 [formerly fa4b100c85]]
Former-commit-id: 3b9324f933906b3d898373f418ca462c559f35ab [formerly 6b5d61a31cef4a308139383841c6ef0fa2f2d151]
Former-commit-id: 6e6ec1ef9caad0fb0ad722aaa866647ebc78d107
2019-01-26 12:11:29 +00:00
Henrique Dias
2b7aa7a0c9 chore: version v2.0.1
Former-commit-id: 1ee923d5e301cbc091885dc523baf9f771a5fe26 [formerly a7fc98143b3fc481d04e64c9a9608957475bbece] [formerly 87cca4477009a498c17c5779ec33964513139325 [formerly 5b097eec5f]]
Former-commit-id: 28bf2572b9e3e8258d57de8c0905a8aaafa707c7 [formerly 5de3ab416d621dbd54cd58cf0bf34273017144d9]
Former-commit-id: 603e4589dd55068be106f240a57ec1ee04f8760d
2019-01-26 12:10:55 +00:00
Henrique Dias
4d8f0c532b feat: update front-end
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 2153ac8242a70a057f3573ee6d5afca1824a61bf [formerly c3a4cd6efdfcf3d7d568548763d9eacc1f2a1679] [formerly 6ae07ad768953558d19885c5e4a5b97194ae18ef [formerly a4fee75dd4]]
Former-commit-id: 09c70625d4c30701a49a063835e22a5b74152ffb [formerly 2ac34724d3074d99a21878b5048d9886ce9bf04d]
Former-commit-id: 6039d9b1533d84cc930db13f16a1acb6222610a5
2019-01-26 11:38:49 +00:00
Henrique Dias
367e251a0e fixes: correct users importing id (#645)
@princemaple could you try out this branch to see if it works on your end?

Former-commit-id: 12c782316c411fa3438f167c12634adffb5e1adf [formerly c613ff6624c55292f532d7772e866cf6c81241f5] [formerly 11f03e54dae28fa773227d85259cfd73c5750137 [formerly 9c42269b62]]
Former-commit-id: 04bcf5803397877d00ba48ea6d0b00246dc07b3d [formerly 4c1bb1e95375777aede2c0911bdfa9ce46273b37]
Former-commit-id: 601db641f7d7b01c14903d0cc27085e3d7080c3d
2019-01-26 11:37:33 +00:00
Henrique Dias
cc6f2f8bec fix: encode URIs correctly
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: bf213b683c7cf6a42bd5a710e08ea2ed1cbe6c8c [formerly 7033f8885f037a8fd17aaccc7c95741cdd8a7f15] [formerly 1156eac936b97cc1821f0ffc28f09c977b434945 [formerly dadfffbd31]]
Former-commit-id: 5afbd473b14481514e137a191aa75c3860efbe68 [formerly 691b7b346559672fe41fd2bc7430256ab8512b2d]
Former-commit-id: 0aec5af50f77e3f4f6701b3a4e34694514c64cd5
2019-01-26 10:47:34 +00:00
Henrique Dias
007fde8186 fix: linting
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 3b1344ed7b9b7c41f7188a3e740cf69f3de7ebb7 [formerly db8acf75870cd31f5077629b2f8bcc6606afb606] [formerly e2a38027b43f835c13933188d0c4e14119f78661 [formerly b90d39dfda]]
Former-commit-id: c521ed975cc868b106344c4212707aa1b1eae19d [formerly a3f0dace392521435350c78e40adfc9ac6c576f2]
Former-commit-id: 46c88075964cdd102f5fd2c12e1b09fd94eba6b1
2019-01-23 15:58:06 +00:00
Henrique Dias
552f8168ea chore: update frontend
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: ee0540ac596192045f940e0bc4f47d29b6c2351f [formerly d90bc812c6a77c9838a711fb4e00d1d62a6bfa04] [formerly 90128f33ffa10f584fcab30a8a1165c06b6659e3 [formerly 2ba176a319]]
Former-commit-id: b677fba611975bdbeb56fd541ac7bedee39e000e [formerly 5ad6e6b025d20d171d4a097cc5895b4f7f38b9aa]
Former-commit-id: 91d3aea37524297ece1d797df6bbf716cda77553
2019-01-23 14:49:18 +00:00
Henrique Dias
42426e3e69 chore: setting untracked version [ci skip]
Former-commit-id: 28403ab07de56efe726c60b5b9394652ade286c8 [formerly f98ae829dafc277f9af53195a359ddf4177b2adc] [formerly 9bee729afab603d71e0f386f2dcf1d68bf117be0 [formerly 846127d164]]
Former-commit-id: 03a5583ca594f0cce67b025d913f68ad5582285f [formerly 8ee04063a261f3f85b9e19b86c9a96e2bf6e78e6]
Former-commit-id: 683769c4b55b6dbddf47e66e1e6760e9f961f508
2019-01-14 09:04:16 +00:00
Henrique Dias
e706391934 chore: version v2.0.0
Former-commit-id: 1a6e6ec0cda359306ef81deb4393e6e588005674 [formerly 45bb5b1b929da50fec506f27a50e6ba492374b60] [formerly 41a597953b6d48ff01ed5a28817e9c9436db300b [formerly 145b391315]]
Former-commit-id: db2d7837facbec0ab84275550934d70956d28add [formerly 0d47b66dfb9c802f0ee885b43a034f6cea044878]
Former-commit-id: b5ddd38e9879458640ec3e9449c72e0fad4e4df1
2019-01-14 09:03:39 +00:00
Henrique Dias
58ff28f84d feat: export generate key
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 3088476c44d4608e2b8c90d3c274b6db17ef30c0 [formerly e40d3ba193e0b54bccce8c13459032f51af84c7b] [formerly 33cabf26abee5ef4f1dd63e423fe1b0fa7ae4f7c [formerly a3daac84a2]]
Former-commit-id: fe022f36fc4d7d8442df8c0fa4a86e2ff3ec328e [formerly 1d949d0ae88b3b5a9b8e4da5c3b6ca814a319589]
Former-commit-id: 36207ddeb7eba335f5fe73ea9dcdf6bffc6265bf
2019-01-11 20:25:39 +00:00
Henrique Dias
74a1ecbb89 chore: setting untracked version [ci skip]
Former-commit-id: f8b61a3532b72c804933bf4ba63a111b3c8a2955 [formerly d076a6110407d517bde07846bf31f6cae710e0c0] [formerly 435d24276a43b69dec81ff9666d78f208116a577 [formerly 6dbf801370]]
Former-commit-id: 7ebd072dccb015521deb296f0151c06f17b5dcf8 [formerly 9f8c86143171142fb3c108ba32c7eab63a5632db]
Former-commit-id: d28fa2428da947bae7029257d04497d581c18d99
2019-01-09 21:52:14 +00:00
Henrique Dias
5fa1711a30 chore: version v2.0.0-rc.2
Former-commit-id: 39889c9895dba58578db931c4c55a1c25b822672 [formerly ebdcd02361e6499301262051376278a9dccecce9] [formerly 4ff653acbd767dd37a2b86be607bbd1af0fb7cd7 [formerly 0d0d9ef5f9]]
Former-commit-id: 0ce6e7f7871bde28b24e1b596af786f3e8dbddf9 [formerly 7d3a69c30e1af1e5b028bbcb926a28341a3f71b9]
Former-commit-id: 81cf5a20fa5ae3077337d968f686df58923b5b5c
2019-01-09 21:51:39 +00:00
Henrique Dias
4bc6a23143 fix: no db error when db size is 0 (#629)
Fixes the error where File Browser would fail when the DB existed with size 0. This closes #628.

@1138-4EB I decided not to check the version for now since it's the first time we're adding that info. Only the next time we change the DB structure we'll use that value as reference to know how to upgrade.

I did not check it because the users running rc1 would have some issues with it.

Former-commit-id: e8b07ab919e9c24feee8f6f2dd6df30df1e2325f [formerly 3396f05b4a1a07e1b993b7c07d1afd2def9cabbb] [formerly b43eb8e400603f99baf7966a58156dec7bd47420 [formerly c1c57c6525]]
Former-commit-id: 1115d0cf8a601feafac2b33cb46b813343f4fa8c [formerly 05de6caf8cf747a95fbb10587f0a767dfb8b8774]
Former-commit-id: 840c1a278cd45d36ce8538b7c5fe97923be05ca3
2019-01-09 21:37:47 +00:00
Henrique Dias
b578e2196a fix: search (#625)
Former-commit-id: d9c9234e87c190d847572c1fe715cf745ba44b53 [formerly f8b5f600fe39be8b47aece870ff24756c5dcfc6d] [formerly ad1cbfd739888d4cc3a1db882a98251cac3b89cc [formerly bafe9f0ad7]]
Former-commit-id: 493e4f3e4b42092201cfd1f99d8ee6cd3eb25dfc [formerly 520a9df6582492f24906f8f3f5c5e90cf5a02acd]
Former-commit-id: 17484d0fe391a82d5ee0dc990f4b1f039d305f4c
2019-01-09 15:18:03 +01:00
Henrique Dias
866375141f fix: strip baseurl (#626)
Former-commit-id: 5daa76063fbd8766115a722336d544d2f6156c74 [formerly 3d644f06b38b6c20f5549b3f2f780556881f216e] [formerly beb819187116079ce83329e85bb1b1d5e6b908ea [formerly 73e0acaa71]]
Former-commit-id: 01dfc4bb6016d6c3de2bb932695e7ca6b9185ff6 [formerly cdee480885c5050d9311f41f39ef7b4feefcc602]
Former-commit-id: 82bbfed106ddae78f22d01cabc11f314c19a1796
2019-01-09 08:13:57 +00:00
Henrique Dias
a3b9807717 fix: clean server struct once it gets to the handler
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: a9d9c2cd9a5fffa71409ebb0867faa3a0aca6e9f [formerly c3359cf3ff2633945a9c8dd5ea8eff5a77484364] [formerly 8921b27f322e426cf2f2f07dc682e1fffca162e0 [formerly f1c86054b3]]
Former-commit-id: 078633f5c5b1aaeafd6b078b5e006c5e05f19c84 [formerly 9013496a12cda3bef58215a3f5df4eeeaa677eb1]
Former-commit-id: 420076748685f1b8a23053c5fe159bc5e86942d3
2019-01-09 08:13:24 +00:00
1138-4EB
d47774c828 fix: caddy sed package name
Former-commit-id: 23faa66a6010168f64545ead1beb5f41db3ffd76 [formerly 335df9ff6c4799677119e72f6bbf5a00e6709c43] [formerly 54ebf5831102f306edb07b40cb518262787a9305 [formerly 5a9f0a0d81]]
Former-commit-id: 5203ad4f906f8f85c7ece2d7beb14eedfa907cf7 [formerly b58ea071061a8a045fbbb9301b028774f9991696]
Former-commit-id: 7ae9ac04e135c449355a8da8845e0951fde6fe92
2019-01-09 03:13:54 +01:00
1138-4EB
bc4ac5eb9b chore: setting untracked version [ci skip]
Former-commit-id: 55909b40916ed0b65a2d588cac5aa171b43c4482 [formerly 52607bd0e51b455281480ac0d8c7fdc5a4a663af] [formerly 75ce16e7e290c9fba9f4288507a4961a4bb0b10b [formerly a55e0d24f8]]
Former-commit-id: 15936e40500010751e70401bd6f0574f614d9ada [formerly a39e7b2a11d0379964f5e911447289910406e0e5]
Former-commit-id: a87b512c8f08cdf5affff568ee96507575e8e2db
2019-01-09 01:53:36 +01:00
1138-4EB
f16ec4b45c chore: version v2.0.0-rc.1
Former-commit-id: 15b5351860f405fa69e33eac6b1fab2c5cdca545 [formerly 3784bd141b58be668dea5b55daf1581a8cd368ff] [formerly b35c153dcd6eb02bb9a989cfa94524609c69b2dd [formerly c1f344e9eb]]
Former-commit-id: dcb76cb145e62812a451e871385be3e7065c09f8 [formerly baad8aadbacf6ea9d17e70ecdff9272e341006c2]
Former-commit-id: d58d71dea43f6b2da1b5600b5d15a15d82fa9f1e
2019-01-09 01:53:36 +01:00
1138-4EB
f8da8bc985 fix: wizard pushRicebox non-existing envvar
Former-commit-id: 4a6d00004f968e76543e3d20ce493a0ff5e4cd1b [formerly e36e6696fd79defbbff9683c96a53920c158aeef] [formerly 5d1798ef2f3a97a4d5e772500acfcb8d47a6a75a [formerly 9f6e51b251]]
Former-commit-id: 1a74df1209e3216eb5cfd780406b75136a441d36 [formerly f72d4c934ecaa9c6930cfa9da7d1974757759af7]
Former-commit-id: e0e020f7937a943976c78c0d212a1076ac2c8ee4
2019-01-09 01:53:35 +01:00
1138-4EB
0ec589ca74 fix: update to goreleaser dockers changes
Former-commit-id: 4c10c5e07f551de30964ae18cfdf4e868efff84c [formerly cc244cf72188258270d20d30781170603513cdd7] [formerly a28388f0d471fae4d8791c1e31b7f9d8b4299f4c [formerly 27d1a95310]]
Former-commit-id: 854366de95a9065503b779581c4d0a4c25b37b65 [formerly 72860fe1d2b1dfcbfd2e2c0797e55a1772b81a38]
Former-commit-id: 7c9b7d2b86fe881a7b71f7619b698cce5c3f98ef
2019-01-09 01:30:56 +01:00
1138-4EB
4e4ac88cbe fix: goreleaser main file
Former-commit-id: d4f2b341e949bfce045124115123b2748ab4b438 [formerly a92a7d72c9077d77be55f9d76b94a104f0be992f] [formerly 3ee3bbc16944230a4c5f7b5b92c19131f08bc5e7 [formerly 8c2c298d9d]]
Former-commit-id: 68b9c5ecebf51002b823d4ef0aee9746a6f22e76 [formerly 441e5f99c76a2d9594f3ee8c12a7b889e6edeee1]
Former-commit-id: aab01c50e0b68dee6472455bf2c14d254fee57f7
2019-01-09 00:37:59 +01:00
1138-4EB
0762516a18 fix: wizard -r requires an argument
Former-commit-id: 0f180b2a9e78ca551eba70705f812e349943d468 [formerly 20bf6d4bd2ec6165c02560725b698278e17e24c3] [formerly a60dd0705c3d59d9f8214fa4bb38b39259b2fd5d [formerly 43e494b0f7]]
Former-commit-id: 6c7a31c95851d3759cef822976bcb41ccf45cbbc [formerly 53b885258e59bb8366290b30b2aded5ab1e361a6]
Former-commit-id: 8311ae09ce36822171d55e3f855bf66a9a2b3461
2019-01-08 23:54:37 +01:00
1138-4EB
41272e67a3 fix: wizard release
Former-commit-id: ca21ec5987a64aea7d155d5ce532b452d502d1e8 [formerly 0f4ae7305653e52c36bd2e05b6328e4b6a21cfa7] [formerly 8461ae3cc270e84de3ab0a402d50484b1a417261 [formerly f218c2a791]]
Former-commit-id: 1e7aca3d5837c39a5073bd3d65847fe566929ad0 [formerly d210374bc803529ce4edf7a6d83bd3c4ae3f1bc5]
Former-commit-id: 0eaf26b83f446f6022da9af1be334f9eb452b5a1
2019-01-08 21:22:03 +01:00
1138-4EB
da7d1db06c style: rename functions in root.go (#623)
* replace isFlagSet with Changed

* style: rename mustGetStringViperFlag and getStringViperFlag, use getParamB to read noauth

* style

* style: move

* fix build error

* rename getServerWithViper to getRunParams


Former-commit-id: 2d6d9535247e9de01ca0741726665f7dfef1b1e6 [formerly 8fa7b76b92545e0b91bd06fd7b21247e921bbb2a] [formerly 3b7eefee2ac5120796c2a13583ea0b0b2d1ccb89 [formerly 2c526077c0]]
Former-commit-id: 57912c62749c5890285657c1b4b637925d480ccd [formerly 03b4cd9551d77589f25881cbf693c6bf8390db4e]
Former-commit-id: 77b9083e39607aedcba9ef9b4af9a94535661ffd
2019-01-08 21:10:27 +01:00
Henrique Dias
cc428d3cd6 feat: add no auth to quick setup (#621)
Former-commit-id: 56d5c323e0f176247779946e04664990b13146e8 [formerly 43ee26a4e1929560135c81ef2d1bfb60f6d15815] [formerly db983bfd8d1e9cea1e749b02ac11d933af05624b [formerly e0a3ce95f2]]
Former-commit-id: 20d14a1193271ef23c090dab1b3828ba7655b687 [formerly bdeb651589e0ca20ff669bfeb85ae0358e8e1d95]
Former-commit-id: 1f00d921e2a7e60f3a290b11603acc6a67a874a2
2019-01-08 18:43:04 +00:00
1138-4EB
9a54abfe62 chore: style and gofmt (#622)
Former-commit-id: 669963fd1d51d7e2d32520ffb0c1ecd5e4224c78 [formerly 8ef320b07699c842ae0325e4665d570fa4399481] [formerly d171df23332dff1d33f00a7407f5dc3f6dde1ef7 [formerly d0fd97d943]]
Former-commit-id: dc9a921b032e1acee0845186e7a009badbe768c5 [formerly 0c8a0f739bd1d984ca0db2b0623da5fdb813f4e0]
Former-commit-id: 3005cd15261952387fde1adf13770e2c1ee52749
2019-01-08 19:40:14 +01:00
Henrique Dias
c50a9b29bd Merge pull request #620 from filebrowser/chore-docker
Former-commit-id: 50fc6f67b7d60b6d30368e58f7ea612af0eefd33 [formerly 01f966c6f8f313a0cfabe43ab547724cb550dbd8] [formerly fd099dd6be88c96aece03fdbb83d716ac23eff16 [formerly a70b9e20a7]]
Former-commit-id: 24c6dfa4f95567a8c6a845243de4649dbafce660 [formerly a07b3b77be33f64ad9deb616c032e31b0c6ea2b2]
Former-commit-id: ad7ca28cac44bbd54e0f622aee02ef87c0777cbe
2019-01-08 17:38:07 +00:00
1138-4EB
3396218ff0 chore: update Dockerfile
Former-commit-id: 2ce789dc1facaee4afb7edcdd922f304b0b2cd69 [formerly 52c535b516b35996190d4bceded1502b622bed10] [formerly edc3b73e09591edf8bb352f047fe64da39c58f4e [formerly 5a0547b467]]
Former-commit-id: 87c2a4a3e4002a0a676470f9fda207486673b525 [formerly 0d790b609d7b0d96dc273f2241dedb0695b8d351]
Former-commit-id: 56b586a9cf0f851ad69b1db9e8e7046b5d57523f
2019-01-08 18:17:52 +01:00
Henrique Dias
04392a7328 feat: quick docs update
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 24d7ca4ba681ae4395cb23620fb92c19fad79279 [formerly f22f42daaaa18cea22f1a5c15544568d3c7bbb2a] [formerly 04e6ddffc5371fba2dfa1c0322326ed9b28ee73a [formerly 66010d877e]]
Former-commit-id: 10e7edbfb312764a8ba335a10aab2ca26392db47 [formerly d2fa614d1938fb18644957728634808b1d4acf5d]
Former-commit-id: 65727295e4f0e3758d235e08dd62cbf737b5904a
2019-01-08 17:00:36 +00:00
Henrique Dias
e1026a1fb4 feat: add docs info
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 4cc444f7168a76920c2821534027f121b7b0b0d5 [formerly fc1b399bbcf6cbd0a26db133ce644192664e4987] [formerly c71a14856c55345626eb7982e2bbe9ca0b7a1aec [formerly e68af011d4]]
Former-commit-id: b6ec8dd8817ec6bf028e1e7df299f8dd720628d9 [formerly 99077c4ca6faac93a1c956d96833faa3f2c40fe6]
Former-commit-id: 620919fdfd9f213cc61e4ce3b4e8650096a489b4
2019-01-08 16:37:02 +00:00
Henrique Dias
4703e0d36f docs: improve some cli docs
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: f7710895557fc2f181dc04b07cef1bf8e612bd9b [formerly bf7a392bc9e83971ddc9ae673f4fedf8772d3ed1] [formerly 06404f0eb55f410bb6cab197021bdd5e5c0991a2 [formerly 2ba5a4275a]]
Former-commit-id: 5a676627143edb8d7ca474b564fe2ab3c6b610c3 [formerly edbc0e60c66ab62df1611cda766fc8b3c8ac837e]
Former-commit-id: 2925d9dd6471f900c59adb495a5c2f7abfe0026e
2019-01-08 16:09:25 +00:00
Henrique Dias
2e1553542b Merge pull request #618 from filebrowser/chores-version
Former-commit-id: e4a254c445bb6f9e6012800101812847f2f7a165 [formerly 39f8661c8cb8a37dd379bc87685fa266e2c98cc9] [formerly ad43c963e3adce98b64edb3324f9c4912b4a5623 [formerly 58edf878ab]]
Former-commit-id: 66301024e8d6c34070382fb0b9db8e25a1055da1 [formerly cb29ecd9eec4ae6ae0cb422457ee1d794a51df20]
Former-commit-id: d4eff084d7aad39e384ec9cc0cd3227250a195d3
2019-01-08 15:55:06 +00:00
1138-4EB
438371fc9a use log.Fatal instead of panic
Former-commit-id: 5f02ba76b35ff67d57114729fc08e58fadc11067 [formerly afdbc0fb9d46042f3bd02d623d7d762a30edbd3b] [formerly 13ff37a836606b90cff13e0836e679983eaaadec [formerly 7a775c42a1]]
Former-commit-id: 99e8cbc7708b4c6c197220e21eced17aa11e242d [formerly 1404d4021cbcce848c106a8b15ee9bd989afebf1]
Former-commit-id: ae93bddd201e69d8069cc1ff8989e75d1adecec3
2019-01-08 16:21:03 +01:00
1138-4EB
6712fa580b enable version subcmd and --version flag for root cmd and all subcmds
Former-commit-id: a9e681d47d47f9f09a22d8479705f62672f509b7 [formerly b7d17db57156675b06897bc289fe616628a47abb] [formerly e06d3b13b547356fb928288b09aaaaf1a60b8950 [formerly b4708348c6]]
Former-commit-id: 43b18221e14269bada106e867b666f67a692c992 [formerly bee15f87fc2ecf5e8b4a0d74f41bde7617aef12a]
Former-commit-id: 733aaa6f3d5e3fc80dbb65ccc028d9f6ff6f73b7
2019-01-08 16:20:23 +01:00
1138-4EB
b660404bfe reduce code duplication
Former-commit-id: fa4946eff4f979e8fd3550a0b11f3ab147177b8f [formerly cd071c220157452a095325c049d801e99d2f8a94] [formerly 7a619be88fb162ddbf897387a31577fd3e94bfec [formerly ef56112711]]
Former-commit-id: 692897eac98f1d8d4a916d0ef0aa342b994a186b [formerly 69d9f127de2deadbbcaa0174fc1a4613ce2cb93d]
Former-commit-id: 49c5aef77aa74ec8352368627c98b9e50d417228
2019-01-08 16:19:17 +01:00
Henrique Dias
6ab8779948 fix: root
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: fc5ff2d807b0b8c6857c71311f061c7322af32df [formerly 19bd77dbaf743c53e7c8db08930e2a9ce6c0b675] [formerly 89f54b49d9d705b9a016827ceb1e7c0face0e56b [formerly 88644664e4]]
Former-commit-id: 3ff15179a86d330ff5f2a7f6b49b890d3ecd34fd [formerly 483a8a99b3b9dbe13ded1cf7fd608bf27b35a4d0]
Former-commit-id: 8115bd29a2356de1dd1cc2950248c4a3c07580e4
2019-01-08 14:43:46 +00:00
Henrique Dias
dd16a2e836 feat: update frontend
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 5b039e136b6100689309ded011501fb4a6dcce76 [formerly 54ace8e99e7ad81101cebb0dc44c5ad67b4af3b7] [formerly 1756700eaf0dcffd6b3888e613925905a123390c [formerly 68bdf65595]]
Former-commit-id: ef1cd08c5a36d4f28a6fd6d7d906b36f7b377051 [formerly d14c62b4510730c62bb2fba982c4cbaf96c804ec]
Former-commit-id: ed5c968279e630468c2ba6d1823a86153be78d4c
2019-01-08 14:29:18 +00:00
Henrique Dias
870b5b4079 fix: use server options from DB too (#616)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: bb60ec81f56f5d761ef76b2c1e26bbe83210f434 [formerly b28f83c65e0934e138a1710549f52e0f66a158e0] [formerly 7138a3215ceb144afa0ea45be2315f30b052109f [formerly 72069207c6]]
Former-commit-id: 0fb7ae6353f786edd93a9166141bfa446dd3dbf9 [formerly 5cb07e8c96a7cfca1aec5843123e1abc4ca8578a]
Former-commit-id: 914c0348516f072a9ccce4e105327feaaddb4cc0
2019-01-08 14:07:55 +00:00
Henrique Dias
66d485f639 feat: add replace opt
Former-commit-id: 7cc788c0560fb54cd098f4b6039b42d46fd78561 [formerly 7fd126f9152827162e9cf17dcd3ea293793ce504] [formerly bef00ad6a024835145bea635511be47b7e1f8a16 [formerly 76bf72902d]]
Former-commit-id: afc342bb45e4b8d3f059c33f2c60043f9612210b [formerly 149f17999b12be474cc91e2b821a528ce98adfcf]
Former-commit-id: b855a6691f1661b5d8af13a58f80773eda2d8a96
2019-01-08 12:03:34 +00:00
Henrique Dias
684366e050 feat: simplify flag adding
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 520945c4cd979999ce7da8cc60544e1e390de3fe [formerly 5c73f94c28f67f0fb25ecff7ce999480ff0d873f] [formerly bdb85560ceeac89408c8588213ef88c5b774c8c7 [formerly fc06f642f2]]
Former-commit-id: dc0c81b78cdec8656bd25dad84f9589486300d34 [formerly b18cd1e0bced8b34b31863fb7c4e714905bbf0d9]
Former-commit-id: cd84e54f28b9c56c3ced9da79f7fcb9a659f674a
2019-01-08 10:50:37 +00:00
Henrique Dias
01929c72ea feat: make server options a struct (#615)
Former-commit-id: a54bc7c8a0fb700d4f90f78c54d6cb028e8acea7 [formerly a0946a1d5b82ce5681684bc0f871bd892c4d6c3f] [formerly 6b23b0abbe5cde6a6348f982975d15a1161359de [formerly 0e7abaa7fb]]
Former-commit-id: cf9ea1110bcb8b5eb30ecd25db1928659ecea922 [formerly 38cebeff1f9e6b03760f7b277a3941f7bd733fb5]
Former-commit-id: db44c1d5ff8fed361849b5bf1fe48e04c75d7ce7
2019-01-08 10:29:09 +00:00
Henrique Dias
802318f903 feat: config/users import/export (#613)
Supports json and yaml.

Former-commit-id: d36b07953ede1842942b7ab477effeb2e5aa7d5b [formerly 51d0d5691d19e0649935816779a34b1b700e088a] [formerly 342f636293be8e38e7907453a67c67e5e9195c78 [formerly 73b8d2ee7e]]
Former-commit-id: 8ef6a1563ebe425a15a8229165d2ddb043cefb21 [formerly 01c4ac1d89e0d5c6ed16bb7f23c2bbe62085d6e5]
Former-commit-id: 6d197ee1931889571c61ad0920e4352d4b02b264
2019-01-08 08:57:24 +00:00
Henrique Dias
b9acd275a2 feat: remove useless code
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 7cc4780fb876e5cbb50a2918bb7f59ef27c9df69 [formerly 172f465b8292a1427ca957034c25bd989b27665a] [formerly aa4115896142f42f126f3cce34256937b03c5e04 [formerly 46b221533a]]
Former-commit-id: dbe998a5acfe50a763cef63316c824c49b626dad [formerly 92d7264061e532ceae3a98861f434734f4488b90]
Former-commit-id: c09fb725461ad375bac46a2648a588a1b6d88ffd
2019-01-07 23:11:00 +00:00
Henrique Dias
1809a3638b chore: update ricebox path on caddy repo [ci skip]
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 92566ce4d867c9ca04840bc8a10c72620bef7988 [formerly b417064bd37ebf0d30bc38b6f2e463a1ca3d5531] [formerly 8c167e6c20cce29f068d9ef574e5a52830c4b2d8 [formerly cae8809da0]]
Former-commit-id: 45bc3ca821d054bb8b96bbc58f8206268cd944b1 [formerly ce0f48e3b4673ae70aca38fe427a334c8129b4ae]
Former-commit-id: 69b5cd589a27d444adbb83b8f1ae7fbd7ed4709f
2019-01-07 20:59:55 +00:00
Henrique Dias
5a83d6736b fix: rename global scope as root and fix root md
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 856c18bc9cf98a27b6cbea923b231e0aaf279190 [formerly 201c1a0294947930a7d0706af72ce719a8cc3b98] [formerly 0253e57e2994023e798f6fb0ae76f9c21d18fd69 [formerly 33a58c999a]]
Former-commit-id: e7d88b22207125c29ea85a5a539653a54584999c [formerly 77cb1e0172cdf7195cc25d557e5028a9250d655c]
Former-commit-id: 64288f5a475a82d5f88c91347a09aea67ebb169d
2019-01-07 20:34:44 +00:00
Henrique Dias
77e1fe83db feat: wrap commands to send info (#612)
Wrap commands in a better way to pass storage

Former-commit-id: 9a3790c193936b53fe3826d1e051795efd30670b [formerly 04a9f34933a162cf4a98bc1e019f0d6c6404aae7] [formerly ab9be7f27b55a94e6a0f053df6908e357d4b396c [formerly 01ff03e426]]
Former-commit-id: ae7b61281dec2b5527f6032dc6f8c1bd8bb51296 [formerly 780ccc3b166e72bf53114bbfc0a95c0b7ffd8656]
Former-commit-id: 68ee8f7f3931f8e571b0188c96951077d6529cd7
2019-01-07 20:24:23 +00:00
Henrique Dias
1133f0f826 feat: rename import to upgrade
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 0c8eb7bea0cdf9745385fae660532bda9368c7be [formerly 5fb38e8b21346fa41fe0602929cd4f7f6fa19fa2] [formerly 9f39ca06f86dcb7c64b69ed4227789581f140397 [formerly f396602084]]
Former-commit-id: f310a5b4d7b1a54026dba8ccb637bf2ad5bf531a [formerly da06cb70d42ae5c2a4b0927f661b0026ae972792]
Former-commit-id: 23d0481a4cb60a70ab1b59bd8042c3923d161917
2019-01-07 19:22:32 +00:00
Henrique Dias
981b42fb5c fix: remove init from root
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 0a29d1eb40c1df0ad039959d3dc3ab4e5ebe328f [formerly eda99299d47c005f30bc04123403d9a739fd4933] [formerly f0703faa441e10b681854c71e6fb9fdbbad6ac44 [formerly 148d233d7a]]
Former-commit-id: e2162f9ac885704fc60e0b427b8331207b960712 [formerly c39d1dbdb49c5f534c69d6359f3afc793bcf5632]
Former-commit-id: de358cd75d688ba93fd4f36b8c5f3aadbe58ca3f
2019-01-07 19:21:29 +00:00
Henrique Dias
c59d42b601 feat: improve docs output
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: af19a86cebfe955619d5e05cfd5e9c4101a328e0 [formerly 84df35184bd684e00617651b0115b219e6e9c88e] [formerly 697906b1c6c4e47a03518edd50f5e3d86ea16690 [formerly ebaed3c390]]
Former-commit-id: a89ca0fd17984ebf6e95596ed515ad1592d314b6 [formerly e776a061d2628054eca107076601703aa2c7575d]
Former-commit-id: 7c809138219ef4723ec1ae47252eacdb60f7d78d
2019-01-06 18:36:47 +00:00
Henrique Dias
f70fc2d954 Merge pull request #610 from filebrowser/hashedpwd
feat: require hashed password and add hash command
Former-commit-id: b8d4bd7c9fbdde724beb62c77cee1daba15d315b [formerly fadf295f423c8979fcf7a704b05cffc3a0735d2a] [formerly e4a9044cd0a94b4f4fa1a8f441c563fe0a564a62 [formerly a2d32438f1]]
Former-commit-id: fbf8a1d1e85646a43bf220f1bb73d40481da7df0 [formerly a5b48143fb9c39da6b1b8f43c1e80729892a1837]
Former-commit-id: 5ba56215decd17c9c2b8cd59546a7181cef96aea
2019-01-06 18:25:09 +00:00
Henrique Dias
1aec3744d7 feat: only hash if it's default pw
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: f25a675cd60a328715febb7e6e799b28e3dbadec [formerly 09fc814b175a9d6ce7669daaaf64071c9de8d951] [formerly d53b7af3501535f25e74aef463c4b9d821486aa4 [formerly 550269d2ed]]
Former-commit-id: c21b1ecc3bdf6b1f8c9de8e18ba8d9a2777f0b27 [formerly a31b1e0ae18bc0bf69e83f564dfd50fb6b2c38b6]
Former-commit-id: fc3ee85d741cd83eda2961bcff91fb9d5ebc42d1
2019-01-06 17:55:47 +00:00
Henrique Dias
25792232e6 feat: add hash command
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 4d1b43927775194e96b8a9a3ae13fbffc21df572 [formerly b738daa5a48369b1fd5140a70b8b8965a34109e4] [formerly 5d2eefed13d38efdb480aab2d61a2e06244919eb [formerly a2742dff16]]
Former-commit-id: c4c6b087a91ea3d781fd5e5bbf9c511a9c25a312 [formerly 0aedca54ba1e98ad63e863fdd86e50123ad9078f]
Former-commit-id: b4581ad7c366baf486fc1412eaac4c6f9940b979
2019-01-06 17:53:47 +00:00
Henrique Dias
2869570a20 docs: update caddy issue template
Former-commit-id: af5dd2ab18970ed2a2792eb2bdb061d1540a67d3 [formerly e4563af635b2fe1d6d8abc6bcd07f120378f1cba] [formerly 633630c52d61cde8b8d5b31096a5621fa4063e84 [formerly 56c1536693]]
Former-commit-id: c58ffbae57cf39c342c5ce8bc6ae73b765edecf0 [formerly d4981d9243a139b6a96d791ef89f03c33a830b6d]
Former-commit-id: 01a668e7d5644566257d4f689928e5194ab5e59a
2019-01-06 16:39:59 +00:00
Henrique Dias
3a4ff6dbb2 Merge pull request #606 from filebrowser/viper
feat: dockerfile & viper
Former-commit-id: e819374dcd28bd939b0d3105f338a51cadf112fd [formerly e2886cb88a7642e9c681cd21205fd6f178e782df] [formerly 776586c1e92a0adcd0797a6ec8f95d7a0c177e65 [formerly 143dcec6f7]]
Former-commit-id: 8160ef39bcc5e01ff1489523240de0b59beb5bf9 [formerly 19520a57cc82f85178a5de7feac00cea3848791b]
Former-commit-id: 67518c991c6c4c3a6a8e8ffa5762001f01536013
2019-01-06 15:27:23 +00:00
Henrique Dias
42134a4849 feat: cleanup cli
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 2923c251335301f361098890bf67d47cd58c0f86 [formerly 277653e21c4b9077ea3b83c149f0c5b2982b694f] [formerly 7481557b6f47c8de6499f3ee7339ea8d29216700 [formerly 999c69de5c]]
Former-commit-id: 65eaacb4aee11f84c9f97ca2834def045921202a [formerly 7c9260a1fe142258dd0ac02c4710b03badd66d76]
Former-commit-id: ff3f3d7189b2e8cc2f00bef581cba108780e4552
2019-01-06 15:26:46 +00:00
Henrique Dias
e5c150e83f merge with master
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: dfac33db9ca3454cd3af02a732a64a02a8268b01 [formerly 38be015f7b3376a3bc992725c1cb1a019c1843cb] [formerly 5a4e310b96ebc5895e64f8eeb2f592890d4b63b0 [formerly 2b8bd28158]]
Former-commit-id: a30bfcebe6bbc115990b8f8398171b32942a8767 [formerly 553fafa22b46b2689ece093f3b0cf85b3cff1c87]
Former-commit-id: 5ce047d4e3f5217a179685f8b2850d4eb157376e
2019-01-06 13:20:17 +00:00
Henrique Dias
f1a89f5ec4 feat: add global scope (#604)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: a44ebfc7a5687b5f51f0ff791335f66ab9f2e8e0 [formerly 9a044fadd8f2ebbb7dbb773273799c26a797f513] [formerly 7f374d016eaf756cfce215dd16a2274bbabe1915 [formerly f55f205ced]]
Former-commit-id: 31015ddc5f4fc28c895743f6fe9dcf5488bb4b01 [formerly e439027304a1e49667fafde011e07d043ef0d2ee]
Former-commit-id: 0394c60358673b56991364260b1cbe41fa457593
2019-01-06 13:01:42 +00:00
Henrique Dias
f2d952bf0e fix: dont fail when can't detect file type (#609)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
Former-commit-id: 3dbe943b6d64bf7d3f6c6d8970d2608438e4c2bc [formerly d5238a25f0e31dee84367a5e27b6f68ab50050d6] [formerly 297d8be6b3aa5e5411634286ba4faff256fd6837 [formerly 07f3ee38e5]]
Former-commit-id: 5a568c9eff47b5fa54d3956ecc2d2a55cb31fc8f [formerly 8d7f78cbf47a8a84f02324fdd858782e4b67b0e0]
Former-commit-id: 1343ba84d9c8952bd9e210cf7f23b70129236c81
2019-01-06 12:59:53 +00:00
Henrique Dias
70733ff846 feat: change default to 8080
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 4bcba1cc1d4f275c68b1e3a32045f6ec1136d264 [formerly 990ef78e797dc4a9828a6dd8c5c7162e06c6af3f] [formerly 1a4f246dc04fc76b0dd9656beb010d03fcef8045 [formerly e22598a126]]
Former-commit-id: 649df28a7201a0fefbd57b6faf56046fbf46c7b5 [formerly 7c763bae4fb9072920cc0907102583e15d1a7afc]
Former-commit-id: 163cfb1164e3f2be099722b013598fd9aba6611a
2019-01-06 12:57:35 +00:00
Henrique Dias
94619341f2 feat: simplify future changes
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 1fef9a9903b88ce216c4863a2c13d18030883f01 [formerly ab968c3e733db147d0e185934f03e7f965e03fde] [formerly a8e8e77ed08ca600abc156ba1cd57aff1af9d5c5 [formerly 12eb050cc2]]
Former-commit-id: eeb1864fb4c2c0d981c657a54c2d1e2a83a260e7 [formerly 09d661a1172e93b8e6a627dff2870b1e1c5903c6]
Former-commit-id: 5974a6e8e1309855e58160e6fa827de6dc5b9605
2019-01-06 12:41:52 +00:00
Henrique Dias
36bd2907f8 Merge pull request #608 from filebrowser/dont-persist
feat: don't persist server data on database
Former-commit-id: 768c9ce33d1f24626f94f1de558624382ebb4d97 [formerly de47b48b656299e3e9918e302257b031fd73bc34] [formerly 0304ed3fe19248a7635c06db5367478e5c5ac7bc [formerly 02c34ef8be]]
Former-commit-id: a780a2b2f96b2650c35cd65e3ece26cc1c58eb41 [formerly 4cac4d8b2e52632711d50e59c07107d677ce1616]
Former-commit-id: 930d1650c381ce4e02c79d29b2d3bcd9062828b7
2019-01-06 12:29:31 +00:00
Henrique Dias
f879944346 feat: dont persist server data on database
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 2ba9d0a5d060380a73ec1b46901a6f16a5e985a1 [formerly 1cd1c62eaba87c166d8fe10baebfe27bce0448a0] [formerly 3d1721671fb760a4b99aa66fe7d5a8d00579b17c [formerly a8ff679ae3]]
Former-commit-id: ff84b7c9f8982292219b6c673ecbe60b231cb567 [formerly 2cf251aa108b3415e766fd05dd268ccd05f0ee1c]
Former-commit-id: f112fdbd48836c509981cb93f41a47ff0eff77eb
2019-01-06 12:26:48 +00:00
Henrique Dias
d821418bca feat: update frontend
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 3454ae3d39d1739b4c586f099442894cc64b4473 [formerly e2024dbdb835a464b91b843d73ffbbb5ca84d190] [formerly 5ed6bc9695aa06e86ad6c67afec1af85d332dacf [formerly 22f2287bc3]]
Former-commit-id: f1a65e8d41ce28cc9d9d849d14ae407e48c58535 [formerly 1000226a97885b3e0a88aa3f0afaa7901ad4166d]
Former-commit-id: ce067696dd15c98f472d8cbdd77e764a6a1efe0c
2019-01-06 12:01:44 +00:00
Henrique Dias
a21198be11 feat: update frontend
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: abe6d7d161c5623b479a0331bfb035bad0e3ac2b [formerly c7de783f07988d163a19f5c4f4274de029fbc4dd] [formerly 776a733a98306debc757ca1048233b24d7823987 [formerly d97bafb53b]]
Former-commit-id: d405dd0600ad15bc6956c417f8894b8c51efa805 [formerly e9499a12c629884dd194e9ea4867fb07f3500735]
Former-commit-id: 36df4acbca806758aa1d031fa1e9f4ae041e5830
2019-01-06 10:06:39 +00:00
Henrique Dias
70042f4489 fix: allow embedding into iframes (close #550)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: fd99b98b820e6d7bfe0e5e2c7cb0371e19497c57 [formerly 9c306af4416794e5a2e0d9165960617cfeca81e1] [formerly 9267510624a99cc72cf29ba671cca797d2f441e3 [formerly 2d858e6738]]
Former-commit-id: 3004c1182c71f3eb094d2ce1f60e5ec4364d00f8 [formerly ff39e10768468f8eb2580fae4aed5f9242925dba]
Former-commit-id: 0f7df8698160a72d74d6bdac41573b8c9c48cc4f
2019-01-06 09:29:23 +00:00
Henrique Dias
3890a9a416 fix: do not read whole file on listings
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: c630ed523a9f599c3dd1eda5930baa020d0b9911 [formerly f89f524d2979e43d6c2fd99903552bfe89addbc1] [formerly ba05ce7e5c730a04681910d87378dcdf3acc809b [formerly 28b326ab1d]]
Former-commit-id: cc4832f376eb2e5d5c99dfdac9b1966448b4e48f [formerly f254f221fa44f016a8f22cb3414580bb3a57750b]
Former-commit-id: 66c66d82ade69e62d32e05f8350166b2cdc3bb12
2019-01-06 09:24:09 +00:00
Henrique Dias
a58b64085d Merge pull request #603 from filebrowser/feat-viper
Feat viper

Former-commit-id: 688b44305afd67a5c018c7147d7b92d74978594b [formerly 6ddcd63bb1b210403c6ec3175bc8081971b82a96] [formerly 637bfd056f36ace26e958444318f3cbfc921c41e [formerly 72402b0274]]
Former-commit-id: ac60c7fa2da5bd5baa0522e106bbbff81ea2525f [formerly 8502db4715fd84e41665d97dd257ba1b27bb1dfb]
Former-commit-id: be28f4eb5496598b825bbac154906a33988bb224
2019-01-06 08:09:26 +00:00
1138-4EB
90b7f4aaf6 [WIP] add viper to manage envvars and cfg files
Former-commit-id: 99d241dc790629791b67b7b2ce20a10341a1c1e7 [formerly 08e8410bffdb50134a2d6ccbe853b25d4c4d3fc6] [formerly f32b18d9acb42ee1988c49b7980a16a606cee142 [formerly 1080bfde68]]
Former-commit-id: 318c4f159697e896bcf824e274907c5c03046bf0 [formerly 82533ae817673dfab8d56533f15a9931c0c74c1e]
Former-commit-id: ece42aa8e8c7480a5a21614b6ca397b71a01e1fa
2019-01-06 06:11:15 +01:00
1138-4EB
2def76df83 fix Dockerfile entrypoint args
Former-commit-id: 1569bdc5af20784b25dd1350dc640c99bb111736 [formerly 92e50eb0b6bc61b43f93515c79f7bf5741ce229f] [formerly 61cfe864e8dd0017060249b6962a5fa67bf1252f [formerly 09a6ffb1f3]]
Former-commit-id: 642e1ac56911282dfbea5e7c41044cc557d7c39f [formerly 8df377f2bda0c02c3b464529c871ccfb81fe968c]
Former-commit-id: 82ecd4ab3a9fce2c9ade430fc85417b9270c634a
2019-01-06 03:36:08 +01:00
Henrique Dias
1db210a24f 🧼: remove comment [ci skip]
Former-commit-id: 6560b8172709c5e8809b734eaf82139635c24905 [formerly c172a284c4c2bce5d7f82a13dda7cdc78d5c7d66] [formerly b75b0b28ef23b9e341628054252f32eb08f9933c [formerly c830b80269]]
Former-commit-id: b482c5c90f95166aaf3c368d136f23c67531d6a7 [formerly 52b0e3434d83a82f55aa6a0157a35578494b5aa0]
Former-commit-id: d1e5d7262a89f20f80274be277c9e388af56f20e
2019-01-05 23:56:22 +00:00
Henrique Dias
b0586d985c feat: scope must be set on CMD
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 328b2a0ff52cb16c90158fff624f61230341b340 [formerly 68c35fd1abf023bdb9e1de101834f9b680c23dcf] [formerly 24554f91091c9d30073d4a98d462bea8d1928970 [formerly 3939e7b99d]]
Former-commit-id: ef97962090dad10d21924b476ec79b0fa92b906c [formerly f242696e812a57876edf282e0a7304860bd04b1f]
Former-commit-id: 85b816ed5ff5cf47ff2ae8a26f4a4cd99b1c29d6
2019-01-05 23:49:18 +00:00
Henrique Dias
a52374e288 feat: correct db path
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: c9c695d3b3c51a1e6f75b2319e52eb7a67221411 [formerly 4c1416815a2e2facf55f1fab9cb564b9090a305d] [formerly 09022439361037a8112f6421cc8eb9c6d5b93572 [formerly ed3d32e3ba]]
Former-commit-id: df28f382068ad0b6b1c4d2e2331ef035e54541d7 [formerly b7013cce5004ed0f8c0a157a8985949b11c73b35]
Former-commit-id: 49830926e40c5ac6bcbd9495a15c91ee6c1158c1
2019-01-05 23:48:51 +00:00
Henrique Dias
277f13a350 feat: update dockerfile
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: e6b5d4dae3b1c92e5f45d1871d2cf522ebe231da [formerly d96f427f565caeaa73d496f1cfe5797849cbfee6] [formerly ecdfa88ca15f22287b8a145b1a32deac51febf54 [formerly 365eff8ca4]]
Former-commit-id: 7035068a2d4532448ce5f99df3e44a56ef70abf0 [formerly 22078ce93001feb79a7fe835ab33298287ffb23b]
Former-commit-id: 4d4576f98a9d992501e4ee7cd7d90a7dd319fabc
2019-01-05 23:47:56 +00:00
Henrique Dias
ea434ffc04 🧹: gofmt
Former-commit-id: 9548d370497e13d436abbc670cf40d360badab9f [formerly f29ba9c4dcf9962c3a5045629526296cd2b43ad8] [formerly 3f89c094c1b3330c8d6f1b2379d6309567d12210 [formerly 92fda0070c]]
Former-commit-id: 4ad64211019e0236f0eaa6e041a8793e899954fe [formerly 6bf71ffba205b563ff6cd0c7487d9a328c757686]
Former-commit-id: 4c7afe072fc3e2a225ca5a7dbf3f3beb66b44058
2019-01-05 23:01:16 +00:00
Henrique Dias
12b2c21522 feat: v2 (#599)
Read https://github.com/filebrowser/filebrowser/pull/575.

Former-commit-id: 7aedcaaf72b863033e3f089d6df308d41a3fd00c [formerly bdbe4d49161b901c4adf9c245895a1be2d62e4a7] [formerly acfc1ec67c423e0b3e065a8c1f8897c5249af65b [formerly d309066def]]
Former-commit-id: 0c7d925a38a68ccabdf2c4bbd8c302ee89b93509 [formerly a6173925a1382955d93b334ded93f70d6dddd694]
Former-commit-id: e032e0804dd051df86f42962de2b39caec5318b7
2019-01-05 22:44:33 +00:00
1138-4EB
53a4601361 chore: setting untracked version [ci skip]
Former-commit-id: 08352e25250ae60eca3289b81227833cd59c6122 [formerly f05e75cd9d0a34dc1155a348c26c6f1ce16d5973] [formerly 60bc13d70b80580426a7eee48a83efa4da16fdd8 [formerly 013ddf45c7]]
Former-commit-id: 591b084ed5dd5ebb0b5661f6bbad33dc5a19fec1 [formerly d3ca27f95cec8bd4b2557eb807699ae801b14804]
Former-commit-id: 993c87748dfd43ab90bed637a21bd008713299ba
2019-01-05 22:26:41 +01:00
1138-4EB
4c7c507830 chore: version v1.11.0
Former-commit-id: ef29aae8bce2a6f7065f17e5a67a2ae7f0757ecb [formerly 73e46c8be3e8eeb30dbe09e1f32a23f0ad72b0d4] [formerly 4edd4c5782b442132446486132a5adab9d6f15d6 [formerly 663e0608b9]]
Former-commit-id: 2d337b53eff21b0ac7b42ac217a348ae683b75f0 [formerly 6af864c17bec27e4eed20ef2e0cdcd12a65b23cf]
Former-commit-id: 5ea70d7c172c1f40aaa1a718b6972935d3b8c688
2019-01-05 22:26:40 +01:00
1138-4EB
bc8d19feff fix goreleaser work dir, go get
Former-commit-id: 77e16f340827015ab03b517fb573bde6e864e170 [formerly 5cd6823a69867510bc37532c31737107a95d2f26] [formerly b84c196ad4be5a099eb4153f03431b419d6694b6 [formerly 77868b2647]]
Former-commit-id: 906c949ce79f94faee8b795ef66622d557281964 [formerly d401d2ea6393e4ed133563980e4fea3fee0c64e4]
Former-commit-id: b2ce07cb1c0a969a8cb62e823cba5f617b19f0bb
2019-01-05 22:26:28 +01:00
1138-4EB
f77009365f move filebrowser bin to root
Former-commit-id: 26f855618a8be4f28fe05bbd04ffb1c3437d6e45 [formerly f49857b8acd81f2155d5dfcd83d5362f6b91f846] [formerly 27a857c6d63f7dd795613f2af44b563e072c7453 [formerly 3988bdb8fe]]
Former-commit-id: da0d6b6921b340df1ae4a77a3306f56a970cf0c6 [formerly b56f8c43fed299ca73ba155c76c74b76a2347a36]
Former-commit-id: 06329d841c54b4d58a73b59bc5ab8a64e62f35ba
2019-01-02 03:35:35 +01:00
1138-4EB
74e93b8df0 replace gometalinter with golangci-lint (#596)
Former-commit-id: f43cff5a88f9b70f593cf612832428f71decd92f [formerly 7f5f957bc17fb9e03b37224a1cc31ad65af5468c] [formerly 8e8a054716b10a3999bf75deea0f0d3759c1ac42 [formerly 835c37d1e3]]
Former-commit-id: 970cbb1ad8489d7117ee580339709a07652def96 [formerly f7a47fc1f409b3acc390fa039c0076b208931748]
Former-commit-id: ec3c2df078a903c6485dd74207e34bab08f1d9c1
2019-01-02 03:13:53 +01:00
1138-4EB
901dc2c160 allow to set default user with env vars (#591)
Former-commit-id: e0e798642757d7a5017fccf0edd4d65a4181359f [formerly b354327fac46e7b721e2baf6fef5877944afb400] [formerly 3ef64ca1637c2145fd4a776f26afbd1b426d5098 [formerly 0b66d700e8]]
Former-commit-id: 192b543db9d3707eedd8745833020d603fe64c21 [formerly b7b034bd96ff63d185ccf9cd20cbc7673eed7de1]
Former-commit-id: 4fca72efa7aac242fec991da5330e78ef455d12e
2019-01-01 03:18:58 +01:00
helloray
b5ee82c943 fix multi-select files download error when filename contains '+' (#571)
Former-commit-id: fda2e75979b6d48ab77e1486d0d65375cae8ee03 [formerly 0ea1d769d4a591c522e7a642f386e3db579ce913] [formerly 230ee6abca47dd4a212d1481a294fc30972f3545 [formerly 7394f6b9bb]]
Former-commit-id: 3786998d5b87591db765e5388886e217a3c58dc8 [formerly c4954221ab23794024ced09d0f858c65d0d82c23]
Former-commit-id: 42bfe718742895fa9e03bf5dd5c1e53c826c510b
2019-01-01 02:39:45 +01:00
Allen.Guo
8e4805ba69 set threshold for large files (#558)
Former-commit-id: 9b4aa87da78f2a9ad539e4229a5a1114a5716502 [formerly 0767dca86d42737c75bb7575015f9c29e35a55a2] [formerly 65887efb2d961d40c95374ac2336e76e53e3b4b0 [formerly 802bcd8cbd]]
Former-commit-id: 3daab729620942ea0403f618588e731f90717e17 [formerly 5197f129ce4425a8716279e04f4e5b3653901c3d]
Former-commit-id: 0cb78fc0e87cb14ee540f2d3a2264d7b081c8985
2019-01-01 02:22:09 +01:00
helloray
694c750561 fix directories in search results can not be opened by click (#583)
Former-commit-id: ed2a9a08fc9488bf4ad9ad6124d24324dce7bc4c [formerly 8cfcadb62184144e58bba8af3b6c47ace2f6050f] [formerly 040d07180c51944c5f5d713a86db915365c829fa [formerly ea3576da7e]]
Former-commit-id: e653086b78975f878ba0f6f397715c61f8fb53ef [formerly 1b4d65cd703b6c37fe6589da29c25d565783fe27]
Former-commit-id: 1f073a343adb693ee4d9153309a664520027908e
2018-12-30 17:47:45 +00:00
Henrique Dias
efa3b3f198 feat: readd dos2unix
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 7a00285b53dc2a67214cf2a9a8111794801cc7ab [formerly 0dd178342671e6c201a2ea86d6699b52c03fe4c3] [formerly c25ea49026485af46401c2bf359b3dc3883711f7 [formerly c01ebf33ef]]
Former-commit-id: 489505f6219c7ce5476717c8cc054dd7e648e29b [formerly 2d81af6b62d26914f7d3b48d4781a5f5196769af]
Former-commit-id: 8e72aee50d6cd5a158f791c3aa8a1d2f3fa4ca6e
2018-12-28 23:39:46 +00:00
Henrique Dias
998dd9430d fix: move everything to LF (#588)
* fix: move everything to LF

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

* feat: metalinter

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 3e371bf0dc4d8205fd2ab4d1b64328b7659242c0 [formerly 5c776eafad1350b9f55b3417bf63f51d372e1663] [formerly ef8552957375306c1ab58db6cead3fdf92bc1758 [formerly b344efef2d]]
Former-commit-id: b8e19acffb00ef1546a7005b1956a858038199f2 [formerly 2b9920caa1bf71b44f245ee3d246b41170f5aecf]
Former-commit-id: 36c7a82150c1ca5d528aeb7aadae243661966560
2018-12-28 19:19:54 +00:00
1138-4EB
c8b5728743 add go mod support (#586)
Former-commit-id: cbe15cc342afd93705ee0ebd588313dad64ad45e [formerly d8de1b0940a83510fc5af2d35b04bce5d34fec60] [formerly d5b2b44d09de2740ebde690b9eb85d5ac5bbcd0c [formerly 4945635bd6]]
Former-commit-id: a56cc4805870bedf858ca69d9692188d69bf9bef [formerly faec73a01496613eaa0ee1512d77a8d62617cac0]
Former-commit-id: 67b5db918ee3295f5d4223b68e11504ec4f70491
2018-12-26 00:48:43 +01:00
Shodhan
fab33e3ed1 update README.md (#568)
Former-commit-id: 901577a2f334e78051f75b4c4435abe655c634e0 [formerly cd82cd950a318fe28e86621667a8339996e44cff] [formerly a480ec089d539fbc0439181b5505e6dca6455e28 [formerly 59f28638c7]]
Former-commit-id: 5119d459fcdba021f4e23f3705ddc0f9bec0b161 [formerly 8d30555b1c6f7328d4e07c41043cc370c0cc0154]
Former-commit-id: 4a30913f85528107b8cf5f5f62c7a8f6aa3746f3
2018-11-19 03:21:24 +00:00
Henrique Dias
5079f405fc docs: remove old disclaimer and add new one (#533)
Remove old disclaimer and add new one.

Former-commit-id: 26caff0046abe585e1dc58c7f6ca728254b57883 [formerly 9915c1da01cdf3742c49625028de3646f4cc0218] [formerly aad017cd8c74480cfc978c830f83346c5e410bc3 [formerly dae992d4a9]]
Former-commit-id: 0fb7d01241ec6fe633624710bd7d4a2a713ca119 [formerly defcc61802d496705a16de97c30ad5ca2e7d8497]
Former-commit-id: 2dffe9f988673bc9c4b83638190f70ac579b9e38
2018-09-08 20:30:39 +01:00
chinglin
b85a07536d fix: recognize small text files (#531)
Former-commit-id: c4d7475d7fe858562fb5f45dc39164aac2463cbd [formerly da7f7862848b719e71b0b4af9fb4c9813a2c1629] [formerly 264f015d1a736fd5d237e7895d3ee142b0137cee [formerly a0194899c9]]
Former-commit-id: 218bd162ee8f5222fdb0c717b481524c210ded7a [formerly 916f1ca36e2439e32d1b6a8baa0eee7a8efd290c]
Former-commit-id: ad2dd70b88612c8a212c0351abdeae9da442e21d
2018-09-08 19:03:12 +01:00
1138-4EB
7e3a15e073 chore: update frontend
Former-commit-id: 701a87afa3c7a8c7dfd15458fe2c23c2ebffa322 [formerly 743b8fcd60467068ce0bbc7129a6481d3feb740b] [formerly 4f705a9a56af47da1c06cc6e7ce779890dedb7e2 [formerly 43707a68cf]]
Former-commit-id: a856ab9ac4e6e3d2716997e0ef0ad5b62eb55cbc [formerly 21503f038fba99e7ec45fbf9a6de455fe860b009]
Former-commit-id: b3cde7867cd25d02a95a802761aa9956f15ddd58
2018-08-24 00:24:38 +01:00
Equim
aeb4e2aab3 readme: fix ci badge
Former-commit-id: 47ccac39f49f20424b045e69bd41c16b958d75e9 [formerly cfca8143a46299a6044da9fd644aa97444c03f61] [formerly 61a6608b440440ca14dbad171abaa7b581cc430e [formerly 516aa80c86]]
Former-commit-id: 710cf897c71bb8e5fdd3726e68ddc44b66633634 [formerly 8d1f3a87ab4580dfbc051c04d72201ee0cd878af]
Former-commit-id: 3bdf49c3539bc73d8862dbdf19545547a2aba375
2018-08-23 13:47:44 +08:00
Equim
bd65bc9e44 readme: fix ci badge
Former-commit-id: b8e5a0df76108e9d8c8341899e5270c46f4a9ba7 [formerly f86e9cb629e7dfceddb7e1fa3dcd701394d2933d] [formerly 3c80281d4fc173ce9fbde95823344456b8b0ee93 [formerly fc84aa65a3]]
Former-commit-id: 49a0f985fb5c0e78a532300a3192bfe8c1565c9b [formerly 78cdcdcedc20829ed77f6e2759391c75a4352f18]
Former-commit-id: 2edfc4473e44cea69f7f8423109111fa29abc248
2018-08-23 13:45:11 +08:00
Hugo Massing
59468830bb fix: search case sensitiveness (#515)
Former-commit-id: 7d86ecccd2095be6bf7db6fa4b93e226cb590661 [formerly c6e3db510232dad7f175ede09481dd3c14cac26c] [formerly cf4dfe6c7ce811d489292a0896b4de46a89bfdc0 [formerly d16352b0ba]]
Former-commit-id: bfa8e15160d458a77c9a1e5cea759d214716dbdd [formerly 74fa0134bc42399b0f3a6627791efed6f5176fa6]
Former-commit-id: 04d04ac91ad7047afc541d5c43e69f81fae54f2a
2018-08-22 16:25:30 +01:00
1138-4EB
d7c3665e2b chore(goreleaser): adapt main to refactoring (#506)
Former-commit-id: b3489300998867306df6e168ace939c8e5d02906 [formerly 9bef5d82435847fe679a298a6e0bd7ba74361f09] [formerly 4e385aea825abd7f4ee9f2eb9cdad7f6acbbe061 [formerly 3372f0546d]]
Former-commit-id: e221415d23a3f6be129fe921d429414b4199b772 [formerly 8cefe1aabe6f30fb9b415e009cce96cc3b00f019]
Former-commit-id: 17b5db1f79eb41e90fdeac2f85178f5ce777dd33
2018-08-22 13:24:34 +01:00
1138-4EB
679b0f0f4e chore(version): set CLI version from lib
Former-commit-id: 687a0a5f65c1e246110f11832a74aff227aea9b1 [formerly 6066fdbdd709de04a8362868084f70fb04a24c66] [formerly c29860d9846fe01aadffd393753265294749fc3f [formerly 0c53f06c64]]
Former-commit-id: cc10a50da0a49f97455a59a7e6e8145460168407 [formerly ea1aae8d790840e5ac7e86556f59316b476b1218]
Former-commit-id: ccc7c07a75dffcd5306a537bef2a5dce8a8f6051
2018-08-22 13:15:55 +01:00
1138-4EB
7d912dd257 chore(dokerfile): load config file implicitly
Former-commit-id: af5491f1958594a033cceea64bb988e427141952 [formerly 24659c5c4693bb2f7a4930e748a79e329dd6e45c] [formerly 9b3bc71ac1708475648c0ec0207584a5690ac91f [formerly 0f2be941e8]]
Former-commit-id: 9a1f8040210fb026e6741517640bc583915727bb [formerly 971cd99c1c3734d352b6f07664f05245b1672047]
Former-commit-id: 653b6e78a6d562db4374f5e0ce22078cdc670fd8
2018-08-22 13:09:21 +01:00
1138-4EB
a92d7aab8e chore: add version to subcmds
Former-commit-id: a08e327cccff4586578c71b6278b46c9d802f4dc [formerly 0b5e200ece501efd62b80c11f03518f5aac11c87] [formerly defeb96bda2355d30a5fd0d9e6a3b6c427b170b2 [formerly d5fcb555cb]]
Former-commit-id: bf7ccdb941b150562153ba61609db38922191b97 [formerly d6250e9ca18bd318f0fdf742fc32e0404998e2f3]
Former-commit-id: 867dec4689e6ed85b29c6501e37da85801783281
2018-08-22 12:30:55 +01:00
1138-4EB
0536d8342c feat: use cobra to provide subcommands, move sources to lib (#506)
- Use cobra in order to provide subcommands `serve` and `db`.
  - Subdir `cmd` is removed.
  - Subdir `cli` is created, which is a standard cobra structure.
- Sources related to the core are moved to subdir `lib`.
- #497 and #504 are merged.
- Deprecated flags are added. See https://github.com/filebrowser/filebrowser/pull/497#discussion_r209428120.
- [`viper.BindPFlags`](https://godoc.org/github.com/spf13/viper#BindPFlags) is used in order to reduce the verbosity in `serve.go`.


Former-commit-id: 4b37ad82e91e01f7718cd389469814674bdf7032 [formerly c84d7fcf9c362b2aa1f9e5b57196152f53835e61] [formerly 2fef43c0382f3cc7d13e0297ccb467e38fac6982 [formerly 69a3f853bd]]
Former-commit-id: 2f7dc1b8ee6735382cedae2053f40c546c21de45 [formerly b438417178b47ad5f7caf9cb728f4a5011a09f5e]
Former-commit-id: 07bc58ab2e1ab10c30be8d0a5e760288bfc4d4dc
2018-08-22 01:29:51 +01:00
1138-4EB
93acf4a6f7 chore: use commit SHA as version if not release (#505)
Former-commit-id: f94f65a805178a47be814226c69125f2c35b995e [formerly f87abdedd1a0b0a4187d11e6311a1fc5d95b9368] [formerly f0a8303535fdfa4bcb348c21e8576c32908255ed [formerly b1eb90767d]]
Former-commit-id: 31edb3a4cb01d8a091549d3b7a4dcc572b64baa8 [formerly 6b2abc348d488a7066812072a887df19ac70c720]
Former-commit-id: d7fbb8e61646a9fdc55699b0d016d8c13e676dcc
2018-08-20 10:41:06 +01:00
1138-4EB
dd8f47fade chore: fix rice-box import with sed in push_ricebox
Former-commit-id: 8f25251975c4e8a24d8cd7af1a9ab915010cb2ec [formerly 22583d38eff231d75e6fa1bb0a3f30f19201ebe2] [formerly f96b729dcf040693463591f90c602b030c576c1a [formerly 43ab4fa3de]]
Former-commit-id: 1b1a4b9be3b365faf0e18215fb2b5723b644a66f [formerly 6ce724f373ec2ad6738c61589a075ff9de0ed64e]
Former-commit-id: 750ca0440b7fb606e53fc043255fd2b0e0327a17
2018-08-16 10:12:33 +01:00
1138-4EB
3f4db6b81e chore: fix author in push_rice (#514)
Former-commit-id: f2b1df2b3387ae61c9e165de5763a0e06c2eb7d7 [formerly b3b5751c000a722e5d61e20ecfd0f7ef18420b0f] [formerly d951176d0cf0e0f1db255eb9d4fb0f52688c8cb9 [formerly 7afaf59e5d]]
Former-commit-id: 28fa6fdbd6b6414e303cf52ce57288e534a0a50c [formerly 780354453afc8940fec77d9b5765aeacc56dc924]
Former-commit-id: a83f01e72a88cdcc557f85b84f513c38b565f08e
2018-08-16 09:56:06 +01:00
1138-4EB
e471e79d50 fix(config): ensure provided config path is used (#508)
Former-commit-id: 519c027039de94232d801df4a71187096888f6bd [formerly f76f9459eeb7d8038b8d9b31af2e562c2984809e] [formerly 6b532750f58cf0eabaffacb772b623a9ecbf8e5b [formerly 1e12bb7f7c]]
Former-commit-id: 17a85007590f31c7ef1c2e6d125d30191eaa4d7d [formerly 4ee6dc582cc4e1c086f55901902864d784d392d5]
Former-commit-id: 9daf15d9a1131f8f45ce35a9b676dfdc8cd4b099
2018-08-16 09:37:07 +01:00
1138-4EB
6b4bce5daf chore: setting untracked version [ci skip]
Former-commit-id: f1990766e31c6cf01a7b97d1047e494e1ffb5175 [formerly 3f137859a89ca9623cf0ccb5cafdcd732853aa3e] [formerly d97c14c27c0c7e88295dc3114ec497979e3507e0 [formerly 69d1fdc0ac]]
Former-commit-id: 9983703da7f342ac3648fab4e92ce90fa19ea186 [formerly 78ac026abaa38ca16278b80d8f7c23f842d736c9]
Former-commit-id: 3626e4a882a1b28850a579090812347718247597
2018-08-16 07:33:26 +01:00
1138-4EB
b66adcb582 chore: version v1.10.0
Former-commit-id: 74446bfe3c27c860a34021c9fbc072a1d1b82bc5 [formerly cb41bf65c06e12bfdba229e337204dfe5e00c3c6] [formerly 5482d87a53717bc557d984d87f6448a0ee955503 [formerly b579350798]]
Former-commit-id: 38679cbcad1ab3e5bde96897048fc90594bcc5dd [formerly 775d5d1d240ae13649f383bdbc170ea906d969e8]
Former-commit-id: 941367abeb3f691ef5017d59c7a2543cc4caddab
2018-08-16 07:33:20 +01:00
1138-4EB
5ec06fa0cd chore: fix release conditions
Former-commit-id: 6300d99faea5b807ba90ca409bcc683eefb5cf67 [formerly e9ce861912c0b03f64bded2ed44896d6ae79a485] [formerly 8acca6c5ecf8b56e85e22271addaa7ce396bc676 [formerly 714876e3d0]]
Former-commit-id: bcc4154cbe9a0dbe6819b3ac3236d98c3b8f6010 [formerly 00da283ee494ad42a7e886f52fa5c8ec34860c68]
Former-commit-id: 4f8963ab76da8a9230e835ba8ef82b7893516b20
2018-08-16 07:32:46 +01:00
1138-4EB
c163318ce5 chore: make release.sh executable, update frontend
Former-commit-id: 239ec73aad2905eb0ffaf2318b1f6166bb910da1 [formerly 723297d061329c46876a4bfc534c1bd83a1249a4] [formerly 0293f9a819d58f62b00c51894bb7e33d0af9cab9 [formerly 0854c423c3]]
Former-commit-id: 2cb8474af898a81cdcce7d6a0c109854efa7c0c9 [formerly 48013895c67ac2cb22097fb5dde040747a231dfd]
Former-commit-id: 06799635ff5acfa1a79f4c41f22b187aa92b2b98
2018-08-16 04:30:28 +01:00
Henrique Dias
98dabff1e7 docs: update docker iamge
Former-commit-id: fb8c8d07d7c50a916b9142ae674a0d080af4bad5 [formerly 37c016849e2bc83f184eb1cb3b881c3fa300bdb4] [formerly 05c42ceabed6b64d5b4550fa32b07d3d3d976c50 [formerly 10607eb6bb]]
Former-commit-id: 525cbecb6754d4bc3c440053880440dfdb16acd7 [formerly 03e66762e36fb88cf738c21238faa7f72463d486]
Former-commit-id: 723f07c766502c2f49305baf79ebde41e9e15098
2018-08-08 11:50:59 +01:00
maweck
50dcf35eda feat: proxy auth support (#485)
* Change the order of commands to be able to cache more layers in case of multiple builds triggered in a row

* Fix #471

* Format Code

* Revert "Change the order of commands to be able to cache more layers in case of multiple builds triggered in a row"

This reverts commit 29217f66ee6aee63d2c03ac86de4ad437876317d [formerly ebff3e9d79ac9eca44d7b3caf7814be62c784d43] [formerly 9b95d9e986254d55405cd0e9484dcbbadc54c87b [formerly d13fd2878c38a46f91da30de150624200f0b32e9]] [formerly 3ec8fb12d8b6e1942ebae6abb00c5f15b03d6412 [formerly 6a70bdaf457f50896dd9826608666a39babae666] [formerly 063a6fe9d4991b7b6c257ae081288ea40efbe8b5 [formerly 01362f34ee]]].

* Adjustment based on the review

* Rename "login-header" to "loginHeader" and prepare auth.method to accept "none" as a value

* Fixed line break

* Readd "lumberjack.v2" import which was removed by gofmt

Sorry - I do my tests and run "gofmt" before comitting the changes - It sadly seems like it is messing up the imports over and over again.


Former-commit-id: 252e65171f70ee87238b5542e6af81d90bdaed6b [formerly fa843827feaab389550f32ba3a629e1968bcea3d] [formerly 942986226dbb56ef1cb4dff24445406cfa699d2d [formerly ed62451ea0]]
Former-commit-id: e87377dd6f30012b0d602b592100a7deb39a8632 [formerly f8198aa8a51fd5e727c31df0918ab62024520cef]
Former-commit-id: 019de07d53c3da16354e228330c14efb0dfb2122
2018-08-08 10:06:16 +01:00
Henrique Dias
769e634bdd docs: add freenode badge
Former-commit-id: adbba24f2d206e5f70e062c3733dc4737b2be85c [formerly d74e2307695c122fe4ad8118aa73d4af91fc7d5c] [formerly 1428ecc21a5031949b8bb04b43a31db7dbe1ca5c [formerly b90e7b8d26]]
Former-commit-id: ddbb0a87937d4704e1e14fbd16a9a129b26cceb4 [formerly 90a491507a9f9e8dfe78329ae6b51dd722859855]
Former-commit-id: 724bae950c0affd84fd9066ac016e318c5b7c115
2018-08-08 09:14:55 +01:00
1138-4EB
dead024e53 add pull request template (#501)
Related to #477.

Former-commit-id: f3020544c0b03295d5c4c79a678a4a1acc47884e [formerly 10c8b8febfa720d1e719f5e4735259b6427b9df0] [formerly 3d0b90a6b6c62bed99d8347066befff8a29f4525 [formerly 8186e8f02f]]
Former-commit-id: ccbd134d4e7d8eb7a362a2e34fa2828f2b86766d [formerly 2f9b979b97a8086136cdf36c68cdaeb2b36ef7da]
Former-commit-id: 6855aafd45b5c526b91fd3acdd95af4fec68175f
2018-08-07 13:53:51 +01:00
Henrique Dias
f4982cff5e style: fix linting issues
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 10657ab9cff2ee94dd7c0082bfe2cbfa07865022 [formerly 5501af1ace43a089ac4222cf9da2f5176242f817] [formerly 39c72e2e9235a822a30c0b338f55c441f3b3024d [formerly b7022bdfe3]]
Former-commit-id: 5941e4ab1295b90371ba60003f69939559dc8060 [formerly 3513d92ba403133d7b53aa19c92e4356f9e68b75]
Former-commit-id: 3657f6f659e893928bd2b9f64afecdaa41d587a6
2018-08-07 13:34:06 +01:00
1138-4EB
bfbb7b5ee1 chore: move filebrowser/dev img to separate repo (#500)
Former-commit-id: e54327906c7e4923debd36fff1dc31886440463c [formerly 72506b1b7f04ba728532ab6e94bd3e482ce38cda] [formerly 1195ba2763a02f47797bb529a7f89fa625e4c3ca [formerly 5afe2cc52d]]
Former-commit-id: 022049582a495c141024ceaa43516541a8c72628 [formerly 6a29708b0a57ae9aad227fec96983218d50da38b]
Former-commit-id: b9b48ad2b8e5d0b3b96f2b15fefe785a830240dd
2018-08-07 13:29:50 +01:00
1138-4EB
7c09473312 chore(gometalinter): exclude vendor
Former-commit-id: 8e99e3c0802a1f8acbed90047f0143789da771ad [formerly 94a11f954bdbdb4f295ecfb53ed786241a2a7fb5] [formerly 165c7ed873e40b703e3c910678479212f5f78fec [formerly 65ea97b32e]]
Former-commit-id: b144f646b8808e500209056d35994f4b9cb60773 [formerly 964ce718e4661dd15d3a7311637d4105d381b320]
Former-commit-id: ffc4f157a492490b95df3849d52218ae142581fc
2018-08-07 12:31:27 +01:00
1138-4EB
b6a8472722 fix: use './...' when running gometalinter
Former-commit-id: a3f2c975184928b042e09a42a2006c54fc3c9026 [formerly 3f80e808255c869732bc31f981f3a9256f151cc7] [formerly facb7e61332d3fb6fb18e5ac36771141474935c8 [formerly 69f11ed80b]]
Former-commit-id: fd86fb79039c33f22aaf05ca7023c74ad8d0036b [formerly 990a472cde58a891c01d673e1b1fb570b07868f1]
Former-commit-id: 887b84b6134135b268d4aa82d9c65990fc7d86c9
2018-08-07 12:04:43 +01:00
1138-4EB
db01cfa2f0 fix multiple entries in script deploy [travis-ci/travis-ci#7641]
Former-commit-id: 32d1205b18e256f94831485837b868f1cdf30bb1 [formerly 8caae9f4acbfc93df6729a28ecb0f136bff3cc3e] [formerly c988834f5d4a7a08796d538626c2b3f042fbe1eb [formerly 81f05aa894]]
Former-commit-id: 8b2f7f547441f01f853a67d8edca7c54fc6cf0db [formerly d4c50007f20825ef35cf767ce7b31ed76848e341]
Former-commit-id: ff4fab2a46d70189ba0a977c372db7cf7c5c0bd3
2018-08-06 22:14:40 +01:00
Henrique Dias
4267ebf0b4 fix: error at first sign
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 649162e55f57817c6e2fd8cb66fb4de1ada68199 [formerly fe5e1f6df6320c2eb6f24ca64ebffd6cedf6659b] [formerly 2f6eea9879c754d67acdf8f0809dd9c39cc12df0 [formerly 4470e0b450]]
Former-commit-id: 3a3500d1492db1ca7c262c60390452892fccb97b [formerly 2ea468347c670e8dfeda99be204e0b22072ea9c5]
Former-commit-id: be6a317810a0a465db2e852c6839308bf4d346ad
2018-08-06 20:53:48 +01:00
Henrique Dias
d4e9f5ba53 Merge pull request #492 from filebrowser/chore/build
chore: new build process
Former-commit-id: 5c703aea976d95470a5f427a2c2d7b15d08c0e9e [formerly 326fcdd2d11d414c557986c74ec343d5c2221168] [formerly 7a5991c0e85806e82256b201b515a070e0e95ec9 [formerly 8ad626b0bc]]
Former-commit-id: f78d78c109181cd9c52bd91753d4e39e8f65e077 [formerly 05e6b729485ddfa48ad428c389bd85d8ab11f366]
Former-commit-id: e91d24edfdff15c075e4f980a88b3dc8cf9d5254
2018-08-06 20:40:57 +01:00
1138-4EB
4ace991b8a update ricebox in caddy/assets
Former-commit-id: af8d9982d961f4c8e5a301dc0eeb1dc790f35231 [formerly 6f678bfadf1e1db8c8dc5e368087a23a3dba8b65] [formerly 3d06b4d8d6b2ffe209f10b9ae4ce30955839e721 [formerly 6f7fded3f1]]
Former-commit-id: 4016e6b9b12d5f945c67fd0960a3460cd1fbfda1 [formerly 1ead636502f6b0991e1b18f3de5889546cedfa24]
Former-commit-id: 03bb7d11a2062ca3fe4ffd5d3efc702e4652c260
2018-08-06 20:08:56 +01:00
1138-4EB
e0c91bb747 update frontend submodule
Former-commit-id: d1cbaf35191dfbdf499909baed77d16daa54ce4c [formerly edb3f13a7a6fd20a8377bee0c1eb9814dedcb615] [formerly b5566691de3d26ffaaaa0a9df77d517a8290a2cd [formerly 1149092d73]]
Former-commit-id: 642d0481907ba86e2fde0940e02bdfad4e04c898 [formerly 4f90dfe05f65af83234eb32e62fc4476ecdc5a75]
Former-commit-id: c858f5c393bfdc4de23c7fcc50cd1f2145ec44cf
2018-08-06 18:26:59 +01:00
1138-4EB
557e5922d2 fix(publish): fetch all before checking a matching semver in the frontend
Former-commit-id: 922b633d536f4102d8ec3e68a7d7fa12270e21c9 [formerly 7c8b0295aebc6819a162f94d23821e7728ebabc0] [formerly efad5cfea2c8bf1a1617dea5e9e6d0903d2d44d7 [formerly 18a9d977c2]]
Former-commit-id: c48391a56546742845c697d0b6494b1230bdf529 [formerly 4609f232086d4c5096c2a937cdf980f1b1a786cc]
Former-commit-id: 50ac09f7bca6d3541c0b8eb70ad672ed6768b2ca
2018-08-06 12:46:59 +01:00
1138-4EB
cea4d2aae9 fix rice-box dir in travis
Former-commit-id: a4de4d83ab964c11bb0375a66af7b011f39990bc [formerly e93bcfd8f83c089d72245ffa79785860f00b3758] [formerly 364f472f6e27004dab8bffa8674c855e9e6d4213 [formerly ac3ad47a92]]
Former-commit-id: 4c8cebdea67e8cd88c58563702489f7549aaa222 [formerly 1d6a75e82822a33f8edde2d64077196454f460ed]
Former-commit-id: 4230de67e7923ef7450385c8c9d25654f19f18c7
2018-08-06 12:46:59 +01:00
Filebrowser Bot
bb5c041d5c add deploy_key.enc 9ca81b5594f5
Former-commit-id: ed1098dcc37748ac3253be57416ba10aed0786e2 [formerly 4f791e75150f7947ea9bfac6e7e13bf3316f21d7] [formerly 140301afea7e83c08649870eb8cd6ee8bd111353 [formerly 43288e9b86]]
Former-commit-id: a8e5cee586fadff0a107d47cdb10573eb9aa30f5 [formerly 2eaf33fe47c4c56277284733251be36cfc0956e9]
Former-commit-id: 6d7a694ae4b0328c092ee342b96b226f464e526b
2018-08-06 05:01:44 +01:00
1138-4EB
bf1ef5b0f8 setup travis releases with filebrowserbot
Former-commit-id: 0593d1dd3883e25a44588131fa6fe69df815fd87 [formerly 429f789e0c54719595830f2290985be1f5899fb1] [formerly bb5b0328aa951f5534ab29e5070a1aa4da9ec2e2 [formerly 52aebd0444]]
Former-commit-id: 0cd117cb81b2a38b2646cc880c8774fed786d45c [formerly bf046ec317be577c8c3c4613d81272f6ae7fcabc]
Former-commit-id: 5066ef1dc9b898e8cf9909c03dede43690325815
2018-08-06 05:01:42 +01:00
1138-4EB
08ebe0fbb0 release all the files in dist
Former-commit-id: 9ac3858d788425d5c447f5a5ce068db71ba3bac2 [formerly 1eb037fc961dcb2d288d3f9edb7ee0867456aeef] [formerly 8633b5ef520ec3d4873a8b93925f90b4d129713e [formerly 6c98dfc9fc]]
Former-commit-id: 80f9ee49a48f953108813af26d8d576b17793245 [formerly 8cb7931e12674c248c68a90a3de2d5054646e089]
Former-commit-id: 2f0a1639a58ed6c8b56c178675829b05d8b08f30
2018-08-06 05:01:41 +01:00
1138-4EB
bdd7c269ed add docker-credential-pass to dev img and use it in travis
Former-commit-id: 3deff7d6b345fd6c1e9bac71b446730631e891c9 [formerly 2525a27cb90b003f72c7d936e2f0224848e3e49f] [formerly c699da2816b0c61bfdaf0a8b40612b9d50734d73 [formerly 5ab5c7c243]]
Former-commit-id: 7ed9366f3c83f50afef6b40d0006c32256d053f7 [formerly 0fc1beb902fbadc6f6388b10b7ed319e15fcb7d4]
Former-commit-id: 7bd6bacacb114d72808ded8c102f8f14de450625
2018-08-06 05:01:39 +01:00
1138-4EB
292ef7ea8a replace publish.sh with build/release.sh
Former-commit-id: 89636040fe653a0e2917a51fd7e557b0a9d2436c [formerly b052d724fe2381766bfd225d451cc7a077f82db4] [formerly e9e6f9066892058cf2780d33db8e561281bb1597 [formerly 2592c5eb43]]
Former-commit-id: d29d1a3284e7e84c80324d7591623644e5c3fac9 [formerly 3417ad7fe90ed523a0bc9bd67beafbb7b7ff3a80]
Former-commit-id: 5ac4f1ea442c54a401c66203343fa0373b5ffa9c
2018-08-06 05:01:38 +01:00
Henrique Dias
03ab2199d4 update repo
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: c78a96fbc7f65f0504e28ac2a59130d060cfc3d2 [formerly 5b8124120440eef3f81bef7a1354897c1e88e0ef] [formerly bbfcefaad0bd8e345f8463ad6f3ef7e5a65ea152 [formerly c6c915e387]]
Former-commit-id: 4af0f562b1c42e28e50f51c368544b957e3954b7 [formerly fa4050a8f763b7fea686617842610c526ed077b1]
Former-commit-id: 789e64f89019211fc541cbbc2e67655899b294ae
2018-08-06 05:01:36 +01:00
1138-4EB
41489f9e89 chore(gometalinter): gas is renamed to gosec [alecthomas/gometalinter#505]
Former-commit-id: 9d049a2544677a82892d61b046d9ca02719fd64e [formerly 75108904316b277fcdbd28145d0abff61c4c7d04] [formerly c28ae59c1ed7230f7f9ac4c5d6b27a014bac506b [formerly 993bab4687]]
Former-commit-id: b2bcc79aa40cb727315e0ec1007deea3a74358c6 [formerly 35c44ec3706ef141489d1c65309b55e21f03b4a0]
Former-commit-id: bce721ae0ca43b5b9667c31ccb2a3b64b48b7a71
2018-08-06 05:01:35 +01:00
1138-4EB
3bc5f6e0df build docker images with goreleaser
Former-commit-id: 5f8a21053734ba6c507b7d39fca57c0dcb9994fa [formerly 2ecda20825d40484ae2a24fba6dff4dfa63bf5df] [formerly a13bb1c1d1d812c86d8d92521bb48f7102b6725e [formerly 6cb2e30143]]
Former-commit-id: 553cb8f6ac4f89a4ab9574a72a2dd54e384f1072 [formerly 64e289831d826b28cc777c7ee7a79c8938f2a706]
Former-commit-id: 587e569d59adf142a24513bce9bc764841f8a550
2018-08-06 05:01:33 +01:00
1138-4EB
42d33cf595 add docker static client to filebrowser/dev
Former-commit-id: c9e14d35f42c240caf16c7ffaf03b56dac75588f [formerly bf92002b6cac66b3fca8fd68e7a19284983973d1] [formerly 3954699af9e3dad46a0026b07fd5ebb13796fabd [formerly 7459e66b71]]
Former-commit-id: 8f65bfb661773bd587243e84e9381d0e9a77ff50 [formerly 72cb26e555e2dd113a7c7e77fff71ae0abf440de]
Former-commit-id: dfe6091913bbcaf6bd87f8e1f3b06d5d5c84d14e
2018-08-06 05:01:31 +01:00
1138-4EB
0fbde826bf move caddy to separate repo
Former-commit-id: 38db4637c287a3f77a8e3fc39b0344a0d0ea0e94 [formerly aa94394d631efb107b6597e8bf2ec8d68f754fc8] [formerly efcef3211664021f7b23b9e6f1dcb7b5dbfc68a7 [formerly 28952e81bb]]
Former-commit-id: b7c4dbc1a19630c9116d640f96c52eccb6c66ab4 [formerly 5f2c74aa1fd92fdd3cd5917b21b5f6034d024748]
Former-commit-id: 3d6ad271b8f507f479ab9375419ad4b74594e719
2018-08-06 05:01:29 +01:00
1138-4EB
578f3e9bdd ignore rice-box.go
Former-commit-id: d416e0328a439e90100a8898b4eecd0d841094f0 [formerly 2ae0702ee23cb54706f34a01e2adadc8d71af201] [formerly e14ada686593af7f4e51df3631388e2564cc48d8 [formerly 569354c493]]
Former-commit-id: 55f994a485f1c19e0f217ef5a0a9eb929c0cb602 [formerly fc5f991702704d2b39bd3d557a7972a8da0190d7]
Former-commit-id: 0da0e4d08c933641f4212ec5e528da384eee315a
2018-08-06 05:01:27 +01:00
1138-4EB
f1e5cd490e add gometalinter and goreleaser to travis, drop circleci
Former-commit-id: dc44ea15987447b0f179bb2011c000f6d7224898 [formerly 3192a7ad777c6ff93fdd0d62a1d9f4c466c5b06e] [formerly 5bb95d586cf0dbf48355142fe17dfa8d162923c5 [formerly de7a8cee60]]
Former-commit-id: 129d25ece6e5ad704f3ef98bc4a59db70d0c9e10 [formerly f51552b629dbd69810e51142c9a66ab708d96d39]
Former-commit-id: 39d64538f9edcb5933c5cff8904f86691bf75ed3
2018-08-06 05:01:25 +01:00
1138-4EB
40b0cd4b66 add travis
Former-commit-id: a68e501a962cdd7c3a9e5a3d91433cbec34265e3 [formerly ab4763c975794e5997fab6abb51b2e91bda6e08a] [formerly 709e134df8986005308f3e125348fe13cf92919a [formerly 703318c214]]
Former-commit-id: 6672ab0918f84d73819f038cc5a24f1ce22625b4 [formerly 21d926cefe6d46ec2a99eba5e589b264e818d22d]
Former-commit-id: 294b3fa3faae6363f483388ccbedcf091d1f837c
2018-08-06 05:01:16 +01:00
1138-4EB
f9e3923ae7 add filebrowser/frontend as a submodule
Former-commit-id: 689395356dc1860d0f0f5786986cbbc4238a1fe0 [formerly 0c528dae26624fad221c4fa6b273a02dc030e81c] [formerly f353338b249c2ed818611ac6a91939bc87356de9 [formerly a2e293292e]]
Former-commit-id: 647dac9f8eed2df57191a75e4b199aebb18375fc [formerly 000079405f67a4bff2098c2cddc082a4374e0bd5]
Former-commit-id: 89c911c807783e2176994fc6949bf8221ca5e5a3
2018-08-05 10:58:21 +01:00
1138-4EB
32f7efbde5 add filebrowser/filebrowser:dev, move dep execution to build.sh
Former-commit-id: 691201333f6c76d5fe8d7134a1d68c4cc50404a7 [formerly a9973160b528bfe6b26bac2a6e1236e6e9192f0c] [formerly 84f8fdb79bd0929ef84a969a688ef1381e6ac691 [formerly d11aa8de6b]]
Former-commit-id: 5d10ebcf1f43a9854aa8b66b1227220e81e34473 [formerly a6e486b7c3a40fa821c2250bcd9edc1841775887]
Former-commit-id: 7367476016ce2499441cdb2d050fb2f961eed4d0
2018-08-05 10:58:21 +01:00
1138-4EB
56e5005484 drop package.json, use yarn instad of npm, add build_in_docker.sh
Former-commit-id: 1f1ce1a5350eb1d4d12dc3b90bae20d6df6048f9 [formerly fae0cae6f369574aab49ab952e1aa681c97f7067] [formerly 6f8245ec50d0d2485a263e5877a6a353837b1197 [formerly f91ee24858]]
Former-commit-id: b9bb3ad6a460de55851943bbbc62aee74e32028c [formerly 049f6c239d7a936d70493e68f23838c0ec11af88]
Former-commit-id: 81f69427472bbeb3f82e6bd2c3a114e2c5fb47d7
2018-08-05 10:58:21 +01:00
Henrique Dias
6bf0e8c063 chore: disable gosec (#490)
Former-commit-id: 515a160e341e7dcd338c7aea0a73c8dea0a917ca [formerly 85d6e4c2e150055fd8a2ba223bf8a7ee92116f72] [formerly 703c59c0f952f0fb7e43159c98328e53d1a92c04 [formerly 46b5fa013c]]
Former-commit-id: 1f6a9e78cdab0a6a6066248d98464bafd9d3f1c3 [formerly e102d783604d0afaff7e45a6dfd6eed9b7065e0d]
Former-commit-id: 22ffc5fbb93cd96609b04baf437e63db7bbfbe1b
2018-08-04 16:24:16 +01:00
1138-4EB
7445d73cf6 new issue templates (#477)
Former-commit-id: a28d3ceeb4a70ec5c59c7ad159952c4d453c8bca [formerly 1bcbffccb6aa9ccadf8ea43a7ffe4eb14cd7ec2b] [formerly 1d27bddbcf066bf32160c9b422bd927802ae8daa [formerly fb1dbb4276]]
Former-commit-id: 5fca1e72ba88f574059c4cf6ce92a13eac1919ed [formerly 3b928a4ec672b17f72ecfbc71bd7764e7cf7a31c]
Former-commit-id: 613be772339dcf2e4d422d5ddd361b66c95e7b2c
2018-07-29 20:20:24 +01:00
1138-4EB
af095a71e7 add ca-certificates to scratch docker image (#478)
Former-commit-id: aa531b84a518c6e4b48edc1231f663c316f36c23 [formerly 2b724b5f31ddbd39b1f9fb6df7ed4cff481b30db] [formerly 8f803379488acbc1149161b7df0eed4455ba876f [formerly 4e454f4bd2]]
Former-commit-id: 1579bebb11497abcdb83a4141af9da8bf681f8a9 [formerly c3943d81a5e4e66b4c1407ea37f30044b65ce593]
Former-commit-id: b26678c4727c4ad42463e25c53b6982efc18330c
2018-07-29 20:20:06 +01:00
1138-4EB
ab87f76dcb docs: add note about filemanager migration
Close #467.

Former-commit-id: 18d26af7c8a72d6195db73b795734dd18b9b2441 [formerly 87bdb71d011899d5e3e4c8dd9f7da6f629dceb67] [formerly ad1ff095a6e5dcf0c5e9f203f2bc3aa8e515d71d [formerly 6bbedddf51]]
Former-commit-id: 5d27d3e8f271ee437cb119df21334a942687193a [formerly 4ed80cbda3c300b5b18657cbbb4897eeff10f3df]
Former-commit-id: bc9d48ea84661e0607f30af71036d2e4f9a574f1
2018-07-29 20:19:52 +01:00
Dawid 'DeyV' Polak
2cbe941202 updated readme - case sensitive (#481)
Former-commit-id: 2ba295ca7060930f1f84645eed1f402b6f322522 [formerly fc51c3822642127f1d6ef6752bbcf47a3691a630] [formerly 8c38dd9075aed5f7a0d1fd974aa3dcad9fee8445 [formerly 90ad46b881]]
Former-commit-id: c0cc1705d3a215f07635de8809ab53238fccb75f [formerly bb31830df2193330f7266a4c382a57b89301446b]
Former-commit-id: bee1cec2d7892350706b8f2b24481f41a93e1082
2018-07-29 20:18:42 +01:00
Dawid 'DeyV' Polak
5e58c25aa4 natural sort (#474)
Former-commit-id: 9865271f38824fd4762253014a7855ee087d315f [formerly 17c1a5f7e2cbbea4f01ba394f6ae76ded22594f3] [formerly 2087a30cb8fa514b33d99fb9797a0751a8f532cd [formerly 202c9c97e5]]
Former-commit-id: 513ed21a74e590d062f0974b0ea7af7381162df9 [formerly 3fb2617b7aa05abe93460e2ab25ba2369ce68095]
Former-commit-id: a038eda5003c044eeceeea46539f3673ebc16f95
2018-07-29 17:43:23 +01:00
1138-4EB
bdfca1be33 subdir 'logo' moved to separate repo (#473)
Former-commit-id: d8596d836d5f3a126e6c58bab8737ae3902c0e9f [formerly b71f4484566042f6e4450f8ffafbf09f7ac76d48] [formerly e0b9028417b62b2ef00df7ed4ffa5deedef2b4bd [formerly c6f60d298a]]
Former-commit-id: 74e17d4db50e7ce9a2c2e16b706bd9a037832953 [formerly ef09d2f245aac59b54c09d370677294eda305c5a]
Former-commit-id: fa358937f8c8e9ca24e45c2f8d2c9997587dd927
2018-07-28 16:14:41 +01:00
VLEFF
281b8dca23 feat: handle subtitles for video streaming (#468)
Former-commit-id: 4259259f666304a88a808093afd26967059bd702 [formerly c925c803e33aa5486e920291b97b27e15ee9e2b9] [formerly dfe55f167c82ce734968505765104f855284a095 [formerly eb12bf2c2d]]
Former-commit-id: 96c5284c2a8c00c97dce3965893b4820e7ed4e6e [formerly 84f9ed9f1256e89010c5e813dc0b589af6a32d4a]
Former-commit-id: 0c84bae4cefcd2fad3b65f0fbec31e565ca5f27b
2018-07-26 10:47:09 +01:00
Henrique Dias
2761302ddf Update .dockerignore
Former-commit-id: a81be3e8b6e2130c615bb41f67946f940590ab0e [formerly a0c08066d324572fbff46aad1697bb8eb51722ca] [formerly 86886ab818a9fff57402bc5fb2652554d3f3998e [formerly ccf1722e65]]
Former-commit-id: 735ed5b90b2c329b97dd1840f95616d4089c91e6 [formerly 81363b7cbbe2b06e23701460b5842d22d51eaf33]
Former-commit-id: d34170646d7bec7efeeb9558b0b048333b86e096
2018-07-25 10:16:26 +01:00
Henrique Dias
06f0d36dd8 chore: setting untracked version [ci skip]
Former-commit-id: 3f52c0a25429df791e76eb7b157f4fd977193597 [formerly beee01e81d8380725e8f6b351606a9d1121c53fe] [formerly 75a659afa40143517192f3c4e04fa4f2fda5acc7 [formerly 80da59dab0]]
Former-commit-id: 0a74edab781637aa33568654fc7c82574cff069c [formerly d15a8f7f1b994aa8f359b402367da0f9b39c6c8d]
Former-commit-id: 912c7ff7943300c3f4b6b89f021c9071831afd28
2018-07-23 14:54:28 +01:00
Henrique Dias
a8863ec90b chore: version 1.9.0
Former-commit-id: 4dd0b080c6e792a117af9e33c43ac81c767e589a [formerly 3f3e6b6933d063cbcd16d2d14312740571ee908b] [formerly dd9b3423fe513c11916676922fae7a965dfa90e3 [formerly b4eda31788]]
Former-commit-id: 0ae3856cb12a0fdc1eea2acaf297145d93c1f2f9 [formerly 8191100298ba99a599de7c32513a5d010c705c7d]
Former-commit-id: 7b7a6565f30b0000eae8dc096f33ee0044bc99c7
2018-07-23 14:53:42 +01:00
Henrique Dias
3ed5a64cef feat: case insensitive search by default #415
Former-commit-id: e39d951ceaac2a3c9b055b8661c17432d746f5d2 [formerly f6a93dfc39e6edec09f19228d9d8d6cb66fbdac4] [formerly 0cecdec65555f37fab1e8773f066928cf821f6b5 [formerly 43d489c194]]
Former-commit-id: 57fd7a80303a6044846a3e11fabe0c9402557052 [formerly 4ffe639c08a784a05d49ff615994bda5f700ec1a]
Former-commit-id: 0db3b23185991ca9f0c0dc7e3f1eff5f4c2f7a77
2018-07-23 10:24:52 +01:00
Torben Woltjen
013c24733e Update .dockerignore to ignore the .git directory (#462)
Former-commit-id: fde994a6670ee97a1172869daa30645a1b6ea5a3 [formerly 6d7b714941b24f2c7aa92b1592d337957b57398b] [formerly b51eaa45ca829c7d0a6fa10f57edfb01fbc3c765 [formerly 3d3191b154]]
Former-commit-id: 8a25b969af8fe457970ab6151968fcef368dbbfc [formerly 9ed0c187ed77d53538bdc80a179d15f09a3d71fe]
Former-commit-id: ba61b6f861baee637bfacef1f8ce9d0a4f0ef915
2018-07-18 07:20:26 +01:00
Henrique Dias
d9d6fb656a fix: remove default rules (#455)
Former-commit-id: 61306205aa8bbdbd8248fb2cc1b1f2b8d1c9a47d [formerly 01601ea4acb9479b6b1b8f26acf89bec97876f42] [formerly c619c7135b3aa54367c3a9cb857eb647f6f6657a [formerly ec2e8d1f54]]
Former-commit-id: 51e1335b9720aa2825b55dbedabe5040f2c98e85 [formerly 9bdceac017d39acc8f7fb5abebe23c842c646f48]
Former-commit-id: b003d0e8e6b0410c31d80e60a50ba5fa70232304
2018-07-08 08:29:45 +01:00
Henrique Dias
eb72c5d959 chore: set untracked version [ci skip]
Former-commit-id: 34ebd89ab0214e369573f7fd9e830cd5b167aacf [formerly f8c67cb2a5dd1db582b71e1e3a838fd2644cdac8] [formerly 44d8c11057a965cfdbc6cf6e4f32afd6d7ca9c93 [formerly 8e864bfc93]]
Former-commit-id: 8d8d63420a5f135d64906369e98ad24541fab599 [formerly 6ed08fff774a5eb3ef92a81f646984e2504e5a1e]
Former-commit-id: bda207626bcae10499d7db7d68a30bf2ca81d340
2018-06-28 17:39:11 +01:00
Henrique Dias
03bdc57334 chore: version 1.8.0
chore: remove mips and misple due to compiling issues

Former-commit-id: ff1ab1b2a7f565ab9a7ec641c2158451208b939c [formerly 4c3f92a99672985e351bba104bbdb39cb442567f] [formerly 62e767638a349586584ebf16a9bfaaeb5de485c9 [formerly 30d5603964]]
Former-commit-id: 2aaa5a5e38f5ffd2bd08de26dc87caaabf81399c [formerly 9aa15449ec3391649367d7df8f16224d6772b8b5]
Former-commit-id: 60c82bdb832ebd50f5d9a9c6997da617849f7920
2018-06-28 17:33:23 +01:00
Henrique Dias
00e80365da docs: update screenshots
Former-commit-id: a2c782005b0a6566852847628e13de89087b2f31 [formerly e07e40fb4b7a1c44d930758d8641d1005f04e504] [formerly 7cd48e4afc82cd96671004984121a053e0b19d4b [formerly 102df60321]]
Former-commit-id: c266b57797145bc48f47fb12eb41bfa0786198f7 [formerly 53e746f3706e233045b1e93eea2977bb84917b1d]
Former-commit-id: 234de2cfc43b74964ca92e91f3bfafe637bb1968
2018-06-28 17:10:29 +01:00
Henrique Dias
aeba656a3b chore: update dependencies
Former-commit-id: 923d89ba332e6cc8fe80acdb821bff6b4ec003ed [formerly 45291bd9bbed76416b79a0a24d37aa32cfc86afc] [formerly 8d52172856c5ca1bbd7d5426a42dd8129d0c1b3e [formerly acc6e575ef]]
Former-commit-id: 3636b2e136c09a89f60a4f74adf980bfb5bb1d2d [formerly 3b84ff7966be81f45145f2eabed6b5705dd6cf09]
Former-commit-id: 505b1e40ac3adf3a4aad59e6f769d1fd34b0408a
2018-06-28 13:32:13 +01:00
Vladyslav Tokarchuk
dd40590ee6 fix: directory "others" execute permission, close #300
Former-commit-id: 0b0798905c957972e4deb0a934593f8c06910160 [formerly d77b03128a8c6b28a07998be4a29e3cfa8c14345] [formerly 19c9cefe047c2ef0c43d03d37fc4633bc35fbdb9 [formerly a07b08dae5]]
Former-commit-id: 72b8c93ab89c5df491899b3e41be46090089b406 [formerly 4a3e4bbac51eb2cc5c2fb75cb6de8ed5da01a108]
Former-commit-id: 86a702dbd2daa2ce36e799f6fd8b2ec8957c6844
2018-06-27 12:27:41 +01:00
1138-4EB
3ffb64abcd Add logo (#436)
* Add new logo

* Add new logo to README

* center logo in the readme

* add icon and logo in multiple formats #417

* rename logo.* to banner.*, crop white space, add icon_raw


Former-commit-id: c52c4c30f8f3a21a0c53f64452bf242146600956 [formerly 2d1d1efcd07060e18d26a7ecb530087f66b93d88] [formerly 4ee282a565c0cf5bc7ee7c07b338530c4592aea4 [formerly c0531c129a]]
Former-commit-id: c00a2f847ba387a304bfc59248626a2636e05dc6 [formerly a86618d87d4490ae891d50dfa92f42e9117be2c6]
Former-commit-id: f670dda3f4713e070625a56a76dc264aa62bf0c2
2018-06-26 18:10:12 +08:00
Henrique Dias
2dbb080fa2 chore: setting untracked version [ci skip]
Former-commit-id: ab9c804efbf5c372bc72fb1692a892cdf6c03d9c [formerly 24fadc2ccb26cbde51949560642a4dcd05e8cb55] [formerly 041bb1d3b5bddf9e9d9a00a0d15bc107bde8597a [formerly e3162e7170]]
Former-commit-id: f7612d5ad4db40943017edca2c90cfa9e46cb42e [formerly ed73a7e4e7dda445a6810529b345fe07d296fdf6]
Former-commit-id: 1c20c6e4c26b88f4381ce672de174f465b844012
2018-05-20 14:57:11 +01:00
Henrique Dias
f014828ee6 chore: version 1.7.1
Former-commit-id: 5b1b7642b56050a35dd06e020fe666d54ac4608b [formerly 3f64b131efb30db09461791b0bcce8a45cde2fd7] [formerly 31799922e187b67442ca8d024304dbdfa37b76f8 [formerly a8c589172d]]
Former-commit-id: c034e606c858c02346bd6de223a8dae1c35cde6f [formerly d9ee0ae17078a3510552541b26ba50d4c1d48806]
Former-commit-id: f94753f8d2de4ef2c99c0e5a19a863c8e5c464fe
2018-05-20 14:56:25 +01:00
Equim
bab6b7760b fix name_template for arm arch
Former-commit-id: a6c02bbd245beec733e61853c0a2446d464779fb [formerly 0399fb8fd0458ca804df6786f2f2013dc92155ed] [formerly a4fb29cb77d6448beef4c6bba88c93f70ac1bd75 [formerly 347122153b]]
Former-commit-id: d7b0611d1e2d2c76f4b04a9faf681947b9973e52 [formerly fff496e7d33c0b9b81467a33c7398dc962efe941]
Former-commit-id: c7d63e5908af2541d7cf4444bdf1730eefe23c5a
2018-04-26 22:38:15 +08:00
1138-4EB
e278dbba65 Rename manager to browser (#406)
* rename File Manager to File Browser

* rename fm to fb


Former-commit-id: 82cd461b7efa992114a6cb6a3bb7fbae53558f42 [formerly 18b0295100462d2c798177086ddc3f615c50ca71] [formerly 5927828ac67268438cc6de00fcaf9140a8620794 [formerly 7643b0c4e3]]
Former-commit-id: 3661e0339db83f5e4e3afa9bcb1015401afb611d [formerly 50eb65db9848c8db82115913fb58399fc371d990]
Former-commit-id: 03e42a5b429a3f0a83c88799e086a4c51c5e031d
2018-04-23 22:42:52 +01:00
Henrique Dias
5a8c28fa6d Update package.json
Former-commit-id: 0481ae202a800cc772ecc73f2df6c34c7cd3c440 [formerly 39f2f5644324def07a26aeaba413009785edd01e] [formerly 1d8a679709a764eb3485cc235e78ea102f1eb2b1 [formerly cd0ab77388]]
Former-commit-id: 0539911bdb06bafddd89d01235444397653dfbdd [formerly cea0a516383ad638738b6bc4d0a12509cdc9daf8]
Former-commit-id: 4eeca9fed79ddce64b6c1da7dead970601541733
2018-04-23 20:29:16 +01:00
1138-4EB
e7e2edf76c fix #311, fix #312 (see filebrowser/frontend#7) (#405)
Former-commit-id: 2a2fe8e441a30073ff9dbb4ba4f6c6235709f158 [formerly 75aa9ca68f6fe2e20ff01d027c9c18e49fe75739] [formerly 371c60a517b81399929f520abc25462f7a271083 [formerly c6eb4fbac5]]
Former-commit-id: e501e318c908fd83ffe7a4984ea732385116aa97 [formerly c5a2a983c3960e2af98915b89a6abb3f2ae3bbde]
Former-commit-id: 90dd43012239882bf72855df4f538fa59f699d64
2018-04-23 20:21:18 +01:00
1138-4EB
dd2d02e492 fix309: merge CMD in the dockerfile to ENTRYPOINT (#397)
Former-commit-id: ca81d11e477ac00abf2998b69425f00a0fa9bfd3 [formerly 262790d3b7ddd904b38fc926658e275531ced99b] [formerly 7d2d31e627d5df0d2f78362a43a27d80725dd4be [formerly f7fdd6cc92]]
Former-commit-id: 097da2311051673f5bea9f851f1451938a7d1935 [formerly b7922bd40d932e03493345cdaca0541150d9a44e]
Former-commit-id: 6b915b5d648575b857d51dc885de675616509d18
2018-04-18 11:53:22 +01:00
Michael Lawson
735e74a858 Fix typo preventing "--allow-edit" from being set (#392)
Former-commit-id: 3762a51ff4883a37b27ba5f859c0633f46d9d7f6 [formerly e125c2f788f5c04c4546ddfc6d86fff1d6624142] [formerly 2d696d4c1857621a9f8ae8c0637a5f43d783c2a5 [formerly 54d0845212]]
Former-commit-id: b063d159d13c5024b79d7dd7bbb5770732efd7e7 [formerly d75479c0c17ca461e36930501ee415a4b8863319]
Former-commit-id: b4a1f4516594d07ff22894384713b0fcb5ba15d8
2018-04-06 05:24:32 +08:00
Henrique Dias
7fc2414476 chore: add more architectures and arm versions (#379)
closes #357

Former-commit-id: 3ee5cc7ba30971665983f9e4a6ff9c25736c02db [formerly a804a698af9226856a76451dc78b756ce9d97dcc] [formerly e1ec927e96a80c90d039efd85a706135f6d4725a [formerly 281339337d]]
Former-commit-id: 6cdd27c4d9ecdb019b99228cbe5641949efc71d6 [formerly dac19ea15f5c7fa6d4b5eaad1c3a5267ae561900]
Former-commit-id: 2a263d999de61788373209667fa8c67a4e3850ad
2018-03-11 22:05:57 +08:00
Henrique Dias
822b8f8e05 chore: setting untracked version [ci skip]
Former-commit-id: 1bf9470ebe3331bcf61f1335de88b4298d253d3c [formerly 360a3ff78b73dadb59a78dc96a4708a4e8e7669b] [formerly c09ce1961737ed92aa22960025e25c0c63847f3e [formerly 5facaf219f]]
Former-commit-id: 4716a43b6e1a3a107d9f9b586376c726e4362ebf [formerly 4ff2f3a2b977b0f1ccaf7eb7ebc8fd4b57f459a9]
Former-commit-id: d0dd7a8e05f6495882493978ed3507aefbdcbd25
2018-03-10 13:25:56 +00:00
Henrique Dias
2d63c288e4 chore: version 1.7.0
Former-commit-id: fad547009e94abcf390a7a9a5fbda912890f5558 [formerly 38266b3eac1f5b6f45d12fdfa83afcf7daa98e60] [formerly e36ec6f4c2b25002be967b4a5dc9566749ac8d42 [formerly 97d26e2348]]
Former-commit-id: 59730ce4eac5932e9d52ffd5dbe810f52f69f548 [formerly 327efa168ad4669b585228fd6b7ced76b261e1f7]
Former-commit-id: d325631f00a18d8fc6009f571b66192809cb8875
2018-03-10 13:25:46 +00:00
Henrique Dias
218a96eebd chore: update dependencies
Former-commit-id: 17c4e043823582d827f3de6a50fc48f2c60250a7 [formerly b1783b936da0e7ede97e128c0d73d20c4c0f5c1b] [formerly b170eca4528721f3269451f6fabeffa54d08fcb9 [formerly fbf49d61d6]]
Former-commit-id: b34516564cf6520f8c21693e287c092bc65b76e9 [formerly b45a4f2367831aee0e5def4096e34b6afb4b8a83]
Former-commit-id: b06ebe48ba6311fa50488aa26b0cc74118d4dfd7
2018-03-10 13:25:11 +00:00
Henrique Dias
4fbef557ee chore: setting untracked version [ci skip]
Former-commit-id: 0fbfd17b4531b45f781fb8517eb155ec953a98f2 [formerly 3a6821e11c979bc638eeb1d31458f1ff7605f69e] [formerly 0ecb209c4172fc504860f25325e03d78f4a12408 [formerly dc97fb7dc6]]
Former-commit-id: 18dc494d9c4b250dc451316ee6c342e0bc26a5e0 [formerly e375068391bba6b1e4c477895bcf054574c7865a]
Former-commit-id: eed4fd2cddeb199b22843a293e8471cb3a40ab0a
2018-03-10 09:00:56 +00:00
Henrique Dias
0a4c803650 chore: version 1.6.0
Former-commit-id: 9b5297726d87eb6617a8c99a1f8e23c9b4d7f1e2 [formerly e227cf02e128ba194fba68f9aca3ea61476e65f4] [formerly 4d23059dc7db2615079ea2364ea5db10663a27e5 [formerly 5f9d216542]]
Former-commit-id: 7676703b8cf5c681fd671a7fe457f4bcdeafcdc2 [formerly 13e2b075b1db00a8de95742ac1a377bdb8272585]
Former-commit-id: 64bfe1b140a3d98c1e6c77b1d225cfb7e5ed5055
2018-03-10 09:00:46 +00:00
Henrique Dias
68c5b8cd52 chore: remove failing arches
Former-commit-id: bca9d8ef1c447c295b564711e52271c233ee76aa [formerly a8b9b2c7706199b9e655f77f51193540af9dcdaa] [formerly e03e1f77be77d2f9ae853472c03197183e3d000e [formerly 4c197176fc]]
Former-commit-id: 0a904664f8bf4177eb1e573a3dbd2e71ffbd86b4 [formerly 74c0785f2cd7b5c92c910f9043b9ccc06433acbc]
Former-commit-id: 70a547ce5220e833f393a9c94b1d70c76fa708d1
2018-03-10 09:00:24 +00:00
Equim
0cff87be24 alternative ReCaptcha, close #366
Former-commit-id: c8c9baff75891868283bd353c83a19d38e6bc0e9 [formerly 88aeffc35a402c44c9c92a534c8cd271124826a7] [formerly 39cfd0e090894509e913100aa2f9b325ad6e5b68 [formerly 6e1c6a4a8c]]
Former-commit-id: a49c1046af3ba28c469e93e7d88013f5a6b1d062 [formerly 07c801b64ed03b187bb1dd9bbfb502b92572af44]
Former-commit-id: aa69ed3d4d78f8942b8b2c924c73c8e4c4965520
2018-02-27 17:12:54 +00:00
Equim
a2fcb8b3b0 feat: 6 bytes version of share link, close #331
Former-commit-id: a4a4edf89a32e9b8338474eb3322de69e12da83e [formerly 57124e6118adfbf0ae38ec77ce6816f6351174ad] [formerly 6d9e5b81bf0f52373147cb46d3c71d7e8e1362a7 [formerly f0a703baa7]]
Former-commit-id: 7da431b8bf791bdfe66fca2b0f87fc4b4918543b [formerly 4d02e3f0a697b912fb639b09857ae5daa0851ebf]
Former-commit-id: 87af8b945b414dad82d1c6769d6ec014e097aa22
2018-02-27 17:06:23 +00:00
Equim
5eb9e95720 chore: use dep to manage vendor (#364)
Former-commit-id: a5262bb5a3ca329e8d9d7f68bbcd932bcd4f5aa0 [formerly 38cda564a25a09a12a849a5ac756b55e895d8ac7] [formerly b70c0cf897f19e468259148fc75e9a60de5252ab [formerly a184b775b3]]
Former-commit-id: 1de8ed7a5b316b7a64cad814c0efc80b67a9668f [formerly 5ef584fce122832b7e9200e6a7c6259a2b0e3c09]
Former-commit-id: 7e11fda1d06bd57d16a03a17d7c3a644e46c451a
2018-02-25 08:55:48 +00:00
Henrique Dias
967d4e28de chore: setting untracked version [ci skip]
Former-commit-id: 093104cb4d68178bf5de22289d58c465fca10552 [formerly 17499e5eec1c3c54f9e1c699818ea823be3d6728] [formerly 0e561b7ea77348ba12e29173607062c6badccc88 [formerly 4bd2e8e333]]
Former-commit-id: 992c37c538e5aa2aec9b6504cf836f2dd6aea2c9 [formerly cf3727500421de16876ddc84462d48b5600e1946]
Former-commit-id: af2ab326c2092bc169a44622e56b10000d6091dc
2018-02-24 08:45:44 +00:00
Henrique Dias
ee53803fc2 chore: version 1.5.5
Former-commit-id: cee33f264a3b98f9e635203f38793a5b4147792f [formerly 0619dbb1ca27fb4b3f030a77c2a1eae4233f3c87] [formerly eb56b144bfc0ec579fac4abd31aae495f3ba3498 [formerly 04096b6d1e]]
Former-commit-id: 4630f7870de9502b05b9bfd84c0feb022220b20b [formerly 029af42ac358788458facfba9236265e78bf681a]
Former-commit-id: b4471eb6375f7a46fe7344f6e301ea88722d389e
2018-02-24 08:45:16 +00:00
Henrique Dias
fa2ab280aa chore: bump frontend version
Former-commit-id: a381a7cf11629dc1fd8c847299f90b931accf2c6 [formerly 8da5f9853d69fb4a77a9d563be75408a1c0abf26] [formerly d7eaec9372fea8b12154755ccfb5a527e7d4a105 [formerly b0e3ec25ba]]
Former-commit-id: d745e4d51195a9d054bec17809f6a2c4da296c94 [formerly 03513fff5e0c16d3a2d694e5e2a76465157b1bb1]
Former-commit-id: c94620ff90019ee0e725fd1fa16017368a8d9715
2018-02-24 08:44:31 +00:00
Henrique Dias
395801016b chore: setting untracked version [ci skip]
Former-commit-id: f35ba7ce165f0d16b5943a26f713cfdd701d1ea1 [formerly 6a439c90d9c04a9d7c946444f1177b328f2b4735] [formerly 85ae45844946d0f4575b5fb1929fecb9a9a56b1b [formerly 52803ddb26]]
Former-commit-id: 1678fc7a028b881e4e7c7a721adaf51120877b04 [formerly c5a6dcf31959b2444d38a93705edb7ade958122d]
Former-commit-id: 73bd93eac053a1857d034f30af66a3f1fee3bd36
2018-02-18 12:27:49 +00:00
Henrique Dias
30ed82a70f chore: version 1.5.4
Former-commit-id: 1ad07843678a00d0f24d490dbdbbe5c211782c91 [formerly f0328a485087490f0f6fb1bdb8751ce0377edb63] [formerly 381a1863aa910ba03b89b47769b575f6dc2869d6 [formerly 83af6f2720]]
Former-commit-id: 8bdb8c1913820d84a3b504a7d55c98cd675baa58 [formerly 6b84fde09c4e03b8d9504d9786ae953e69d83402]
Former-commit-id: 9ddd4867df78fcbf7cd8302ab408fef3cdbf8906
2018-02-18 12:27:38 +00:00
Henrique Dias
ab643cd0c4 fix: not being able to change settings (#359)
Former-commit-id: 6230e0e979ca561a778be5f1aa245e85adb808e9 [formerly a14bfa497f716aa95a6b24d04e09361f06ff0b31] [formerly 008421161a7563ce29631cd103eef34597dd211a [formerly 7e962180b2]]
Former-commit-id: 3ac8515e4d0d2fff862af27ef14b23a8a66226a6 [formerly 83798c187f0df689f85f4118140661f04c051d60]
Former-commit-id: 1edf72e1db7824b1a64fbd97889835d20d9af500
2018-02-18 12:26:07 +00:00
Henrique Dias
85e5beaa4a chore: setting untracked version [ci skip]
Former-commit-id: c61d0cbd94e07432d75926fdc2c23dc365674351 [formerly f48aae15e3a532a9988b63be960185fd839db46d] [formerly 7807dcf654b3a05c2743b63fbd63d3a42e4381fc [formerly d117e4d005]]
Former-commit-id: a8fcba07f677764ee58f5bde4f10cb7dddf18bef [formerly aba5eff7c0ea571e728322e33070a977323f194c]
Former-commit-id: 3eb36b35a1672e254b046131309556ee22b1845d
2018-02-18 10:03:45 +00:00
Henrique Dias
3cab34c68b chore: version 1.5.3
Former-commit-id: fdf8f683da6bfb0c9c5f653f89969ed28a5fac86 [formerly ba0afcdbb13ea6040a77397d9b5cc1844b04d3df] [formerly c5625bc490f452970645719cec512f62796da98e [formerly 13030c7ace]]
Former-commit-id: d3fd31bf729a46295c53b3bbd9f7d2c09ce1ed13 [formerly 8278bc090fd8b99ef07b3d376d1243f14c8aa7aa]
Former-commit-id: ca391495213b2523fbde1c2aef1ee7a7818715e2
2018-02-18 10:03:34 +00:00
Henrique Dias
8299f8ed06 chore: go 1.10 and fix linters
Former-commit-id: 289bceb9a90eb2422a69010863e7f2691eae357f [formerly b0cbba626a1185f95c6ce98d453cce99ee208e97] [formerly 90388476afb899550d56c82f836203e3d7942df6 [formerly 5c188d9dd4]]
Former-commit-id: a318b0f544706102d05a1f6faaeb2bbbd11ede29 [formerly 05b5bf7216959990c8cdccebae5fd91769aa9596]
Former-commit-id: af8ef1c7dc5926a9f6912249b2c0a334452c239b
2018-02-18 09:59:49 +00:00
Henrique Dias
da05c5048e fix: bypass errors on symbolic links
Former-commit-id: 20cd8429be62bbe7c4f2ee48f7dddc2f389d5117 [formerly f857fe8d323a25e00e193f959aac605d742d7f15] [formerly 2c4ef521c756b902b7914a42958c163db85c2cc3 [formerly df453ca634]]
Former-commit-id: a638071b19674d82400639a142cb32085c20d1d9 [formerly aaabe20901f149ec00f4eea1ac730a6cf9f30856]
Former-commit-id: 43a13d56401f6b18fee8cff4806f960cd5683314
2018-02-18 09:49:40 +00:00
Henrique Dias
071e1ec19b chore: setting untracked version [ci skip]
Former-commit-id: d3e7532c6a00a899c1447cca4cd995e1f8feab73 [formerly 4d445abd785ae0adb8c8d0d748efbffa4ac2d001] [formerly 098e184c167f80cf3780e043ce941b3b36ddb41e [formerly 22327703fd]]
Former-commit-id: 84da73349f055e544276fafd9d3b4663ebe4e7d9 [formerly 28a71db5fb466aedb66045068a20647f192d12ad]
Former-commit-id: dbdc0c0a3953dbdd941cd3310bedbfc3d957362a
2018-02-04 00:40:16 +01:00
Henrique Dias
8884e68806 chore: version 1.5.2
Former-commit-id: 590181d208cd1a1addabbffa5c860afe234fbc60 [formerly d04974b17bc5cb290eca029c8e99af7d8a8555e8] [formerly a138ec0dba4609b2093dea1091ec8a4141504ae9 [formerly 60026f943b]]
Former-commit-id: 09ecb88b44745c160aa1db5262d299ce249b95bc [formerly 8458b1c621fa766998da3a886ac990495cf771ae]
Former-commit-id: 0a0bb60c235a1a2a8b98282d9e63ca5defb7d90f
2018-02-04 00:40:06 +01:00
Henrique Dias
68bfbe5103 feat: readd caddy to this repo
Former-commit-id: cf48e35cd8c5ceff57d1353c75ffacd1de96e9ad [formerly d62bc138c736881547184977110cd622f2d31847] [formerly 4270b9fb5c907097ce6babffcedafccb5a8b6356 [formerly 385cfba0ff]]
Former-commit-id: 04e6142a81d677781664c9a79e960465fadd3eb4 [formerly 2152b2410fb078914c788bf7f15ca8028af54c58]
Former-commit-id: e88a3fce1b9d16421ce9c1aa9c63c90705878bd2
2018-02-04 00:38:07 +01:00
Henrique Dias
4a7bdfc59b chore: setting untracked version [ci skip]
Former-commit-id: bf80464d9d029dbe2ad94e6a0578767051edcd0e [formerly 338f2cc8d8e86b6666d692fa1497da3acf0bd5f7] [formerly 2ed27b9f856328760b427bc0ad19eb62a04aabc0 [formerly 05cca04f2e]]
Former-commit-id: a7f4dd93d50011d538a206f6d5e317407c33f8bf [formerly 2386141b2825821c379d15bb183fddad6eb80b4d]
Former-commit-id: 5014565536c407489923ec844f0818b9f671d2f4
2018-02-03 00:15:05 +01:00
115 changed files with 6122 additions and 3913 deletions

View File

@@ -1,79 +1,84 @@
version: 2
jobs:
linting:
lint:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/filebrowser/filebrowser
- image: golangci/golangci-lint:v1.16
steps:
- checkout
- run: golangci-lint run -v -D errcheck
build-node:
docker:
- image: circleci/node
steps:
- checkout
- run:
name: Install Dependencies
name: "Pull Submodules"
command: |
cd cmd/filebrowser && go get ./... && cd ../..
go get github.com/alecthomas/gometalinter
gometalinter --install
git submodule init
git submodule update --remote
- run:
name: Run linting
command: |
gometalinter --exclude="rice-box.go" \
-D goconst \
-D gocyclo \
-D vetshadow \
-D errcheck \
-D golint \
-D gas
build:
name: "Build"
command: ./wizard.sh -a
- run:
name: "Cleanup"
command: rm -rf frontend/node_modules
- persist_to_workspace:
root: .
paths:
- '*'
build-go:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/filebrowser/filebrowser
- image: circleci/golang:1.12
steps:
- checkout
- attach_workspace:
at: '~/project'
- run:
name: Install Dependencies
name: "Compile"
command: GOOS=linux GOARCH=amd64 ./wizard.sh -c
- run:
name: "Cleanup"
command: |
cd cmd/filebrowser
go get ./...
- run:
name: Building
command: go build
deploy:
rm -rf frontend/build
git checkout -- go.sum # TODO: why is it being changed?
- persist_to_workspace:
root: .
paths:
- '*'
release:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/filebrowser/filebrowser
- image: circleci/golang:1.12
steps:
- checkout
- run:
name: Install Dependencies
command: |
cd cmd/filebrowser
go get ./...
cd ../..
- run:
name: Deploy
command: curl -sL https://git.io/goreleaser | bash
- attach_workspace:
at: '~/project'
- setup_remote_docker
- run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- run: curl -sL https://git.io/goreleaser | bash
- run: docker logout
workflows:
version: 2
lint-build-deploy:
build-workflow:
jobs:
- linting:
filters:
tags:
only: /.*/
branches:
only: /.*/
- build:
filters:
tags:
only: /.*/
branches:
only: /.*/
- deploy:
requires:
- linting
- build
- lint:
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
only: /.*/
- build-node:
filters:
tags:
only: /.*/
- build-go:
filters:
tags:
only: /.*/
requires:
- build-node
- lint
- release:
context: deploy
requires:
- build-go
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
ignore: /.*/

8
.docker.json Normal file
View File

@@ -0,0 +1,8 @@
{
"port": 80,
"baseURL": "",
"address": "",
"log": "stdout",
"database": "/database.db",
"root": "/srv"
}

View File

@@ -1,2 +1,3 @@
testdata/
.github/
testdata/
.github/
**.git

View File

@@ -1,24 +0,0 @@
### 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.
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.
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?
### 2. What is your entire Caddyfile?
```text
(Put Caddyfile here)
```
### 3. What are you trying to do?
### 4. What did you expect to see?
### 5. What did you see instead (give full error messages and/or log)?
### 6. How can someone who is starting from scratch reproduce this behaviour as minimally as possible?

22
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,22 @@
---
name: Bug report
about: Create a report to help us improve
---
**Description**
A clear and concise description of what the issue is about. What are you trying to do?
**Expected behaviour**
What did you expect to happen?
**What is happening instead?**
Please, give full error messages and/or log.
**Additional context**
Add any other context about the problem here. If applicable, add screenshots to help explain your problem.
**How to reproduce?**
Tell us how to reproduce this issue. How can someone who is starting from scratch reproduce this behaviour as minimally as possible?
**Files**
A list of relevant files for this issue. Large files can be uploaded one-by-one or in a tarball/zipfile.

View File

@@ -0,0 +1,16 @@
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
Add a clear and concise description of what the problem is. E.g. *I'm always frustrated when [...]*
**Describe the solution you'd like**
Add a clear and concise description of what you want to happen.
**Describe alternatives you've considered**
Add a clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,16 @@
**Description**
Please explain the changes you made here.
If the feature changes current behaviour, explain why your solution is better.
:rotating_light: Before submitting your PR, please read [community](https://github.com/filebrowser/community), and indicate which issues (in any of the repos) are either fixed or closed by this PR. See [GitHub Help: Closing issues using keywords](https://help.github.com/articles/closing-issues-via-commit-messages/).
- [ ] DO make sure you are requesting to **pull a topic/feature/bugfix branch** (right side). Don't request your master!
- [ ] DO make sure you are making a pull request against the **master branch** (left side). Also you should start *your branch* off *our master*.
- [ ] DO make sure that File Browser can be successfully built. See [builds](https://github.com/filebrowser/community/blob/master/builds.md) and [development](https://github.com/filebrowser/community/blob/master/development.md).
- [ ] DO make sure that related issues are opened in other repositories. I.e., the frontend, caddy plugins or the web page need to be updated accordingly.
- [ ] AVOID breaking the continuous integration build.
**Further comments**
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did, what alternatives you considered, etc.
:heart: Thank you!

17
.gitignore vendored
View File

@@ -1,12 +1,7 @@
.DS_Store
node_modules/
*/dist/*
*.db
*.db.lock
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
.vscode
package-lock.json
yarn.lock
*.lock
*.bak
_old
rice-box.go
.idea/
filebrowser

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "frontend"]
path = frontend
url = https://github.com/filebrowser/frontend

View File

@@ -1,37 +1,65 @@
build:
main: cmd/filebrowser/main.go
binary: filebrowser
goos:
- darwin
- linux
- windows
- freebsd
- netbsd
- openbsd
- dragonfly
- solaris
goarch:
- amd64
- 386
- arm
- arm64
- mips
- mips64
- mipsle
- mips64le
ignore:
- goos: openbsd
goarch: arm
goarm: 6
- goos: freebsd
goarch: arm
goarm: 6
- goos: linux
goarch: arm64
archive:
name_template: "{{.Os}}-{{.Arch}}-{{ .ProjectName }}"
format: tar.gz
format_overrides:
- goos: windows
format: zip
project_name: filebrowser
env:
- GO111MODULE=on
before:
hooks:
- go mod download
build:
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/filebrowser/filebrowser/v2/version.Version={{ .Version }} -X github.com/filebrowser/filebrowser/v2/version.CommitSHA={{ .ShortCommit }}
main: main.go
binary: filebrowser
goos:
- darwin
- linux
- windows
- freebsd
- netbsd
- openbsd
- dragonfly
- solaris
goarch:
- amd64
- 386
- arm
- arm64
goarm:
- 5
- 6
- 7
ignore:
- goos: darwin
goarch: 386
- goos: openbsd
goarch: arm
- goos: freebsd
goarch: arm
- goos: netbsd
goarch: arm
- goos: solaris
goarch: arm
archives:
-
name_template: "{{.Os}}-{{.Arch}}{{if .Arm}}v{{.Arm}}{{end}}-{{ .ProjectName }}"
format: tar.gz
format_overrides:
- goos: windows
format: zip
dockers:
-
goos: linux
goarch: amd64
goarm: ''
image_templates:
- "filebrowser/filebrowser:latest"
- "filebrowser/filebrowser:{{ .Tag }}"
- "filebrowser/filebrowser:v{{ .Major }}"
extra_files:
- .docker.json

View File

@@ -1,10 +0,0 @@
{
"port": 80,
"address": "",
"database": "/database.db",
"scope": "/srv",
"allowCommands": true,
"allowEdit": true,
"allowNew": true,
"commands": []
}

View File

@@ -1,24 +1,13 @@
FROM golang:alpine
COPY . /go/src/github.com/filebrowser/filebrowser
WORKDIR /go/src/github.com/filebrowser/filebrowser
RUN apk add --no-cache git
RUN go get ./...
WORKDIR /go/src/github.com/filebrowser/filebrowser/cmd/filebrowser
RUN CGO_ENABLED=0 go build -a
RUN mv filebrowser /go/bin/filebrowser
FROM scratch
COPY --from=0 /go/bin/filebrowser /filebrowser
VOLUME /tmp
VOLUME /srv
EXPOSE 80
COPY Docker.json /config.json
ENTRYPOINT ["/filebrowser"]
CMD ["--config", "/config.json"]
FROM alpine:latest as certs
RUN apk --update add ca-certificates
FROM scratch
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
VOLUME /srv
EXPOSE 80
COPY .docker.json /.filebrowser.json
COPY filebrowser /filebrowser
ENTRYPOINT [ "/filebrowser" ]

106
README.md
View File

@@ -1,75 +1,31 @@
![Preview](https://user-images.githubusercontent.com/5447088/28537288-39be4288-70a2-11e7-8ce9-0813d59f46b7.gif)
# filebrowser
[![CircleCI](https://img.shields.io/circleci/project/github/filebrowser/filebrowser.svg?style=flat-square)](https://circleci.com/gh/filebrowser/filebrowser)
[![Go Report Card](https://goreportcard.com/badge/github.com/filebrowser/filebrowser?style=flat-square)](https://goreportcard.com/report/github.com/filebrowser/filebrowser)
[![Documentation](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/filebrowser/filebrowser)
[![Version](https://img.shields.io/github/release/filebrowser/filebrowser.svg?style=flat-square)](https://github.com/filebrowser/filebrowser/releases/latest)
filebrowser provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files. It allows the creation of multiple users and each user can have its own directory. It can be used as a standalone app or as a middleware.
# Table of contents
+ [Getting started](#getting-started)
+ [Features](#features)
- [Users](#users)
- [Search](#search)
+ [Contributing](#contributing)
+ [Donate](#donate)
# Getting started
You can find the Getting Started guide on the [documentation](https://filebrowser.github.io/quick-start/).
# Features
Easy login system.
![Login Page](https://user-images.githubusercontent.com/5447088/28432382-975493dc-6d7f-11e7-9190-23f8037159dc.jpg)
Listings of your files, available in two styles: mosaic and list. You can delete, move, rename, upload and create new files, as well as directories. Single files can be downloaded directly, and multiple files as *.zip*, *.tar*, *.tar.gz*, *.tar.bz2* or *.tar.xz*.
![Mosaic Listing](https://user-images.githubusercontent.com/5447088/28432384-9771bb4c-6d7f-11e7-8564-3a9bd6a3ce3a.jpg)
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.
![Markdown Editor](https://user-images.githubusercontent.com/5447088/28432383-9756fdac-6d7f-11e7-8e58-fec49470d15f.jpg)
On the settings page, a regular user can set its own custom CSS to personalize the experience and change its password. For admins, they can manage the permissions of each user, set commands which can be executed when certain events are triggered (such as before saving and after saving) and change plugin's settings.
![Settings](https://user-images.githubusercontent.com/5447088/28432385-9776ec66-6d7f-11e7-90a5-891bacd4d02f.jpg)
We also allow the users to search in the directories and execute commands if allowed.
## Users
We support multiple users and each user can have its own scope and custom stylesheet. The administrator is able to choose which permissions should be given to the users, as well as the commands they can execute. Each user also have a set of rules, in which he can be prevented or allowed to access some directories (regular expressions included!).
![Users](https://user-images.githubusercontent.com/5447088/28432386-977f388a-6d7f-11e7-9006-87d16f05f1f8.jpg)
## Search
File Browser allows you to search through your files and it has some options. By default, your search will be something like this:
```
this are keywords
```
If you search for that it will look at every file that contains "this", "are" or "keywords" on their name. If you want to search for an exact term, you should surround your search by double quotes:
```
"this is the name"
```
That will search for any file that contains "this is the name" on its name. It won't search for each separated term this time.
By default, every search will be case sensitive. Although, you can make a case insensitive search by adding `case:insensitive` to the search terms, like this:
```
this are keywords case:insensitive
```
# Contributing
The contributing guidelines can be found [here](https://github.com/filebrowser/community).
<p align="center">
<img src="https://raw.githubusercontent.com/filebrowser/logo/master/banner.png" width="550"/>
</p>
![Preview](https://user-images.githubusercontent.com/5447088/50716739-ebd26700-107a-11e9-9817-14230c53efd2.gif)
[![Travis](https://img.shields.io/travis/com/filebrowser/filebrowser.svg?style=flat-square)](https://travis-ci.com/filebrowser/filebrowser)
[![Go Report Card](https://goreportcard.com/badge/github.com/filebrowser/filebrowser?style=flat-square)](https://goreportcard.com/report/github.com/filebrowser/filebrowser)
[![Documentation](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/filebrowser/filebrowser)
[![Version](https://img.shields.io/github/release/filebrowser/filebrowser.svg?style=flat-square)](https://github.com/filebrowser/filebrowser/releases/latest)
[![Chat IRC](https://img.shields.io/badge/freenode-%23filebrowser-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23filebrowser)
> INFO: **This project is not under active development ATM. A small group of developers keeps the project alive, but due to lack of time, we can't continue adding new features or doing deep changes. Please read [#532](https://github.com/filebrowser/filebrowser/issues/532) for more info!**
filebrowser provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files. It allows the creation of multiple users and each user can have its own directory. It can be used as a standalone app or as a middleware.
## Features
Please refer to our docs at [filebrowser.xyz/features](https://filebrowser.xyz/features)
## Install
Please refer to our docs at [filebrowser.xyz](https://filebrowser.xyz/).
## Usage
Please refer to our docs at [filebrowser.xyz/usage](https://filebrowser.xyz/usage).
## Contributing
Please refer to our docs at [filebrowser.xyz/contributing](https://filebrowser.xyz/contributing).

15
auth/auth.go Normal file
View File

@@ -0,0 +1,15 @@
package auth
import (
"net/http"
"github.com/filebrowser/filebrowser/v2/users"
)
// Auther is the authentication interface.
type Auther interface {
// Auth is called to authenticate a request.
Auth(r *http.Request, s *users.Storage, root string) (*users.User, error)
// LoginPage indicates if this auther needs a login page.
LoginPage() bool
}

107
auth/json.go Normal file
View File

@@ -0,0 +1,107 @@
package auth
import (
"encoding/json"
"net/http"
"net/url"
"os"
"strings"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
)
// MethodJSONAuth is used to identify json auth.
const MethodJSONAuth settings.AuthMethod = "json"
type jsonCred struct {
Password string `json:"password"`
Username string `json:"username"`
ReCaptcha string `json:"recaptcha"`
}
// JSONAuth is a json implementaion of an Auther.
type JSONAuth struct {
ReCaptcha *ReCaptcha `json:"recaptcha" yaml:"recaptcha"`
}
// Auth authenticates the user via a json in content body.
func (a JSONAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error) {
var cred jsonCred
if r.Body == nil {
return nil, os.ErrPermission
}
err := json.NewDecoder(r.Body).Decode(&cred)
if err != nil {
return nil, os.ErrPermission
}
// If ReCaptcha is enabled, check the code.
if a.ReCaptcha != nil && len(a.ReCaptcha.Secret) > 0 {
ok, err := a.ReCaptcha.Ok(cred.ReCaptcha)
if err != nil {
return nil, err
}
if !ok {
return nil, os.ErrPermission
}
}
u, err := sto.Get(root, cred.Username)
if err != nil || !users.CheckPwd(cred.Password, u.Password) {
return nil, os.ErrPermission
}
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"
// ReCaptcha identifies a recaptcha conenction.
type ReCaptcha struct {
Host string `json:"host"`
Key string `json:"key"`
Secret string `json:"secret"`
}
// Ok checks if a reCaptcha responde is correct.
func (r *ReCaptcha) Ok(response string) (bool, error) {
body := url.Values{}
body.Set("secret", r.Key)
body.Add("response", response)
client := &http.Client{}
resp, err := client.Post(
r.Host+reCaptchaAPI,
"application/x-www-form-urlencoded",
strings.NewReader(body.Encode()),
)
if err != nil {
return false, err
}
if resp.StatusCode != http.StatusOK {
return false, nil
}
var data struct {
Success bool `json:"success"`
}
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
return false, err
}
return data.Success, nil
}

24
auth/none.go Normal file
View File

@@ -0,0 +1,24 @@
package auth
import (
"net/http"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
)
// MethodNoAuth is used to identify no auth.
const MethodNoAuth settings.AuthMethod = "noauth"
// NoAuth is no auth implementation of auther.
type NoAuth struct{}
// Auth uses authenticates user 1.
func (a NoAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error) {
return sto.Get(root, uint(1))
}
// LoginPage tells that no auth doesn't require a login page.
func (a NoAuth) LoginPage() bool {
return false
}

34
auth/proxy.go Normal file
View File

@@ -0,0 +1,34 @@
package auth
import (
"net/http"
"os"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
)
// MethodProxyAuth is used to identify no auth.
const MethodProxyAuth settings.AuthMethod = "proxy"
// ProxyAuth is a proxy implementation of an auther.
type ProxyAuth struct {
Header string `json:"header"`
}
// Auth authenticates the user via an HTTP header.
func (a ProxyAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error) {
username := r.Header.Get(a.Header)
user, err := sto.Get(root, username)
if err == errors.ErrNotExist {
return nil, os.ErrPermission
}
return user, err
}
// LoginPage tells that proxy auth doesn't require a login page.
func (a ProxyAuth) LoginPage() bool {
return false
}

33
auth/storage.go Normal file
View File

@@ -0,0 +1,33 @@
package auth
import (
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
)
// StorageBackend is a storage backend for auth storage.
type StorageBackend interface {
Get(settings.AuthMethod) (Auther, error)
Save(Auther) error
}
// Storage is a auth storage.
type Storage struct {
back StorageBackend
users *users.Storage
}
// NewStorage creates a auth storage from a backend.
func NewStorage(back StorageBackend, users *users.Storage) *Storage {
return &Storage{back: back, users: users}
}
// Get wraps a StorageBackend.Get.
func (s *Storage) Get(t settings.AuthMethod) (Auther, error) {
return s.back.Get(t)
}
// Save wraps a StorageBackend.Save.
func (s *Storage) Save(a Auther) error {
return s.back.Save(a)
}

View File

@@ -1,26 +0,0 @@
package bolt
import (
"github.com/asdine/storm"
fm "github.com/filebrowser/filebrowser"
)
// ConfigStore is a configuration store.
type ConfigStore struct {
DB *storm.DB
}
// Get gets a configuration from the database to an interface.
func (c ConfigStore) Get(name string, to interface{}) error {
err := c.DB.Get("config", name, to)
if err == storm.ErrNotFound {
return fm.ErrNotExist
}
return err
}
// Save saves a configuration from an interface to the database.
func (c ConfigStore) Save(name string, from interface{}) error {
return c.DB.Set("config", name, from)
}

View File

@@ -1,66 +0,0 @@
package bolt
import (
"github.com/asdine/storm"
"github.com/asdine/storm/q"
fm "github.com/filebrowser/filebrowser"
)
// ShareStore is a shareable links store.
type ShareStore struct {
DB *storm.DB
}
// Get gets a Share Link from an hash.
func (s ShareStore) Get(hash string) (*fm.ShareLink, error) {
var v fm.ShareLink
err := s.DB.One("Hash", hash, &v)
if err == storm.ErrNotFound {
return nil, fm.ErrNotExist
}
return &v, err
}
// GetPermanent gets the permanent link from a path.
func (s ShareStore) GetPermanent(path string) (*fm.ShareLink, error) {
var v fm.ShareLink
err := s.DB.Select(q.Eq("Path", path), q.Eq("Expires", false)).First(&v)
if err == storm.ErrNotFound {
return nil, fm.ErrNotExist
}
return &v, err
}
// GetByPath gets all the links for a specific path.
func (s ShareStore) GetByPath(hash string) ([]*fm.ShareLink, error) {
var v []*fm.ShareLink
err := s.DB.Find("Path", hash, &v)
if err == storm.ErrNotFound {
return v, fm.ErrNotExist
}
return v, err
}
// Gets retrieves all the shareable links.
func (s ShareStore) Gets() ([]*fm.ShareLink, error) {
var v []*fm.ShareLink
err := s.DB.All(&v)
if err == storm.ErrNotFound {
return v, fm.ErrNotExist
}
return v, err
}
// Save stores a Share Link on the database.
func (s ShareStore) Save(l *fm.ShareLink) error {
return s.DB.Save(l)
}
// Delete deletes a Share Link from the database.
func (s ShareStore) Delete(hash string) error {
return s.DB.DeleteStruct(&fm.ShareLink{Hash: hash})
}

View File

@@ -1,90 +0,0 @@
package bolt
import (
"reflect"
"github.com/asdine/storm"
fm "github.com/filebrowser/filebrowser"
)
// UsersStore is a users store.
type UsersStore struct {
DB *storm.DB
}
// Get gets a user with a certain id from the database.
func (u UsersStore) Get(id int, builder fm.FSBuilder) (*fm.User, error) {
var us fm.User
err := u.DB.One("ID", id, &us)
if err == storm.ErrNotFound {
return nil, fm.ErrNotExist
}
if err != nil {
return nil, err
}
us.FileSystem = builder(us.Scope)
return &us, nil
}
// GetByUsername gets a user with a certain username from the database.
func (u UsersStore) GetByUsername(username string, builder fm.FSBuilder) (*fm.User, error) {
var us fm.User
err := u.DB.One("Username", username, &us)
if err == storm.ErrNotFound {
return nil, fm.ErrNotExist
}
if err != nil {
return nil, err
}
us.FileSystem = builder(us.Scope)
return &us, nil
}
// Gets gets all the users from the database.
func (u UsersStore) Gets(builder fm.FSBuilder) ([]*fm.User, error) {
var us []*fm.User
err := u.DB.All(&us)
if err == storm.ErrNotFound {
return nil, fm.ErrNotExist
}
if err != nil {
return us, err
}
for _, user := range us {
user.FileSystem = builder(user.Scope)
}
return us, err
}
// Update updates the whole user object or only certain fields.
func (u UsersStore) Update(us *fm.User, fields ...string) error {
if len(fields) == 0 {
return u.Save(us)
}
for _, field := range fields {
val := reflect.ValueOf(us).Elem().FieldByName(field).Interface()
if err := u.DB.UpdateField(us, field, val); err != nil {
return err
}
}
return nil
}
// Save saves a user to the database.
func (u UsersStore) Save(us *fm.User) error {
return u.DB.Save(us)
}
// Delete deletes a user from the database.
func (u UsersStore) Delete(id int) error {
return u.DB.DeleteStruct(&fm.User{ID: id})
}

View File

@@ -1,14 +0,0 @@
#!/bin/bash
set -e
# Install rice tool if not present
if ! [ -x "$(command -v rice)" ]; then
go get github.com/GeertJohan/go.rice/rice
fi
# Clean the dist folder and build the assets
rm -rf node_modules
npm install
# Embed the assets using rice
rice embed-go

12
cmd/cmd.go Normal file
View File

@@ -0,0 +1,12 @@
package cmd
import (
"log"
)
// Execute executes the commands.
func Execute() {
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
}

26
cmd/cmds.go Normal file
View File

@@ -0,0 +1,26 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(cmdsCmd)
}
var cmdsCmd = &cobra.Command{
Use: "cmds",
Short: "Command runner management utility",
Long: `Command runner management utility.`,
Args: cobra.NoArgs,
}
func printEvents(m map[string][]string) {
for evt, cmds := range m {
for i, cmd := range cmds {
fmt.Printf("%s(%d): %s\n", evt, i, cmd)
}
}
}

27
cmd/cmds_add.go Normal file
View File

@@ -0,0 +1,27 @@
package cmd
import (
"strings"
"github.com/spf13/cobra"
)
func init() {
cmdsCmd.AddCommand(cmdsAddCmd)
}
var cmdsAddCmd = &cobra.Command{
Use: "add <event> <command>",
Short: "Add a command to run on a specific event",
Long: `Add a command to run on a specific event.`,
Args: cobra.MinimumNArgs(2),
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
s, err := d.store.Settings.Get()
checkErr(err)
command := strings.Join(args[1:], " ")
s.Commands[args[0]] = append(s.Commands[args[0]], command)
err = d.store.Settings.Save(s)
checkErr(err)
printEvents(s.Commands)
}, pythonConfig{}),
}

31
cmd/cmds_ls.go Normal file
View File

@@ -0,0 +1,31 @@
package cmd
import (
"github.com/spf13/cobra"
)
func init() {
cmdsCmd.AddCommand(cmdsLsCmd)
cmdsLsCmd.Flags().StringP("event", "e", "", "event name, without 'before' or 'after'")
}
var cmdsLsCmd = &cobra.Command{
Use: "ls",
Short: "List all commands for each event",
Long: `List all commands for each event.`,
Args: cobra.NoArgs,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
s, err := d.store.Settings.Get()
checkErr(err)
evt := mustGetString(cmd.Flags(), "event")
if evt == "" {
printEvents(s.Commands)
} else {
show := map[string][]string{}
show["before_"+evt] = s.Commands["before_"+evt]
show["after_"+evt] = s.Commands["after_"+evt]
printEvents(show)
}
}, pythonConfig{}),
}

56
cmd/cmds_rm.go Normal file
View File

@@ -0,0 +1,56 @@
package cmd
import (
"strconv"
"github.com/spf13/cobra"
)
func init() {
cmdsCmd.AddCommand(cmdsRmCmd)
}
var cmdsRmCmd = &cobra.Command{
Use: "rm <event> <index> [index_end]",
Short: "Removes a command from an event hooker",
Long: `Removes a command from an event hooker. The provided index
is the same that's printed when you run 'cmds ls'. Note
that after each removal/addition, the index of the
commands change. So be careful when removing them after each
other.
You can also specify an optional parameter (index_end) so
you can remove all commands from 'index' to 'index_end',
including 'index_end'.`,
Args: func(cmd *cobra.Command, args []string) error {
if err := cobra.RangeArgs(2, 3)(cmd, args); err != nil {
return err
}
for _, arg := range args[1:] {
if _, err := strconv.Atoi(arg); err != nil {
return err
}
}
return nil
},
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
s, err := d.store.Settings.Get()
checkErr(err)
evt := args[0]
i, err := strconv.Atoi(args[1])
checkErr(err)
f := i
if len(args) == 3 {
f, err = strconv.Atoi(args[2])
checkErr(err)
}
s.Commands[evt] = append(s.Commands[evt][:i], s.Commands[evt][f+1:]...)
err = d.store.Settings.Save(s)
checkErr(err)
printEvents(s.Commands)
}, pythonConfig{}),
}

162
cmd/config.go Normal file
View File

@@ -0,0 +1,162 @@
package cmd
import (
"encoding/json"
nerrors "errors"
"fmt"
"os"
"strings"
"text/tabwriter"
"github.com/filebrowser/filebrowser/v2/auth"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func init() {
rootCmd.AddCommand(configCmd)
}
var configCmd = &cobra.Command{
Use: "config",
Short: "Configuration management utility",
Long: `Configuration management utility.`,
Args: cobra.NoArgs,
}
func addConfigFlags(flags *pflag.FlagSet) {
addServerFlags(flags)
addUserFlags(flags)
flags.BoolP("signup", "s", false, "allow users to signup")
flags.String("shell", "", "shell command to which other commands should be appended")
flags.String("auth.method", string(auth.MethodJSONAuth), "authentication type")
flags.String("auth.header", "", "HTTP header for auth.method=proxy")
flags.String("recaptcha.host", "https://www.google.com", "use another host for ReCAPTCHA. recaptcha.net might be useful in China")
flags.String("recaptcha.key", "", "ReCaptcha site key")
flags.String("recaptcha.secret", "", "ReCaptcha secret")
flags.String("branding.name", "", "replace 'File Browser' by this name")
flags.String("branding.files", "", "path to directory with images and custom styles")
flags.Bool("branding.disableExternal", false, "disable external links such as GitHub links")
}
func getAuthentication(flags *pflag.FlagSet, defaults ...interface{}) (settings.AuthMethod, auth.Auther) {
method := settings.AuthMethod(mustGetString(flags, "auth.method"))
var defaultAuther map[string]interface{}
if len(defaults) > 0 {
if hasAuth := defaults[0]; hasAuth != true {
for _, arg := range defaults {
switch def := arg.(type) {
case *settings.Settings:
method = settings.AuthMethod(def.AuthMethod)
case auth.Auther:
ms, err := json.Marshal(def)
checkErr(err)
json.Unmarshal(ms, &defaultAuther)
}
}
}
}
var auther auth.Auther
if method == auth.MethodProxyAuth {
header := mustGetString(flags, "auth.header")
if header == "" {
header = defaultAuther["header"].(string)
}
if header == "" {
checkErr(nerrors.New("you must set the flag 'auth.header' for method 'proxy'"))
}
auther = &auth.ProxyAuth{Header: header}
}
if method == auth.MethodNoAuth {
auther = &auth.NoAuth{}
}
if method == auth.MethodJSONAuth {
jsonAuth := &auth.JSONAuth{}
host := mustGetString(flags, "recaptcha.host")
key := mustGetString(flags, "recaptcha.key")
secret := mustGetString(flags, "recaptcha.secret")
if key == "" {
if kmap, ok := defaultAuther["recaptcha"].(map[string]interface{}); ok {
key = kmap["key"].(string)
}
}
if secret == "" {
if smap, ok := defaultAuther["recaptcha"].(map[string]interface{}); ok {
secret = smap["secret"].(string)
}
}
if key != "" && secret != "" {
jsonAuth.ReCaptcha = &auth.ReCaptcha{
Host: host,
Key: key,
Secret: secret,
}
}
auther = jsonAuth
}
if auther == nil {
panic(errors.ErrInvalidAuthMethod)
}
return method, auther
}
func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Auther) {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "Sign up:\t%t\n", set.Signup)
fmt.Fprintf(w, "Create User Dir:\t%t\n", set.CreateUserDir)
fmt.Fprintf(w, "Auth method:\t%s\n", set.AuthMethod)
fmt.Fprintf(w, "Shell:\t%s\t\n", strings.Join(set.Shell, " "))
fmt.Fprintln(w, "\nBranding:")
fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name)
fmt.Fprintf(w, "\tFiles override:\t%s\n", set.Branding.Files)
fmt.Fprintf(w, "\tDisable external links:\t%t\n", set.Branding.DisableExternal)
fmt.Fprintln(w, "\nServer:")
fmt.Fprintf(w, "\tLog:\t%s\n", ser.Log)
fmt.Fprintf(w, "\tPort:\t%s\n", ser.Port)
fmt.Fprintf(w, "\tBase URL:\t%s\n", ser.BaseURL)
fmt.Fprintf(w, "\tRoot:\t%s\n", ser.Root)
fmt.Fprintf(w, "\tSocket:\t%s\n", ser.Socket)
fmt.Fprintf(w, "\tAddress:\t%s\n", ser.Address)
fmt.Fprintf(w, "\tTLS Cert:\t%s\n", ser.TLSCert)
fmt.Fprintf(w, "\tTLS Key:\t%s\n", ser.TLSKey)
fmt.Fprintln(w, "\nDefaults:")
fmt.Fprintf(w, "\tScope:\t%s\n", set.Defaults.Scope)
fmt.Fprintf(w, "\tLocale:\t%s\n", set.Defaults.Locale)
fmt.Fprintf(w, "\tView mode:\t%s\n", set.Defaults.ViewMode)
fmt.Fprintf(w, "\tCommands:\t%s\n", strings.Join(set.Defaults.Commands, " "))
fmt.Fprintf(w, "\tSorting:\n")
fmt.Fprintf(w, "\t\tBy:\t%s\n", set.Defaults.Sorting.By)
fmt.Fprintf(w, "\t\tAsc:\t%t\n", set.Defaults.Sorting.Asc)
fmt.Fprintf(w, "\tPermissions:\n")
fmt.Fprintf(w, "\t\tAdmin:\t%t\n", set.Defaults.Perm.Admin)
fmt.Fprintf(w, "\t\tExecute:\t%t\n", set.Defaults.Perm.Execute)
fmt.Fprintf(w, "\t\tCreate:\t%t\n", set.Defaults.Perm.Create)
fmt.Fprintf(w, "\t\tRename:\t%t\n", set.Defaults.Perm.Rename)
fmt.Fprintf(w, "\t\tModify:\t%t\n", set.Defaults.Perm.Modify)
fmt.Fprintf(w, "\t\tDelete:\t%t\n", set.Defaults.Perm.Delete)
fmt.Fprintf(w, "\t\tShare:\t%t\n", set.Defaults.Perm.Share)
fmt.Fprintf(w, "\t\tDownload:\t%t\n", set.Defaults.Perm.Download)
w.Flush()
b, err := json.MarshalIndent(auther, "", " ")
checkErr(err)
fmt.Printf("\nAuther configuration (raw):\n\n%s\n\n", string(b))
}

25
cmd/config_cat.go Normal file
View File

@@ -0,0 +1,25 @@
package cmd
import (
"github.com/spf13/cobra"
)
func init() {
configCmd.AddCommand(configCatCmd)
}
var configCatCmd = &cobra.Command{
Use: "cat",
Short: "Prints the configuration",
Long: `Prints the configuration.`,
Args: cobra.NoArgs,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
set, err := d.store.Settings.Get()
checkErr(err)
ser, err := d.store.Settings.GetServer()
checkErr(err)
auther, err := d.store.Auth.Get(set.AuthMethod)
checkErr(err)
printSettings(ser, set, auther)
}, pythonConfig{}),
}

37
cmd/config_export.go Normal file
View File

@@ -0,0 +1,37 @@
package cmd
import (
"github.com/spf13/cobra"
)
func init() {
configCmd.AddCommand(configExportCmd)
}
var configExportCmd = &cobra.Command{
Use: "export <path>",
Short: "Export the configuration to a file",
Long: `Export the configuration to a file. The path must be for a
json or yaml file. This exported configuration can be changed,
and imported again with 'config import' command.`,
Args: jsonYamlArg,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
settings, err := d.store.Settings.Get()
checkErr(err)
server, err := d.store.Settings.GetServer()
checkErr(err)
auther, err := d.store.Auth.Get(settings.AuthMethod)
checkErr(err)
data := &settingsFile{
Settings: settings,
Auther: auther,
Server: server,
}
err = marshal(args[0], data)
checkErr(err)
}, pythonConfig{}),
}

91
cmd/config_import.go Normal file
View File

@@ -0,0 +1,91 @@
package cmd
import (
"encoding/json"
"errors"
"path/filepath"
"reflect"
"github.com/filebrowser/filebrowser/v2/auth"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/spf13/cobra"
)
func init() {
configCmd.AddCommand(configImportCmd)
}
type settingsFile struct {
Settings *settings.Settings `json:"settings"`
Server *settings.Server `json:"server"`
Auther interface{} `json:"auther"`
}
var configImportCmd = &cobra.Command{
Use: "import <path>",
Short: "Import a configuration file",
Long: `Import a configuration file. This will replace all the existing
configuration. Can be used with or without unexisting databases.
If used with a nonexisting database, a key will be generated
automatically. Otherwise the key will be kept the same as in the
database.
The path must be for a json or yaml file.`,
Args: jsonYamlArg,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
var key []byte
if d.hadDB {
settings, err := d.store.Settings.Get()
checkErr(err)
key = settings.Key
} else {
key = generateKey()
}
file := settingsFile{}
err := unmarshal(args[0], &file)
checkErr(err)
file.Settings.Key = key
err = d.store.Settings.Save(file.Settings)
checkErr(err)
err = d.store.Settings.SaveServer(file.Server)
checkErr(err)
var rawAuther interface{}
if filepath.Ext(args[0]) != ".json" {
rawAuther = cleanUpInterfaceMap(file.Auther.(map[interface{}]interface{}))
} else {
rawAuther = file.Auther
}
var auther auth.Auther
switch file.Settings.AuthMethod {
case auth.MethodJSONAuth:
auther = getAuther(auth.JSONAuth{}, rawAuther).(*auth.JSONAuth)
case auth.MethodNoAuth:
auther = getAuther(auth.NoAuth{}, rawAuther).(*auth.NoAuth)
case auth.MethodProxyAuth:
auther = getAuther(auth.ProxyAuth{}, rawAuther).(*auth.ProxyAuth)
default:
checkErr(errors.New("invalid auth method"))
}
err = d.store.Auth.Save(auther)
checkErr(err)
printSettings(file.Server, file.Settings, auther)
}, pythonConfig{allowNoDB: true}),
}
func getAuther(sample auth.Auther, data interface{}) interface{} {
authType := reflect.TypeOf(sample)
auther := reflect.New(authType).Interface()
bytes, err := json.Marshal(data)
checkErr(err)
err = json.Unmarshal(bytes, &auther)
checkErr(err)
return auther
}

69
cmd/config_init.go Normal file
View File

@@ -0,0 +1,69 @@
package cmd
import (
"fmt"
"strings"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/spf13/cobra"
)
func init() {
configCmd.AddCommand(configInitCmd)
addConfigFlags(configInitCmd.Flags())
}
var configInitCmd = &cobra.Command{
Use: "init",
Short: "Initialize a new database",
Long: `Initialize a new database to use with File Browser. All of
this options can be changed in the future with the command
'filebrowser config set'. The user related flags apply
to the defaults when creating new users and you don't
override the options.`,
Args: cobra.NoArgs,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
defaults := settings.UserDefaults{}
flags := cmd.Flags()
getUserDefaults(flags, &defaults, true)
authMethod, auther := getAuthentication(flags)
s := &settings.Settings{
Key: generateKey(),
Signup: mustGetBool(flags, "signup"),
Shell: strings.Split(strings.TrimSpace(mustGetString(flags, "shell")), " "),
AuthMethod: authMethod,
Defaults: defaults,
Branding: settings.Branding{
Name: mustGetString(flags, "branding.name"),
DisableExternal: mustGetBool(flags, "branding.disableExternal"),
Files: mustGetString(flags, "branding.files"),
},
}
ser := &settings.Server{
Address: mustGetString(flags, "address"),
Socket: mustGetString(flags, "socket"),
Root: mustGetString(flags, "root"),
BaseURL: mustGetString(flags, "baseurl"),
TLSKey: mustGetString(flags, "key"),
TLSCert: mustGetString(flags, "cert"),
Port: mustGetString(flags, "port"),
Log: mustGetString(flags, "log"),
}
err := d.store.Settings.Save(s)
checkErr(err)
err = d.store.Settings.SaveServer(ser)
checkErr(err)
err = d.store.Auth.Save(auther)
checkErr(err)
fmt.Printf(`
Congratulations! You've set up your database to use with File Browser.
Now add your first user via 'filebrowser users new' and then you just
need to call the main command to boot up the server.
`)
printSettings(ser, s, auther)
}, pythonConfig{noDB: true}),
}

80
cmd/config_set.go Normal file
View File

@@ -0,0 +1,80 @@
package cmd
import (
"strings"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func init() {
configCmd.AddCommand(configSetCmd)
addConfigFlags(configSetCmd.Flags())
}
var configSetCmd = &cobra.Command{
Use: "set",
Short: "Updates the configuration",
Long: `Updates the configuration. Set the flags for the options
you want to change. Other options will remain unchanged.`,
Args: cobra.NoArgs,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
flags := cmd.Flags()
set, err := d.store.Settings.Get()
checkErr(err)
ser, err := d.store.Settings.GetServer()
checkErr(err)
hasAuth := false
flags.Visit(func(flag *pflag.Flag) {
switch flag.Name {
case "baseurl":
ser.BaseURL = mustGetString(flags, flag.Name)
case "root":
ser.Root = mustGetString(flags, flag.Name)
case "socket":
ser.Socket = mustGetString(flags, flag.Name)
case "cert":
ser.TLSCert = mustGetString(flags, flag.Name)
case "key":
ser.TLSKey = mustGetString(flags, flag.Name)
case "address":
ser.Address = mustGetString(flags, flag.Name)
case "port":
ser.Port = mustGetString(flags, flag.Name)
case "log":
ser.Log = mustGetString(flags, flag.Name)
case "signup":
set.Signup = mustGetBool(flags, flag.Name)
case "auth.method":
hasAuth = true
case "shell":
set.Shell = strings.Split(strings.TrimSpace(mustGetString(flags, flag.Name)), " ")
case "branding.name":
set.Branding.Name = mustGetString(flags, flag.Name)
case "branding.disableExternal":
set.Branding.DisableExternal = mustGetBool(flags, flag.Name)
case "branding.files":
set.Branding.Files = mustGetString(flags, flag.Name)
}
})
getUserDefaults(flags, &set.Defaults, false)
// read the defaults
auther, err := d.store.Auth.Get(set.AuthMethod)
checkErr(err)
// check if there are new flags for existing auth method
set.AuthMethod, auther = getAuthentication(flags, hasAuth, set, auther)
err = d.store.Auth.Save(auther)
checkErr(err)
err = d.store.Settings.Save(set)
checkErr(err)
err = d.store.Settings.SaveServer(ser)
checkErr(err)
printSettings(ser, set, auther)
}, pythonConfig{}),
}

139
cmd/docs.go Normal file
View File

@@ -0,0 +1,139 @@
package cmd
import (
"bytes"
"fmt"
"io"
"os"
"path/filepath"
"sort"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func init() {
rootCmd.AddCommand(docsCmd)
docsCmd.Flags().StringP("path", "p", "./docs", "path to save the docs")
}
func printToc(names []string) {
for i, name := range names {
name = strings.TrimSuffix(name, filepath.Ext(name))
name = strings.Replace(name, "-", " ", -1)
names[i] = name
}
sort.Strings(names)
toc := ""
for _, name := range names {
toc += "* [" + name + "](cli/" + strings.Replace(name, " ", "-", -1) + ".md)\n"
}
fmt.Println(toc)
}
var docsCmd = &cobra.Command{
Use: "docs",
Hidden: true,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
dir := mustGetString(cmd.Flags(), "path")
generateDocs(rootCmd, dir)
names := []string{}
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil || info.IsDir() {
return err
}
if !strings.HasPrefix(info.Name(), "filebrowser") {
return nil
}
names = append(names, info.Name())
return nil
})
checkErr(err)
printToc(names)
},
}
func generateDocs(cmd *cobra.Command, dir string) {
for _, c := range cmd.Commands() {
if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() {
continue
}
generateDocs(c, dir)
}
basename := strings.Replace(cmd.CommandPath(), " ", "-", -1) + ".md"
filename := filepath.Join(dir, basename)
f, err := os.Create(filename)
checkErr(err)
defer f.Close()
generateMarkdown(cmd, f)
}
func generateMarkdown(cmd *cobra.Command, w io.Writer) {
cmd.InitDefaultHelpCmd()
cmd.InitDefaultHelpFlag()
buf := new(bytes.Buffer)
name := cmd.CommandPath()
short := cmd.Short
long := cmd.Long
if len(long) == 0 {
long = short
}
buf.WriteString("---\ndescription: " + short + "\n---\n\n")
buf.WriteString("# " + name + "\n\n")
buf.WriteString("## Synopsis\n\n")
buf.WriteString(long + "\n\n")
if cmd.Runnable() {
buf.WriteString(fmt.Sprintf("```\n%s\n```\n\n", cmd.UseLine()))
}
if len(cmd.Example) > 0 {
buf.WriteString("## Examples\n\n")
buf.WriteString(fmt.Sprintf("```\n%s\n```\n\n", cmd.Example))
}
printOptions(buf, cmd, name)
_, err := buf.WriteTo(w)
checkErr(err)
}
func generateFlagsTable(fs *pflag.FlagSet, buf io.StringWriter) {
buf.WriteString("| Name | Shorthand | Usage |\n")
buf.WriteString("|------|-----------|-------|\n")
fs.VisitAll(func(f *pflag.Flag) {
buf.WriteString("|" + f.Name + "|" + f.Shorthand + "|" + f.Usage + "|\n")
})
}
func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) {
flags := cmd.NonInheritedFlags()
flags.SetOutput(buf)
if flags.HasAvailableFlags() {
buf.WriteString("## Options\n\n")
generateFlagsTable(flags, buf)
buf.WriteString("\n")
}
parentFlags := cmd.InheritedFlags()
parentFlags.SetOutput(buf)
if parentFlags.HasAvailableFlags() {
buf.WriteString("### Inherited\n\n")
generateFlagsTable(parentFlags, buf)
buf.WriteString("\n")
}
}

View File

@@ -1,249 +0,0 @@
package main
import (
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"os"
"path/filepath"
"strings"
"github.com/asdine/storm"
"gopkg.in/natefinch/lumberjack.v2"
"github.com/filebrowser/filebrowser"
"github.com/filebrowser/filebrowser/bolt"
h "github.com/filebrowser/filebrowser/http"
"github.com/filebrowser/filebrowser/staticgen"
"github.com/hacdias/fileutils"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
)
var (
addr string
config string
database string
scope string
commands string
logfile string
staticg string
locale string
baseurl string
prefixurl string
viewMode string
recaptchakey string
recaptchasecret string
port int
noAuth bool
allowCommands bool
allowEdit bool
allowNew bool
allowPublish bool
showVer bool
)
func init() {
flag.StringVarP(&config, "config", "c", "", "Configuration file")
flag.IntVarP(&port, "port", "p", 0, "HTTP Port (default is random)")
flag.StringVarP(&addr, "address", "a", "", "Address to listen to (default is all of them)")
flag.StringVarP(&database, "database", "d", "./filebrowser.db", "Database file")
flag.StringVarP(&logfile, "log", "l", "stdout", "Errors logger; can use 'stdout', 'stderr' or file")
flag.StringVarP(&scope, "scope", "s", ".", "Default scope option for new users")
flag.StringVarP(&baseurl, "baseurl", "b", "", "Base URL")
flag.StringVar(&commands, "commands", "git svn hg", "Default commands option for new users")
flag.StringVar(&prefixurl, "prefixurl", "", "Prefix URL")
flag.StringVar(&viewMode, "view-mode", "mosaic", "Default view mode for new users")
flag.StringVar(&recaptchakey, "recaptcha-key", "", "ReCaptcha site key")
flag.StringVar(&recaptchasecret, "recaptcha-secret", "", "ReCaptcha secret")
flag.BoolVar(&allowCommands, "allow-commands", true, "Default allow commands option for new users")
flag.BoolVar(&allowEdit, "allow-edit", true, "Default allow edit 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(&noAuth, "no-auth", false, "Disables authentication")
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.BoolVarP(&showVer, "version", "v", false, "Show version")
}
func setupViper() {
viper.SetDefault("Address", "")
viper.SetDefault("Port", "0")
viper.SetDefault("Database", "./filebrowser.db")
viper.SetDefault("Scope", ".")
viper.SetDefault("Logger", "stdout")
viper.SetDefault("Commands", []string{"git", "svn", "hg"})
viper.SetDefault("AllowCommmands", true)
viper.SetDefault("AllowEdit", true)
viper.SetDefault("AllowNew", true)
viper.SetDefault("AllowPublish", true)
viper.SetDefault("StaticGen", "")
viper.SetDefault("Locale", "")
viper.SetDefault("NoAuth", false)
viper.SetDefault("BaseURL", "")
viper.SetDefault("PrefixURL", "")
viper.SetDefault("ViewMode", filebrowser.MosaicViewMode)
viper.SetDefault("ReCaptchaKey", "")
viper.SetDefault("ReCaptchaSecret", "")
viper.BindPFlag("Port", flag.Lookup("port"))
viper.BindPFlag("Address", flag.Lookup("address"))
viper.BindPFlag("Database", flag.Lookup("database"))
viper.BindPFlag("Scope", flag.Lookup("scope"))
viper.BindPFlag("Logger", flag.Lookup("log"))
viper.BindPFlag("Commands", flag.Lookup("commands"))
viper.BindPFlag("AllowCommands", flag.Lookup("allow-commands"))
viper.BindPFlag("AllowEdit", flag.Lookup("allow-edit"))
viper.BindPFlag("AlowNew", flag.Lookup("allow-new"))
viper.BindPFlag("AllowPublish", flag.Lookup("allow-publish"))
viper.BindPFlag("Locale", flag.Lookup("locale"))
viper.BindPFlag("StaticGen", flag.Lookup("staticgen"))
viper.BindPFlag("NoAuth", flag.Lookup("no-auth"))
viper.BindPFlag("BaseURL", flag.Lookup("baseurl"))
viper.BindPFlag("PrefixURL", flag.Lookup("prefixurl"))
viper.BindPFlag("ViewMode", flag.Lookup("view-mode"))
viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key"))
viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret"))
viper.SetConfigName("filebrowser")
viper.AddConfigPath(".")
}
func printVersion() {
fmt.Println("filebrowser version", filebrowser.Version)
os.Exit(0)
}
func main() {
setupViper()
flag.Parse()
if showVer {
printVersion()
}
// Add a configuration file if set.
if config != "" {
ext := filepath.Ext(config)
dir := filepath.Dir(config)
config = strings.TrimSuffix(config, ext)
if dir != "" {
viper.AddConfigPath(dir)
config = strings.TrimPrefix(config, dir)
}
viper.SetConfigName(config)
}
// Read configuration from a file if exists.
err := viper.ReadInConfig()
if err != nil {
if _, ok := err.(viper.ConfigParseError); ok {
panic(err)
}
}
// Set up process log before anything bad happens.
switch viper.GetString("Logger") {
case "stdout":
log.SetOutput(os.Stdout)
case "stderr":
log.SetOutput(os.Stderr)
case "":
log.SetOutput(ioutil.Discard)
default:
log.SetOutput(&lumberjack.Logger{
Filename: logfile,
MaxSize: 100,
MaxAge: 14,
MaxBackups: 10,
})
}
// Builds the address and a listener.
laddr := viper.GetString("Address") + ":" + viper.GetString("Port")
listener, err := net.Listen("tcp", laddr)
if err != nil {
log.Fatal(err)
}
// Tell the user the port in which is listening.
fmt.Println("Listening on", listener.Addr().String())
// Starts the server.
if err := http.Serve(listener, handler()); err != nil {
log.Fatal(err)
}
}
func handler() http.Handler {
db, err := storm.Open(viper.GetString("Database"))
if err != nil {
log.Fatal(err)
}
fm := &filebrowser.FileBrowser{
NoAuth: viper.GetBool("NoAuth"),
BaseURL: viper.GetString("BaseURL"),
PrefixURL: viper.GetString("PrefixURL"),
ReCaptchaKey: viper.GetString("ReCaptchaKey"),
ReCaptchaSecret: viper.GetString("ReCaptchaSecret"),
DefaultUser: &filebrowser.User{
AllowCommands: viper.GetBool("AllowCommands"),
AllowEdit: viper.GetBool("AllowEdit"),
AllowNew: viper.GetBool("AllowNew"),
AllowPublish: viper.GetBool("AllowPublish"),
Commands: viper.GetStringSlice("Commands"),
Rules: []*filebrowser.Rule{},
Locale: viper.GetString("Locale"),
CSS: "",
Scope: viper.GetString("Scope"),
FileSystem: fileutils.Dir(viper.GetString("Scope")),
ViewMode: viper.GetString("ViewMode"),
},
Store: &filebrowser.Store{
Config: bolt.ConfigStore{DB: db},
Users: bolt.UsersStore{DB: db},
Share: bolt.ShareStore{DB: db},
},
NewFS: func(scope string) filebrowser.FileSystem {
return fileutils.Dir(scope)
},
}
err = fm.Setup()
if err != nil {
log.Fatal(err)
}
switch viper.GetString("StaticGen") {
case "hugo":
hugo := &staticgen.Hugo{
Root: viper.GetString("Scope"),
Public: filepath.Join(viper.GetString("Scope"), "public"),
Args: []string{},
CleanPublic: true,
}
if err = fm.Attach(hugo); err != nil {
log.Fatal(err)
}
case "jekyll":
jekyll := &staticgen.Jekyll{
Root: viper.GetString("Scope"),
Public: filepath.Join(viper.GetString("Scope"), "_site"),
Args: []string{"build"},
CleanPublic: true,
}
if err = fm.Attach(jekyll); err != nil {
log.Fatal(err)
}
}
return h.Handler(fm)
}

24
cmd/hash.go Normal file
View File

@@ -0,0 +1,24 @@
package cmd
import (
"fmt"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(hashCmd)
}
var hashCmd = &cobra.Command{
Use: "hash <password>",
Short: "Hashes a password",
Long: `Hashes a password using bcrypt algorithm.`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
pwd, err := users.HashPwd(args[0])
checkErr(err)
fmt.Println(pwd)
},
}

352
cmd/root.go Normal file
View File

@@ -0,0 +1,352 @@
package cmd
import (
"crypto/tls"
"errors"
"io/ioutil"
"log"
"net"
"net/http"
"os"
"os/signal"
"path/filepath"
"strings"
"syscall"
"github.com/filebrowser/filebrowser/v2/auth"
fbhttp "github.com/filebrowser/filebrowser/v2/http"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/storage"
"github.com/filebrowser/filebrowser/v2/users"
homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
v "github.com/spf13/viper"
lumberjack "gopkg.in/natefinch/lumberjack.v2"
)
var (
cfgFile string
)
func init() {
cobra.OnInitialize(initConfig)
rootCmd.SetVersionTemplate("File Browser version {{printf \"%s\" .Version}}\n")
flags := rootCmd.Flags()
persistent := rootCmd.PersistentFlags()
persistent.StringVarP(&cfgFile, "config", "c", "", "config file path")
persistent.StringP("database", "d", "./filebrowser.db", "database path")
flags.Bool("noauth", false, "use the noauth auther when using quick setup")
flags.String("username", "admin", "username for the first user when using quick config")
flags.String("password", "", "hashed password for the first user when using quick config (default \"admin\")")
addServerFlags(flags)
}
func addServerFlags(flags *pflag.FlagSet) {
flags.StringP("address", "a", "127.0.0.1", "address to listen on")
flags.StringP("log", "l", "stdout", "log output")
flags.StringP("port", "p", "8080", "port to listen on")
flags.StringP("cert", "t", "", "tls certificate")
flags.StringP("key", "k", "", "tls key")
flags.StringP("root", "r", ".", "root to prepend to relative paths")
flags.String("socket", "", "socket to listen to (cannot be used with address, port, cert nor key flags)")
flags.StringP("baseurl", "b", "", "base url")
}
var rootCmd = &cobra.Command{
Use: "filebrowser",
Short: "A stylish web-based 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
web interface.
If you've never run File Browser, you'll need to have a database for
it. Don't worry: you don't need to setup a separate database server.
We're using Bolt DB which is a single file database and all managed
by ourselves.
For this specific command, all the flags you have available (except
"config" for the configuration file), can be given either through
environment variables or configuration files.
If you don't set "config", it will look for a configuration file called
.filebrowser.{json, toml, yaml, yml} in the following directories:
- ./
- $HOME/
- /etc/filebrowser/
The precedence of the configuration values are as follows:
- flags
- environment variables
- configuration file
- database values
- defaults
The environment variables are prefixed by "FB_" followed by the option
name in caps. So to set "database" via an env variable, you should
set FB_DATABASE.
Also, if the database path doesn't exist, File Browser will enter into
the quick setup mode and a new database will be bootstraped and a new
user created with the credentials from options "username" and "password".`,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
log.Println(cfgFile)
if !d.hadDB {
quickSetup(cmd.Flags(), d)
}
server := getRunParams(cmd.Flags(), d.store)
setupLog(server.Log)
root, err := filepath.Abs(server.Root)
checkErr(err)
server.Root = root
adr := server.Address + ":" + server.Port
var listener net.Listener
if server.Socket != "" {
listener, err = net.Listen("unix", server.Socket)
checkErr(err)
} else if server.TLSKey != "" && server.TLSCert != "" {
cer, err := tls.LoadX509KeyPair(server.TLSCert, server.TLSKey)
checkErr(err)
listener, err = tls.Listen("tcp", adr, &tls.Config{Certificates: []tls.Certificate{cer}})
checkErr(err)
} else {
listener, err = net.Listen("tcp", adr)
checkErr(err)
}
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, os.Interrupt, syscall.SIGTERM)
go cleanupHandler(listener, sigc)
handler, err := fbhttp.NewHandler(d.store, server)
checkErr(err)
defer listener.Close()
log.Println("Listening on", listener.Addr().String())
if err := http.Serve(listener, handler); err != nil {
log.Fatal(err)
}
}, pythonConfig{allowNoDB: true}),
}
func cleanupHandler(listener net.Listener, c chan os.Signal) {
sig := <-c
log.Printf("Caught signal %s: shutting down.", sig)
listener.Close()
os.Exit(0)
}
func getRunParams(flags *pflag.FlagSet, st *storage.Storage) *settings.Server {
server, err := st.Settings.GetServer()
checkErr(err)
if val, set := getParamB(flags, "root"); set {
server.Root = val
}
if val, set := getParamB(flags, "baseurl"); set {
server.BaseURL = val
}
if val, set := getParamB(flags, "log"); set {
server.Log = val
}
isSocketSet := false
isAddrSet := false
if val, set := getParamB(flags, "address"); set {
server.Address = val
isAddrSet = isAddrSet || set
}
if val, set := getParamB(flags, "port"); set {
server.Port = val
isAddrSet = isAddrSet || set
}
if val, set := getParamB(flags, "key"); set {
server.TLSKey = val
isAddrSet = isAddrSet || set
}
if val, set := getParamB(flags, "cert"); set {
server.TLSCert = val
isAddrSet = isAddrSet || set
}
if val, set := getParamB(flags, "socket"); set {
server.Socket = val
isSocketSet = isSocketSet || set
}
if isAddrSet && isSocketSet {
checkErr(errors.New("--socket flag cannot be used with --address, --port, --key nor --cert"))
}
// Do not use saved Socket if address was manually set.
if isAddrSet && server.Socket != "" {
server.Socket = ""
}
return server
}
// getParamB returns a parameter as a string and a boolean to tell if it is different from the default
//
// NOTE: we could simply bind the flags to viper and use IsSet.
// Although there is a bug on Viper that always returns true on IsSet
// if a flag is binded. Our alternative way is to manually check
// the flag and then the value from env/config/gotten by viper.
// https://github.com/spf13/viper/pull/331
func getParamB(flags *pflag.FlagSet, key string) (string, bool) {
value, _ := flags.GetString(key)
// If set on Flags, use it.
if flags.Changed(key) {
return value, true
}
// If set through viper (env, config), return it.
if v.IsSet(key) {
return v.GetString(key), true
}
// Otherwise use default value on flags.
return value, false
}
func getParam(flags *pflag.FlagSet, key string) string {
val, _ := getParamB(flags, key)
return val
}
func setupLog(logMethod string) {
switch logMethod {
case "stdout":
log.SetOutput(os.Stdout)
case "stderr":
log.SetOutput(os.Stderr)
case "":
log.SetOutput(ioutil.Discard)
default:
log.SetOutput(&lumberjack.Logger{
Filename: logMethod,
MaxSize: 100,
MaxAge: 14,
MaxBackups: 10,
})
}
}
func quickSetup(flags *pflag.FlagSet, d pythonData) {
set := &settings.Settings{
Key: generateKey(),
Signup: false,
CreateUserDir: false,
Defaults: settings.UserDefaults{
Scope: ".",
Locale: "en",
Perm: users.Permissions{
Admin: false,
Execute: true,
Create: true,
Rename: true,
Modify: true,
Delete: true,
Share: true,
Download: true,
},
},
}
var err error
if _, noauth := getParamB(flags, "noauth"); noauth {
set.AuthMethod = auth.MethodNoAuth
err = d.store.Auth.Save(&auth.NoAuth{})
} else {
set.AuthMethod = auth.MethodJSONAuth
err = d.store.Auth.Save(&auth.JSONAuth{})
}
checkErr(err)
err = d.store.Settings.Save(set)
checkErr(err)
ser := &settings.Server{
BaseURL: getParam(flags, "baseurl"),
Port: getParam(flags, "port"),
Log: getParam(flags, "log"),
TLSKey: getParam(flags, "key"),
TLSCert: getParam(flags, "cert"),
Address: getParam(flags, "address"),
Root: getParam(flags, "root"),
}
err = d.store.Settings.SaveServer(ser)
checkErr(err)
username := getParam(flags, "username")
password := getParam(flags, "password")
if password == "" {
password, err = users.HashPwd("admin")
checkErr(err)
}
if username == "" || password == "" {
log.Fatal("username and password cannot be empty during quick setup")
}
user := &users.User{
Username: username,
Password: password,
LockPassword: false,
}
set.Defaults.Apply(user)
user.Perm.Admin = true
err = d.store.Users.Save(user)
checkErr(err)
}
func initConfig() {
if cfgFile == "" {
home, err := homedir.Dir()
checkErr(err)
v.AddConfigPath(".")
v.AddConfigPath(home)
v.AddConfigPath("/etc/filebrowser/")
v.SetConfigName(".filebrowser")
} else {
v.SetConfigFile(cfgFile)
}
v.SetEnvPrefix("FB")
v.AutomaticEnv()
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
if err := v.ReadInConfig(); err != nil {
if _, ok := err.(v.ConfigParseError); ok {
panic(err)
}
cfgFile = "No config file used"
} else {
cfgFile = "Using config file: " + v.ConfigFileUsed()
}
}

65
cmd/rule_rm.go Normal file
View File

@@ -0,0 +1,65 @@
package cmd
import (
"strconv"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/spf13/cobra"
)
func init() {
rulesCmd.AddCommand(rulesRmCommand)
rulesRmCommand.Flags().Uint("index", 0, "index of rule to remove")
rulesRmCommand.MarkFlagRequired("index")
}
var rulesRmCommand = &cobra.Command{
Use: "rm <index> [index_end]",
Short: "Remove a global rule or user rule",
Long: `Remove a global rule or user rule. The provided index
is the same that's printed when you run 'rules ls'. Note
that after each removal/addition, the index of the
commands change. So be careful when removing them after each
other.
You can also specify an optional parameter (index_end) so
you can remove all commands from 'index' to 'index_end',
including 'index_end'.`,
Args: func(cmd *cobra.Command, args []string) error {
if err := cobra.RangeArgs(1, 2)(cmd, args); err != nil {
return err
}
for _, arg := range args {
if _, err := strconv.Atoi(arg); err != nil {
return err
}
}
return nil
},
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
i, err := strconv.Atoi(args[0])
checkErr(err)
f := i
if len(args) == 2 {
f, err = strconv.Atoi(args[1])
checkErr(err)
}
user := func(u *users.User) {
u.Rules = append(u.Rules[:i], u.Rules[f+1:]...)
err := d.store.Users.Save(u)
checkErr(err)
}
global := func(s *settings.Settings) {
s.Rules = append(s.Rules[:i], s.Rules[f+1:]...)
err := d.store.Settings.Save(s)
checkErr(err)
}
runRules(d.store, cmd, user, global)
}, pythonConfig{}),
}

91
cmd/rules.go Normal file
View File

@@ -0,0 +1,91 @@
package cmd
import (
"fmt"
"github.com/filebrowser/filebrowser/v2/rules"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/storage"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func init() {
rootCmd.AddCommand(rulesCmd)
rulesCmd.PersistentFlags().StringP("username", "u", "", "username of user to which the rules apply")
rulesCmd.PersistentFlags().UintP("id", "i", 0, "id of user to which the rules apply")
}
var rulesCmd = &cobra.Command{
Use: "rules",
Short: "Rules management utility",
Long: `On each subcommand you'll have available at least two flags:
"username" and "id". You must either set only one of them
or none. If you set one of them, the command will apply to
an user, otherwise it will be applied to the global set or
rules.`,
Args: cobra.NoArgs,
}
func runRules(st *storage.Storage, cmd *cobra.Command, users func(*users.User), global func(*settings.Settings)) {
id := getUserIdentifier(cmd.Flags())
if id != nil {
user, err := st.Users.Get("", id)
checkErr(err)
if users != nil {
users(user)
}
printRules(user.Rules, id)
return
}
s, err := st.Settings.Get()
checkErr(err)
if global != nil {
global(s)
}
printRules(s.Rules, id)
}
func getUserIdentifier(flags *pflag.FlagSet) interface{} {
id := mustGetUint(flags, "id")
username := mustGetString(flags, "username")
if id != 0 {
return id
} else if username != "" {
return username
}
return nil
}
func printRules(rules []rules.Rule, id interface{}) {
if id == nil {
fmt.Printf("Global Rules:\n\n")
} else {
fmt.Printf("Rules for user %v:\n\n", id)
}
for id, rule := range rules {
fmt.Printf("(%d) ", id)
if rule.Regex {
if rule.Allow {
fmt.Printf("Allow Regex: \t%s\n", rule.Regexp.Raw)
} else {
fmt.Printf("Disallow Regex: \t%s\n", rule.Regexp.Raw)
}
} else {
if rule.Allow {
fmt.Printf("Allow Path: \t%s\n", rule.Path)
} else {
fmt.Printf("Disallow Path: \t%s\n", rule.Path)
}
}
}
}

57
cmd/rules_add.go Normal file
View File

@@ -0,0 +1,57 @@
package cmd
import (
"regexp"
"github.com/filebrowser/filebrowser/v2/rules"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/spf13/cobra"
)
func init() {
rulesCmd.AddCommand(rulesAddCmd)
rulesAddCmd.Flags().BoolP("allow", "a", false, "indicates this is an allow rule")
rulesAddCmd.Flags().BoolP("regex", "r", false, "indicates this is a regex rule")
}
var rulesAddCmd = &cobra.Command{
Use: "add <path|expression>",
Short: "Add a global rule or user rule",
Long: `Add a global rule or user rule.`,
Args: cobra.ExactArgs(1),
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
allow := mustGetBool(cmd.Flags(), "allow")
regex := mustGetBool(cmd.Flags(), "regex")
exp := args[0]
if regex {
regexp.MustCompile(exp)
}
rule := rules.Rule{
Allow: allow,
Regex: regex,
}
if regex {
rule.Regexp = &rules.Regexp{Raw: exp}
} else {
rule.Path = exp
}
user := func(u *users.User) {
u.Rules = append(u.Rules, rule)
err := d.store.Users.Save(u)
checkErr(err)
}
global := func(s *settings.Settings) {
s.Rules = append(s.Rules, rule)
err := d.store.Settings.Save(s)
checkErr(err)
}
runRules(d.store, cmd, user, global)
}, pythonConfig{}),
}

19
cmd/rules_ls.go Normal file
View File

@@ -0,0 +1,19 @@
package cmd
import (
"github.com/spf13/cobra"
)
func init() {
rulesCmd.AddCommand(rulesLsCommand)
}
var rulesLsCommand = &cobra.Command{
Use: "ls",
Short: "List global rules or user specific rules",
Long: `List global rules or user specific rules.`,
Args: cobra.NoArgs,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
runRules(d.store, cmd, nil, nil)
}, pythonConfig{}),
}

30
cmd/upgrade.go Normal file
View File

@@ -0,0 +1,30 @@
package cmd
import (
"github.com/filebrowser/filebrowser/v2/storage/bolt/importer"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(upgradeCmd)
upgradeCmd.Flags().String("old.database", "", "")
upgradeCmd.Flags().String("old.config", "", "")
upgradeCmd.MarkFlagRequired("old.database")
}
var upgradeCmd = &cobra.Command{
Use: "upgrade",
Short: "Upgrades an old configuration",
Long: `Upgrades an old configuration. This command DOES NOT
import share links because they are incompatible with
this version.`,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
flags := cmd.Flags()
oldDB := mustGetString(flags, "old.database")
oldConf := mustGetString(flags, "old.config")
err := importer.Import(oldDB, oldConf, getParam(flags, "database"))
checkErr(err)
},
}

128
cmd/users.go Normal file
View File

@@ -0,0 +1,128 @@
package cmd
import (
"errors"
"fmt"
"os"
"strconv"
"text/tabwriter"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func init() {
rootCmd.AddCommand(usersCmd)
}
var usersCmd = &cobra.Command{
Use: "users",
Short: "Users management utility",
Long: `Users management utility.`,
Args: cobra.NoArgs,
}
func printUsers(users []*users.User) {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(w, "ID\tUsername\tScope\tLocale\tV. Mode\tAdmin\tExecute\tCreate\tRename\tModify\tDelete\tShare\tDownload\tPwd Lock")
for _, user := range users {
fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%s\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t%t\t\n",
user.ID,
user.Username,
user.Scope,
user.Locale,
user.ViewMode,
user.Perm.Admin,
user.Perm.Execute,
user.Perm.Create,
user.Perm.Rename,
user.Perm.Modify,
user.Perm.Delete,
user.Perm.Share,
user.Perm.Download,
user.LockPassword,
)
}
w.Flush()
}
func parseUsernameOrID(arg string) (string, uint) {
id, err := strconv.ParseUint(arg, 10, 0)
if err != nil {
return arg, 0
}
return "", uint(id)
}
func addUserFlags(flags *pflag.FlagSet) {
flags.Bool("perm.admin", false, "admin perm for users")
flags.Bool("perm.execute", true, "execute perm for users")
flags.Bool("perm.create", true, "create perm for users")
flags.Bool("perm.rename", true, "rename perm for users")
flags.Bool("perm.modify", true, "modify perm for users")
flags.Bool("perm.delete", true, "delete perm for users")
flags.Bool("perm.share", true, "share perm for users")
flags.Bool("perm.download", true, "download perm for users")
flags.String("sorting.by", "name", "sorting mode (name, size or modified)")
flags.Bool("sorting.asc", false, "sorting by ascending order")
flags.Bool("lockPassword", false, "lock password")
flags.StringSlice("commands", nil, "a list of the commands a user can execute")
flags.String("scope", ".", "scope for users")
flags.String("locale", "en", "locale for users")
flags.String("viewMode", string(users.ListViewMode), "view mode for users")
}
func getViewMode(flags *pflag.FlagSet) users.ViewMode {
viewMode := users.ViewMode(mustGetString(flags, "viewMode"))
if viewMode != users.ListViewMode && viewMode != users.MosaicViewMode {
checkErr(errors.New("view mode must be \"" + string(users.ListViewMode) + "\" or \"" + string(users.MosaicViewMode) + "\""))
}
return viewMode
}
func getUserDefaults(flags *pflag.FlagSet, defaults *settings.UserDefaults, all bool) {
visit := func(flag *pflag.Flag) {
switch flag.Name {
case "scope":
defaults.Scope = mustGetString(flags, flag.Name)
case "locale":
defaults.Locale = mustGetString(flags, flag.Name)
case "viewMode":
defaults.ViewMode = getViewMode(flags)
case "perm.admin":
defaults.Perm.Admin = mustGetBool(flags, flag.Name)
case "perm.execute":
defaults.Perm.Execute = mustGetBool(flags, flag.Name)
case "perm.create":
defaults.Perm.Create = mustGetBool(flags, flag.Name)
case "perm.rename":
defaults.Perm.Rename = mustGetBool(flags, flag.Name)
case "perm.modify":
defaults.Perm.Modify = mustGetBool(flags, flag.Name)
case "perm.delete":
defaults.Perm.Delete = mustGetBool(flags, flag.Name)
case "perm.share":
defaults.Perm.Share = mustGetBool(flags, flag.Name)
case "perm.download":
defaults.Perm.Download = mustGetBool(flags, flag.Name)
case "commands":
commands, err := flags.GetStringSlice(flag.Name)
checkErr(err)
defaults.Commands = commands
case "sorting.by":
defaults.Sorting.By = mustGetString(flags, flag.Name)
case "sorting.asc":
defaults.Sorting.Asc = mustGetBool(flags, flag.Name)
}
}
if all {
flags.VisitAll(visit)
} else {
flags.Visit(visit)
}
}

50
cmd/users_add.go Normal file
View File

@@ -0,0 +1,50 @@
package cmd
import (
"github.com/filebrowser/filebrowser/v2/users"
"github.com/spf13/cobra"
)
func init() {
usersCmd.AddCommand(usersAddCmd)
addUserFlags(usersAddCmd.Flags())
}
var usersAddCmd = &cobra.Command{
Use: "add <username> <password>",
Short: "Create a new user",
Long: `Create a new user and add it to the database.`,
Args: cobra.ExactArgs(2),
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
s, err := d.store.Settings.Get()
checkErr(err)
getUserDefaults(cmd.Flags(), &s.Defaults, false)
password, err := users.HashPwd(args[1])
checkErr(err)
user := &users.User{
Username: args[0],
Password: password,
LockPassword: mustGetBool(cmd.Flags(), "lockPassword"),
}
s.Defaults.Apply(user)
servSettings, err := d.store.Settings.GetServer()
checkErr(err)
//since getUserDefaults() polluted s.Defaults.Scope
//which makes the Scope not the one saved in the db
//we need the right s.Defaults.Scope here
s2, err := d.store.Settings.Get()
checkErr(err)
userHome, err := s2.MakeUserDir(user.Username, user.Scope, servSettings.Root)
checkErr(err)
user.Scope = userHome
err = d.store.Users.Save(user)
checkErr(err)
printUsers([]*users.User{user})
}, pythonConfig{}),
}

24
cmd/users_export.go Normal file
View File

@@ -0,0 +1,24 @@
package cmd
import (
"github.com/spf13/cobra"
)
func init() {
usersCmd.AddCommand(usersExportCmd)
}
var usersExportCmd = &cobra.Command{
Use: "export <path>",
Short: "Export all users to a file.",
Long: `Export all users to a json or yaml file. Please indicate the
path to the file where you want to write the users.`,
Args: jsonYamlArg,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
list, err := d.store.Users.Gets("")
checkErr(err)
err = marshal(args[0], list)
checkErr(err)
}, pythonConfig{}),
}

50
cmd/users_find.go Normal file
View File

@@ -0,0 +1,50 @@
package cmd
import (
"github.com/filebrowser/filebrowser/v2/users"
"github.com/spf13/cobra"
)
func init() {
usersCmd.AddCommand(usersFindCmd)
usersCmd.AddCommand(usersLsCmd)
}
var usersFindCmd = &cobra.Command{
Use: "find <id|username>",
Short: "Find a user by username or id",
Long: `Find a user by username or id. If no flag is set, all users will be printed.`,
Args: cobra.ExactArgs(1),
Run: findUsers,
}
var usersLsCmd = &cobra.Command{
Use: "ls",
Short: "List all users.",
Args: cobra.NoArgs,
Run: findUsers,
}
var findUsers = python(func(cmd *cobra.Command, args []string, d pythonData) {
var (
list []*users.User
user *users.User
err error
)
if len(args) == 1 {
username, id := parseUsernameOrID(args[0])
if username != "" {
user, err = d.store.Users.Get("", username)
} else {
user, err = d.store.Users.Get("", id)
}
list = []*users.User{user}
} else {
list, err = d.store.Users.Gets("")
}
checkErr(err)
printUsers(list)
}, pythonConfig{})

87
cmd/users_import.go Normal file
View File

@@ -0,0 +1,87 @@
package cmd
import (
"errors"
"os"
"strconv"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/spf13/cobra"
)
func init() {
usersCmd.AddCommand(usersImportCmd)
usersImportCmd.Flags().Bool("overwrite", false, "overwrite users with the same id/username combo")
usersImportCmd.Flags().Bool("replace", false, "replace the entire user base")
}
var usersImportCmd = &cobra.Command{
Use: "import <path>",
Short: "Import users from a file",
Long: `Import users from a file. The path must be for a json or yaml
file. You can use this command to import new users to your
installation. For that, just don't place their ID on the files
list or set it to 0.`,
Args: jsonYamlArg,
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
fd, err := os.Open(args[0])
checkErr(err)
defer fd.Close()
list := []*users.User{}
err = unmarshal(args[0], &list)
checkErr(err)
for _, user := range list {
err = user.Clean("")
checkErr(err)
}
if mustGetBool(cmd.Flags(), "replace") {
oldUsers, err := d.store.Users.Gets("")
checkErr(err)
err = marshal("users.backup.json", list)
checkErr(err)
for _, user := range oldUsers {
err = d.store.Users.Delete(user.ID)
checkErr(err)
}
}
overwrite := mustGetBool(cmd.Flags(), "overwrite")
for _, user := range list {
onDB, err := d.store.Users.Get("", user.ID)
// User exists in DB.
if err == nil {
if !overwrite {
checkErr(errors.New("user " + strconv.Itoa(int(user.ID)) + " is already registred"))
}
// If the usernames mismatch, check if there is another one in the DB
// with the new username. If there is, print an error and cancel the
// operation
if user.Username != onDB.Username {
conflictuous, err := d.store.Users.Get("", user.Username)
if err == nil {
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)
checkErr(err)
}
}, pythonConfig{}),
}
func usernameConflictError(username string, original, new uint) error {
return errors.New("can't import user with ID " + strconv.Itoa(int(new)) + " and username \"" + username + "\" because the username is already registred with the user " + strconv.Itoa(int(original)))
}

31
cmd/users_rm.go Normal file
View File

@@ -0,0 +1,31 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
func init() {
usersCmd.AddCommand(usersRmCmd)
}
var usersRmCmd = &cobra.Command{
Use: "rm <id|username>",
Short: "Delete a user by username or id",
Long: `Delete a user by username or id`,
Args: cobra.ExactArgs(1),
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
username, id := parseUsernameOrID(args[0])
var err error
if username != "" {
err = d.store.Users.Delete(username)
} else {
err = d.store.Users.Delete(id)
}
checkErr(err)
fmt.Println("user deleted successfully")
}, pythonConfig{}),
}

72
cmd/users_update.go Normal file
View File

@@ -0,0 +1,72 @@
package cmd
import (
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/spf13/cobra"
)
func init() {
usersCmd.AddCommand(usersUpdateCmd)
usersUpdateCmd.Flags().StringP("password", "p", "", "new password")
usersUpdateCmd.Flags().StringP("username", "u", "", "new username")
addUserFlags(usersUpdateCmd.Flags())
}
var usersUpdateCmd = &cobra.Command{
Use: "update <id|username>",
Short: "Updates an existing user",
Long: `Updates an existing user. Set the flags for the
options you want to change.`,
Args: cobra.ExactArgs(1),
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
username, id := parseUsernameOrID(args[0])
flags := cmd.Flags()
password := mustGetString(flags, "password")
newUsername := mustGetString(flags, "username")
var (
err error
user *users.User
)
if id != 0 {
user, err = d.store.Users.Get("", id)
} else {
user, err = d.store.Users.Get("", username)
}
checkErr(err)
defaults := settings.UserDefaults{
Scope: user.Scope,
Locale: user.Locale,
ViewMode: user.ViewMode,
Perm: user.Perm,
Sorting: user.Sorting,
Commands: user.Commands,
}
getUserDefaults(flags, &defaults, false)
user.Scope = defaults.Scope
user.Locale = defaults.Locale
user.ViewMode = defaults.ViewMode
user.Perm = defaults.Perm
user.Commands = defaults.Commands
user.Sorting = defaults.Sorting
user.LockPassword = mustGetBool(flags, "lockPassword")
if newUsername != "" {
user.Username = newUsername
}
if password != "" {
user.Password, err = users.HashPwd(password)
checkErr(err)
}
err = d.store.Users.Update(user)
checkErr(err)
printUsers([]*users.User{user})
}, pythonConfig{}),
}

177
cmd/utils.go Normal file
View File

@@ -0,0 +1,177 @@
package cmd
import (
"encoding/json"
"errors"
"fmt"
"log"
"os"
"path/filepath"
"github.com/asdine/storm"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/storage"
"github.com/filebrowser/filebrowser/v2/storage/bolt"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
yaml "gopkg.in/yaml.v2"
)
func checkErr(err error) {
if err != nil {
log.Fatal(err)
}
}
func mustGetString(flags *pflag.FlagSet, flag string) string {
s, err := flags.GetString(flag)
checkErr(err)
return s
}
func mustGetBool(flags *pflag.FlagSet, flag string) bool {
b, err := flags.GetBool(flag)
checkErr(err)
return b
}
func mustGetUint(flags *pflag.FlagSet, flag string) uint {
b, err := flags.GetUint(flag)
checkErr(err)
return b
}
func generateKey() []byte {
k, err := settings.GenerateKey()
checkErr(err)
return k
}
type cobraFunc func(cmd *cobra.Command, args []string)
type pythonFunc func(cmd *cobra.Command, args []string, data pythonData)
type pythonConfig struct {
noDB bool
allowNoDB bool
}
type pythonData struct {
hadDB bool
store *storage.Storage
}
func dbExists(path string) (bool, error) {
stat, err := os.Stat(path)
if err == nil {
return stat.Size() != 0, nil
}
if os.IsNotExist(err) {
d := filepath.Dir(path)
_, err = os.Stat(d)
if os.IsNotExist(err) {
os.MkdirAll(d, 0700)
return false, nil
}
}
return false, err
}
func python(fn pythonFunc, cfg pythonConfig) cobraFunc {
return func(cmd *cobra.Command, args []string) {
data := pythonData{hadDB: true}
path := getParam(cmd.Flags(), "database")
exists, err := dbExists(path)
if err != nil {
panic(err)
} else if exists && cfg.noDB {
log.Fatal(path + " already exists")
} else if !exists && !cfg.noDB && !cfg.allowNoDB {
log.Fatal(path + " does not exist. Please run 'filebrowser config init' first.")
}
data.hadDB = exists
db, err := storm.Open(path)
checkErr(err)
defer db.Close()
data.store, err = bolt.NewStorage(db)
checkErr(err)
fn(cmd, args, data)
}
}
func marshal(filename string, data interface{}) error {
fd, err := os.Create(filename)
checkErr(err)
defer fd.Close()
switch ext := filepath.Ext(filename); ext {
case ".json":
encoder := json.NewEncoder(fd)
encoder.SetIndent("", " ")
return encoder.Encode(data)
case ".yml", ".yaml":
encoder := yaml.NewEncoder(fd)
return encoder.Encode(data)
default:
return errors.New("invalid format: " + ext)
}
}
func unmarshal(filename string, data interface{}) error {
fd, err := os.Open(filename)
checkErr(err)
defer fd.Close()
switch ext := filepath.Ext(filename); ext {
case ".json":
return json.NewDecoder(fd).Decode(data)
case ".yml", ".yaml":
return yaml.NewDecoder(fd).Decode(data)
default:
return errors.New("invalid format: " + ext)
}
}
func jsonYamlArg(cmd *cobra.Command, args []string) error {
if err := cobra.ExactArgs(1)(cmd, args); err != nil {
return err
}
switch ext := filepath.Ext(args[0]); ext {
case ".json", ".yml", ".yaml":
return nil
default:
return errors.New("invalid format: " + ext)
}
}
func cleanUpInterfaceMap(in map[interface{}]interface{}) map[string]interface{} {
result := make(map[string]interface{})
for k, v := range in {
result[fmt.Sprintf("%v", k)] = cleanUpMapValue(v)
}
return result
}
func cleanUpInterfaceArray(in []interface{}) []interface{} {
result := make([]interface{}, len(in))
for i, v := range in {
result[i] = cleanUpMapValue(v)
}
return result
}
func cleanUpMapValue(v interface{}) interface{} {
switch v := v.(type) {
case []interface{}:
return cleanUpInterfaceArray(v)
case map[interface{}]interface{}:
return cleanUpInterfaceMap(v)
default:
return v
}
}

20
cmd/version.go Normal file
View File

@@ -0,0 +1,20 @@
package cmd
import (
"fmt"
"github.com/filebrowser/filebrowser/v2/version"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(versionCmd)
}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("File Browser v" + version.Version + "/" + version.CommitSHA)
},
}

73
doc.go
View File

@@ -1,73 +0,0 @@
/*
Package filebrowser provides a web interface to access your files
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.
import (
fm "github.com/filebrowser/filebrowser"
h "github.com/filebrowser/filebrowser/http"
)
Then, you should create a new FileBrowser object with your options. In this
case, I'm using BoltDB (via Storm package) as a Store. So, you'll also need
to import "github.com/filebrowser/filebrowser/bolt".
db, _ := storm.Open("bolt.db")
m := &fm.FileBrowser{
NoAuth: false,
DefaultUser: &fm.User{
AllowCommands: true,
AllowEdit: true,
AllowNew: true,
AllowPublish: true,
Commands: []string{"git"},
Rules: []*fm.Rule{},
Locale: "en",
CSS: "",
Scope: ".",
FileSystem: fileutils.Dir("."),
},
Store: &fm.Store{
Config: bolt.ConfigStore{DB: db},
Users: bolt.UsersStore{DB: db},
Share: bolt.ShareStore{DB: db},
},
NewFS: func(scope string) fm.FileSystem {
return fileutils.Dir(scope)
},
}
The credentials for the first user are always 'admin' for both the user and
the password, and they can be changed later through the settings. The first
user is always an Admin and has all of the permissions set to 'true'.
Then, you should set the Prefix URL and the Base URL, using the following
functions:
m.SetBaseURL("/")
m.SetPrefixURL("/")
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.
This is a function that will rarely be used. You can see one example on Caddy
filemanager plugin.
The Base URL is the URL path where you want File Manager to be available in. If
you want to be available at the root path, you should call:
m.SetBaseURL("/")
But if you want to access it at '/admin', you would call:
m.SetBaseURL("/admin")
Now, that you already have a File Manager instance created, you just need to
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.
One simple implementation for this, at port 80, in the root of the domain, would be:
http.ListenAndServe(":80", h.Handler(m))
*/
package filebrowser

17
errors/errors.go Normal file
View File

@@ -0,0 +1,17 @@
package errors
import "errors"
var (
ErrEmptyKey = errors.New("empty key")
ErrExist = errors.New("the resource already exists")
ErrNotExist = errors.New("the resource does not exist")
ErrEmptyPassword = errors.New("password is empty")
ErrEmptyUsername = errors.New("username is empty")
ErrEmptyRequest = errors.New("empty request")
ErrScopeIsRelative = errors.New("scope is a relative path")
ErrInvalidDataType = errors.New("invalid data type")
ErrIsDirectory = errors.New("file is directory")
ErrInvalidOption = errors.New("invalid option")
ErrInvalidAuthMethod = errors.New("invalid auth method")
)

487
file.go
View File

@@ -1,487 +0,0 @@
package filebrowser
import (
"bytes"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"hash"
"io"
"io/ioutil"
"mime"
"net/http"
"net/url"
"os"
"path/filepath"
"sort"
"strings"
"time"
"github.com/gohugoio/hugo/parser"
)
// File contains the information about a particular file or directory.
type File struct {
// Indicates the Kind of view on the front-end (Listing, editor or preview).
Kind string `json:"kind"`
// The name of the file.
Name string `json:"name"`
// The Size of the file.
Size int64 `json:"size"`
// The absolute URL.
URL string `json:"url"`
// The extension of the file.
Extension string `json:"extension"`
// The last modified time.
ModTime time.Time `json:"modified"`
// The File Mode.
Mode os.FileMode `json:"mode"`
// Indicates if this file is a directory.
IsDir bool `json:"isDir"`
// Absolute path.
Path string `json:"path"`
// Relative path to user's virtual File System.
VirtualPath string `json:"virtualPath"`
// Indicates the file content type: video, text, image, music or blob.
Type string `json:"type"`
// Stores the content of a text file.
Content string `json:"content,omitempty"`
*Listing `json:",omitempty"`
Metadata string `json:"metadata,omitempty"`
Language string `json:"language,omitempty"`
}
// A Listing is the context used to fill out a template.
type Listing struct {
// The items (files and folders) in the path.
Items []*File `json:"items"`
// The number of directories in the Listing.
NumDirs int `json:"numDirs"`
// The number of files (items that aren't directories) in the Listing.
NumFiles int `json:"numFiles"`
// Which sorting order is used.
Sort string `json:"sort"`
// And which order.
Order string `json:"order"`
}
// GetInfo gets the file information and, in case of error, returns the
// respective HTTP error code
func GetInfo(url *url.URL, c *FileBrowser, u *User) (*File, error) {
var err error
i := &File{
URL: "/files" + url.String(),
VirtualPath: url.Path,
Path: filepath.Join(u.Scope, url.Path),
}
info, err := u.FileSystem.Stat(url.Path)
if err != nil {
return i, err
}
i.Name = info.Name()
i.ModTime = info.ModTime()
i.Mode = info.Mode()
i.IsDir = info.IsDir()
i.Size = info.Size()
i.Extension = filepath.Ext(i.Name)
if i.IsDir && !strings.HasSuffix(i.URL, "/") {
i.URL += "/"
}
return i, nil
}
// GetListing gets the information about a specific directory and its files.
func (i *File) GetListing(u *User, r *http.Request) error {
// Gets the directory information using the Virtual File System of
// the user configuration.
f, err := u.FileSystem.OpenFile(i.VirtualPath, os.O_RDONLY, 0)
if err != nil {
return err
}
defer f.Close()
// Reads the directory and gets the information about the files.
files, err := f.Readdir(-1)
if err != nil {
return err
}
var (
fileinfos []*File
dirCount, fileCount int
)
baseurl, err := url.PathUnescape(i.URL)
if err != nil {
return err
}
for _, f := range files {
name := f.Name()
allowed := u.Allowed("/" + name)
if !allowed {
continue
}
if strings.HasPrefix(f.Mode().String(), "L") {
// It's a symbolic link
// The FileInfo from Readdir treats symbolic link as a file only.
info, err := os.Stat(f.Name())
if err != nil {
return err
}
f = info
}
if f.IsDir() {
name += "/"
dirCount++
} else {
fileCount++
}
// Absolute URL
url := url.URL{Path: baseurl + name}
i := &File{
Name: f.Name(),
Size: f.Size(),
ModTime: f.ModTime(),
Mode: f.Mode(),
IsDir: f.IsDir(),
URL: url.String(),
Extension: filepath.Ext(name),
VirtualPath: filepath.Join(i.VirtualPath, name),
Path: filepath.Join(i.Path, name),
}
i.GetFileType(false)
fileinfos = append(fileinfos, i)
}
i.Listing = &Listing{
Items: fileinfos,
NumDirs: dirCount,
NumFiles: fileCount,
}
return nil
}
// GetEditor gets the editor based on a Info struct
func (i *File) GetEditor() error {
i.Language = editorLanguage(i.Extension)
// If the editor will hold only content, leave now.
if editorMode(i.Language) == "content" {
return nil
}
// If the file doesn't have any kind of metadata, leave now.
if !hasRune(i.Content) {
return nil
}
buffer := bytes.NewBuffer([]byte(i.Content))
page, err := parser.ReadFrom(buffer)
// If there is an error, just ignore it and return nil.
// This way, the file can be served for editing.
if err != nil {
return nil
}
i.Content = strings.TrimSpace(string(page.Content()))
i.Metadata = strings.TrimSpace(string(page.FrontMatter()))
return nil
}
// GetFileType obtains the mimetype and converts it to a simple
// type nomenclature.
func (i *File) GetFileType(checkContent bool) error {
var content []byte
var err error
// Tries to get the file mimetype using its extension.
mimetype := mime.TypeByExtension(i.Extension)
if mimetype == "" && checkContent {
file, err := os.Open(i.Path)
if err != nil {
return err
}
defer file.Close()
// Only the first 512 bytes are used to sniff the content type.
buffer := make([]byte, 512)
_, err = file.Read(buffer)
if err != nil && err != io.EOF {
return err
}
// Tries to get the file mimetype using its first
// 512 bytes.
mimetype = http.DetectContentType(buffer)
}
if strings.HasPrefix(mimetype, "video") {
i.Type = "video"
return nil
}
if strings.HasPrefix(mimetype, "audio") {
i.Type = "audio"
return nil
}
if strings.HasPrefix(mimetype, "image") {
i.Type = "image"
return nil
}
if strings.HasPrefix(mimetype, "text") {
i.Type = "text"
goto End
}
if strings.HasPrefix(mimetype, "application/javascript") {
i.Type = "text"
goto End
}
// If the type isn't text (and is blob for example), it will check some
// common types that are mistaken not to be text.
if isInTextExtensions(i.Name) {
i.Type = "text"
} else {
i.Type = "blob"
}
End:
// If the file type is text, save its content.
if i.Type == "text" {
if len(content) == 0 {
content, err = ioutil.ReadFile(i.Path)
if err != nil {
return err
}
}
i.Content = string(content)
}
return nil
}
// Checksum retrieves the checksum of a file.
func (i File) Checksum(algo string) (string, error) {
file, err := os.Open(i.Path)
if err != nil {
return "", err
}
defer file.Close()
var h hash.Hash
switch algo {
case "md5":
h = md5.New()
case "sha1":
h = sha1.New()
case "sha256":
h = sha256.New()
case "sha512":
h = sha512.New()
default:
return "", ErrInvalidOption
}
_, err = io.Copy(h, file)
if err != nil {
return "", err
}
return hex.EncodeToString(h.Sum(nil)), nil
}
// CanBeEdited checks if the extension of a file is supported by the editor
func (i File) CanBeEdited() bool {
return i.Type == "text"
}
// ApplySort applies the sort order using .Order and .Sort
func (l Listing) ApplySort() {
// Check '.Order' to know how to sort
if l.Order == "desc" {
switch l.Sort {
case "name":
sort.Sort(sort.Reverse(byName(l)))
case "size":
sort.Sort(sort.Reverse(bySize(l)))
case "modified":
sort.Sort(sort.Reverse(byModified(l)))
default:
// If not one of the above, do nothing
return
}
} else { // If we had more Orderings we could add them here
switch l.Sort {
case "name":
sort.Sort(byName(l))
case "size":
sort.Sort(bySize(l))
case "modified":
sort.Sort(byModified(l))
default:
sort.Sort(byName(l))
return
}
}
}
// Implement sorting for Listing
type byName Listing
type bySize Listing
type byModified Listing
// By Name
func (l byName) Len() int {
return len(l.Items)
}
func (l byName) Swap(i, j int) {
l.Items[i], l.Items[j] = l.Items[j], l.Items[i]
}
// Treat upper and lower case equally
func (l byName) Less(i, j int) bool {
if l.Items[i].IsDir && !l.Items[j].IsDir {
return true
}
if !l.Items[i].IsDir && l.Items[j].IsDir {
return false
}
return strings.ToLower(l.Items[i].Name) < strings.ToLower(l.Items[j].Name)
}
// By Size
func (l bySize) Len() int {
return len(l.Items)
}
func (l bySize) Swap(i, j int) {
l.Items[i], l.Items[j] = l.Items[j], l.Items[i]
}
const directoryOffset = -1 << 31 // = math.MinInt32
func (l bySize) Less(i, j int) bool {
iSize, jSize := l.Items[i].Size, l.Items[j].Size
if l.Items[i].IsDir {
iSize = directoryOffset + iSize
}
if l.Items[j].IsDir {
jSize = directoryOffset + jSize
}
return iSize < jSize
}
// By Modified
func (l byModified) Len() int {
return len(l.Items)
}
func (l byModified) Swap(i, j int) {
l.Items[i], l.Items[j] = l.Items[j], l.Items[i]
}
func (l byModified) Less(i, j int) bool {
iModified, jModified := l.Items[i].ModTime, l.Items[j].ModTime
return iModified.Sub(jModified) < 0
}
// textExtensions is the sorted list of text extensions which
// can be edited.
var textExtensions = []string{
".ad", ".ada", ".adoc", ".asciidoc",
".bas", ".bash", ".bat",
".c", ".cc", ".cmd", ".conf", ".cpp", ".cr", ".cs", ".css", ".csv",
".d",
".f", ".f90",
".h", ".hh", ".hpp", ".htaccess", ".html",
".ini",
".java", ".js", ".json",
".markdown", ".md", ".mdown", ".mmark",
".nim",
".php", ".pl", ".ps1", ".py",
".rss", ".rst", ".rtf",
".sass", ".scss", ".sh", ".sty",
".tex", ".tml", ".toml", ".txt",
".vala", ".vapi",
".xml",
".yaml", ".yml",
"Caddyfile",
}
// isInTextExtensions checks if a file can be edited by its extensions.
func isInTextExtensions(name string) bool {
search := filepath.Ext(name)
if search == "" {
search = name
}
i := sort.SearchStrings(textExtensions, search)
return i < len(textExtensions) && textExtensions[i] == search
}
// hasRune checks if the file has the frontmatter rune
func hasRune(file string) bool {
return strings.HasPrefix(file, "---") ||
strings.HasPrefix(file, "+++") ||
strings.HasPrefix(file, "{")
}
func editorMode(language string) string {
switch language {
case "markdown", "asciidoc", "rst":
return "content+metadata"
}
return "content"
}
func editorLanguage(mode string) string {
mode = strings.TrimPrefix(mode, ".")
switch mode {
case "md", "markdown", "mdown", "mmark":
mode = "markdown"
case "yml":
mode = "yaml"
case "asciidoc", "adoc", "ad":
mode = "asciidoc"
case "rst":
mode = "rst"
case "html", "htm", "xml":
mode = "htmlmixed"
case "js":
mode = "javascript"
case "go":
mode = "golang"
case "":
mode = "text"
}
return mode
}

View File

@@ -1,557 +0,0 @@
package filebrowser
import (
"crypto/rand"
"errors"
"fmt"
"log"
"net/http"
"os"
"os/exec"
"reflect"
"regexp"
"strings"
"time"
"golang.org/x/crypto/bcrypt"
"github.com/GeertJohan/go.rice"
"github.com/hacdias/fileutils"
"github.com/mholt/caddy"
"github.com/robfig/cron"
)
const (
// Version is the current File Manager version.
Version = "1.5.1"
ListViewMode = "list"
MosaicViewMode = "mosaic"
)
var (
ErrExist = errors.New("the resource already exists")
ErrNotExist = errors.New("the resource does not exist")
ErrEmptyRequest = errors.New("request body is empty")
ErrEmptyPassword = errors.New("password is empty")
ErrEmptyUsername = errors.New("username is empty")
ErrEmptyScope = errors.New("scope is empty")
ErrWrongDataType = errors.New("wrong data type")
ErrInvalidUpdateField = errors.New("invalid field to update")
ErrInvalidOption = errors.New("invalid option")
)
// FileBrowser is a file manager instance. It should be creating using the
// 'New' function and not directly.
type FileBrowser struct {
// Cron job to manage schedulings.
Cron *cron.Cron
// The key used to sign the JWT tokens.
Key []byte
// The static assets.
Assets *rice.Box
// The Store is used to manage users, shareable links and
// other stuff that is saved on the database.
Store *Store
// 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
// such as in caddy-filemanager plugin. It is only useful in certain situations.
PrefixURL string
// BaseURL is the path where the GUI will be accessible. It musn't end with
// a trailing slash and mustn't contain PrefixURL, if set. It shouldn't be
// edited directly. Use SetBaseURL.
BaseURL string
// NoAuth disables the authentication. When the authentication is disabled,
// there will only exist one user, called "admin".
NoAuth bool
// ReCaptcha Site key and secret.
ReCaptchaKey string
ReCaptchaSecret string
// StaticGen is the static websit generator handler.
StaticGen StaticGen
// The Default User needed to build the New User page.
DefaultUser *User
// A map of events to a slice of commands.
Commands map[string][]string
// Global stylesheet.
CSS string
// NewFS should build a new file system for a given path.
NewFS FSBuilder
}
var commandEvents = []string{
"before_save",
"after_save",
"before_publish",
"after_publish",
"before_copy",
"after_copy",
"before_rename",
"after_rename",
"before_upload",
"after_upload",
"before_delete",
"after_delete",
}
// Command is a command function.
type Command func(r *http.Request, m *FileBrowser, u *User) error
// FSBuilder is the File System Builder.
type FSBuilder func(scope string) FileSystem
// Setup loads the configuration from the database and configures
// the Assets and the Cron job. It must always be run after
// creating a File Manager object.
func (m *FileBrowser) Setup() error {
// Creates a new File Manager instance with the Users
// map and Assets box.
m.Assets = rice.MustFindBox("./node_modules/filebrowser-frontend/dist")
m.Cron = cron.New()
// Tries to get the encryption key from the database.
// If it doesn't exist, create a new one of 256 bits.
err := m.Store.Config.Get("key", &m.Key)
if err != nil && err == ErrNotExist {
var bytes []byte
bytes, err = GenerateRandomBytes(64)
if err != nil {
return err
}
m.Key = bytes
err = m.Store.Config.Save("key", m.Key)
}
if err != nil {
return err
}
// Get the global CSS.
err = m.Store.Config.Get("css", &m.CSS)
if err != nil && err == ErrNotExist {
err = m.Store.Config.Save("css", "")
}
if err != nil {
return err
}
// Tries to get the event commands from the database.
// If they don't exist, initialize them.
err = m.Store.Config.Get("commands", &m.Commands)
if err == nil {
// Add hypothetically new command handlers.
for _, command := range commandEvents {
if _, ok := m.Commands[command]; ok {
continue
}
m.Commands[command] = []string{}
}
}
if err != nil && err == ErrNotExist {
m.Commands = map[string][]string{}
// Initialize the command handlers.
for _, command := range commandEvents {
m.Commands[command] = []string{}
}
err = m.Store.Config.Save("commands", m.Commands)
}
if err != nil {
return err
}
// Tries to fetch the users from the database.
users, err := m.Store.Users.Gets(m.NewFS)
if err != nil && err != ErrNotExist {
return err
}
// If there are no users in the database, it creates a new one
// based on 'base' User that must be provided by the function caller.
if len(users) == 0 {
u := *m.DefaultUser
u.Username = "admin"
// Hashes the password.
u.Password, err = HashPassword("admin")
if err != nil {
return err
}
// The first user must be an administrator.
u.Admin = true
u.AllowCommands = true
u.AllowNew = true
u.AllowEdit = true
u.AllowPublish = true
// Saves the user to the database.
if err := m.Store.Users.Save(&u); err != nil {
return err
}
}
m.DefaultUser.Username = ""
m.DefaultUser.Password = ""
m.Cron.AddFunc("@hourly", m.ShareCleaner)
m.Cron.Start()
return nil
}
// RootURL returns the actual URL where
// File Manager interface can be accessed.
func (m FileBrowser) RootURL() string {
return m.PrefixURL + m.BaseURL
}
// SetPrefixURL updates the prefixURL of a File
// Manager object.
func (m *FileBrowser) SetPrefixURL(url string) {
url = strings.TrimPrefix(url, "/")
url = strings.TrimSuffix(url, "/")
url = "/" + url
m.PrefixURL = strings.TrimSuffix(url, "/")
}
// SetBaseURL updates the baseURL of a File Manager
// object.
func (m *FileBrowser) SetBaseURL(url string) {
url = strings.TrimPrefix(url, "/")
url = strings.TrimSuffix(url, "/")
url = "/" + url
m.BaseURL = strings.TrimSuffix(url, "/")
}
// Attach attaches a static generator to the current File Manager.
func (m *FileBrowser) Attach(s StaticGen) error {
if reflect.TypeOf(s).Kind() != reflect.Ptr {
return errors.New("data should be a pointer to interface, not interface")
}
err := s.Setup()
if err != nil {
return err
}
m.StaticGen = s
err = m.Store.Config.Get("staticgen_"+s.Name(), s)
if err == ErrNotExist {
return m.Store.Config.Save("staticgen_"+s.Name(), s)
}
return err
}
// ShareCleaner removes sharing links that are no longer active.
// This function is set to run periodically.
func (m FileBrowser) ShareCleaner() {
// Get all links.
links, err := m.Store.Share.Gets()
if err != nil {
log.Print(err)
return
}
// Find the expired ones.
for i := range links {
if links[i].Expires && links[i].ExpireDate.Before(time.Now()) {
err = m.Store.Share.Delete(links[i].Hash)
if err != nil {
log.Print(err)
}
}
}
}
// Runner runs the commands for a certain event type.
func (m FileBrowser) Runner(event string, path string, destination string, user *User) error {
commands := []string{}
// Get the commands from the File Manager instance itself.
if val, ok := m.Commands[event]; ok {
commands = append(commands, val...)
}
// Execute the commands.
for _, command := range commands {
args := strings.Split(command, " ")
nonblock := false
if len(args) > 1 && args[len(args)-1] == "&" {
// Run command in background; non-blocking
nonblock = true
args = args[:len(args)-1]
}
command, args, err := caddy.SplitCommandAndArgs(strings.Join(args, " "))
if err != nil {
return err
}
cmd := exec.Command(command, args...)
cmd.Env = append(os.Environ(), fmt.Sprintf("FILE=%s", path))
cmd.Env = append(cmd.Env, fmt.Sprintf("ROOT=%s", user.Scope))
cmd.Env = append(cmd.Env, fmt.Sprintf("TRIGGER=%s", event))
cmd.Env = append(cmd.Env, fmt.Sprintf("USERNAME=%s", user.Username))
if destination != "" {
cmd.Env = append(cmd.Env, fmt.Sprintf("DESTINATION=%s", destination))
}
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if nonblock {
log.Printf("[INFO] Nonblocking Command:\"%s %s\"", command, strings.Join(args, " "))
if err := cmd.Start(); err != nil {
return err
}
continue
}
log.Printf("[INFO] Blocking Command:\"%s %s\"", command, strings.Join(args, " "))
if err := cmd.Run(); err != nil {
return err
}
}
return nil
}
// DefaultUser is used on New, when no 'base' user is provided.
var DefaultUser = User{
AllowCommands: true,
AllowEdit: true,
AllowNew: true,
AllowPublish: true,
LockPassword: false,
Commands: []string{},
Rules: []*Rule{},
CSS: "",
Admin: true,
Locale: "",
Scope: ".",
FileSystem: fileutils.Dir("."),
ViewMode: "mosaic",
}
// User contains the configuration for each user.
type User struct {
// ID is the required primary key with auto increment0
ID int `storm:"id,increment"`
// Tells if this user is an admin.
Admin bool `json:"admin"`
// These indicate if the user can perform certain actions.
AllowCommands bool `json:"allowCommands"` // Execute commands
AllowEdit bool `json:"allowEdit"` // Edit/rename files
AllowNew bool `json:"allowNew"` // Create files and folders
AllowPublish bool `json:"allowPublish"` // Publish content (to use with static gen)
// Prevents the user to change its password.
LockPassword bool `json:"lockPassword"`
// Commands is the list of commands the user can execute.
Commands []string `json:"commands"`
// Custom styles for this user.
CSS string `json:"css"`
// FileSystem is the virtual file system the user has access.
FileSystem FileSystem `json:"-"`
// Locale is the language of the user.
Locale string `json:"locale"`
// The hashed password. This never reaches the front-end because it's temporarily
// emptied during JSON marshall.
Password string `json:"password"`
// Rules is an array of access and deny rules.
Rules []*Rule `json:"rules"`
// Scope is the path the user has access to.
Scope string `json:"filesystem"`
// Username is the user username used to login.
Username string `json:"username" storm:"index,unique"`
// User view mode for files and folders.
ViewMode string `json:"viewMode"`
}
// Allowed checks if the user has permission to access a directory/file.
func (u User) Allowed(url string) bool {
var rule *Rule
i := len(u.Rules) - 1
for i >= 0 {
rule = u.Rules[i]
if rule.Regex {
if rule.Regexp.MatchString(url) {
return rule.Allow
}
} else if strings.HasPrefix(url, rule.Path) {
return rule.Allow
}
i--
}
return true
}
// Rule is a dissalow/allow rule.
type Rule struct {
// Regex indicates if this rule uses Regular Expressions or not.
Regex bool `json:"regex"`
// Allow indicates if this is an allow rule. Set 'false' to be a disallow rule.
Allow bool `json:"allow"`
// Path is the corresponding URL path for this rule.
Path string `json:"path"`
// Regexp is the regular expression. Only use this when 'Regex' was set to true.
Regexp *Regexp `json:"regexp"`
}
// Regexp is a regular expression wrapper around native regexp.
type Regexp struct {
Raw string `json:"raw"`
regexp *regexp.Regexp
}
// MatchString checks if this string matches the regular expression.
func (r *Regexp) MatchString(s string) bool {
if r.regexp == nil {
r.regexp = regexp.MustCompile(r.Raw)
}
return r.regexp.MatchString(s)
}
// ShareLink is the information needed to build a shareable link.
type ShareLink struct {
Hash string `json:"hash" storm:"id,index"`
Path string `json:"path" storm:"index"`
Expires bool `json:"expires"`
ExpireDate time.Time `json:"expireDate"`
}
// Store is a collection of the stores needed to get
// and save information.
type Store struct {
Users UsersStore
Config ConfigStore
Share ShareStore
}
// UsersStore is the interface to manage users.
type UsersStore interface {
Get(id int, builder FSBuilder) (*User, error)
GetByUsername(username string, builder FSBuilder) (*User, error)
Gets(builder FSBuilder) ([]*User, error)
Save(u *User) error
Update(u *User, fields ...string) error
Delete(id int) error
}
// ConfigStore is the interface to manage configuration.
type ConfigStore interface {
Get(name string, to interface{}) error
Save(name string, from interface{}) error
}
// ShareStore is the interface to manage share links.
type ShareStore interface {
Get(hash string) (*ShareLink, error)
GetPermanent(path string) (*ShareLink, error)
GetByPath(path string) ([]*ShareLink, error)
Gets() ([]*ShareLink, error)
Save(s *ShareLink) error
Delete(hash string) error
}
// StaticGen is a static website generator.
type StaticGen interface {
SettingsPath() string
Name() string
Setup() error
Hook(c *Context, w http.ResponseWriter, r *http.Request) (int, error)
Preview(c *Context, w http.ResponseWriter, r *http.Request) (int, error)
Publish(c *Context, w http.ResponseWriter, r *http.Request) (int, error)
}
// FileSystem is the interface to work with the file system.
type FileSystem interface {
Mkdir(name string, perm os.FileMode) error
OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
RemoveAll(name string) error
Rename(oldName, newName string) error
Stat(name string) (os.FileInfo, error)
Copy(src, dst string) error
}
// Context contains the needed information to make handlers work.
type Context struct {
*FileBrowser
User *User
File *File
// On API handlers, Router is the APi handler we want.
Router string
}
// HashPassword generates an hash from a password using bcrypt.
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(bytes), err
}
// CheckPasswordHash compares a password with an hash to check if they match.
func CheckPasswordHash(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}
// GenerateRandomBytes returns securely generated random bytes.
// It will return an fm.Error if the system's secure random
// number generator fails to function correctly, in which
// case the caller should not continue.
func GenerateRandomBytes(n int) ([]byte, error) {
b := make([]byte, n)
_, err := rand.Read(b)
// Note that err == nil only if we read len(b) bytes.
if err != nil {
return nil, err
}
return b, nil
}

264
files/file.go Normal file
View File

@@ -0,0 +1,264 @@
package files
import (
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"hash"
"io"
"log"
"mime"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"time"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/rules"
"github.com/spf13/afero"
)
// FileInfo describes a file.
type FileInfo struct {
*Listing
Fs afero.Fs `json:"-"`
Path string `json:"path"`
Name string `json:"name"`
Size int64 `json:"size"`
Extension string `json:"extension"`
ModTime time.Time `json:"modified"`
Mode os.FileMode `json:"mode"`
IsDir bool `json:"isDir"`
Type string `json:"type"`
Subtitles []string `json:"subtitles,omitempty"`
Content string `json:"content,omitempty"`
Checksums map[string]string `json:"checksums,omitempty"`
}
// FileOptions are the options when getting a file info.
type FileOptions struct {
Fs afero.Fs
Path string
Modify bool
Expand bool
Checker rules.Checker
}
// NewFileInfo creates a File object from a path and a given user. This File
// object will be automatically filled depending on if it is a directory
// or a file. If it's a video file, it will also detect any subtitles.
func NewFileInfo(opts FileOptions) (*FileInfo, error) {
if !opts.Checker.Check(opts.Path) {
return nil, os.ErrPermission
}
info, err := opts.Fs.Stat(opts.Path)
if err != nil {
return nil, err
}
file := &FileInfo{
Fs: opts.Fs,
Path: opts.Path,
Name: info.Name(),
ModTime: info.ModTime(),
Mode: info.Mode(),
IsDir: info.IsDir(),
Size: info.Size(),
Extension: filepath.Ext(info.Name()),
}
if opts.Expand {
if file.IsDir {
return file, file.readListing(opts.Checker)
}
err = file.detectType(opts.Modify, true)
if err != nil {
return nil, err
}
}
return file, err
}
// Checksum checksums a given File for a given User, using a specific
// algorithm. The checksums data is saved on File object.
func (i *FileInfo) Checksum(algo string) error {
if i.IsDir {
return errors.ErrIsDirectory
}
if i.Checksums == nil {
i.Checksums = map[string]string{}
}
reader, err := i.Fs.Open(i.Path)
if err != nil {
return err
}
defer reader.Close()
var h hash.Hash
switch algo {
case "md5":
h = md5.New()
case "sha1":
h = sha1.New()
case "sha256":
h = sha256.New()
case "sha512":
h = sha512.New()
default:
return errors.ErrInvalidOption
}
_, err = io.Copy(h, reader)
if err != nil {
return err
}
i.Checksums[algo] = hex.EncodeToString(h.Sum(nil))
return nil
}
func (i *FileInfo) detectType(modify, saveContent bool) error {
// failing to detect the type should not return error.
// imagine the situation where a file in a dir with thousands
// of files couldn't be opened: we'd have immediately
// a 500 even though it doesn't matter. So we just log it.
reader, err := i.Fs.Open(i.Path)
if err != nil {
log.Print(err)
i.Type = "blob"
return nil
}
defer reader.Close()
buffer := make([]byte, 512)
n, err := reader.Read(buffer)
if err != nil && err != io.EOF {
log.Print(err)
i.Type = "blob"
return nil
}
mimetype := mime.TypeByExtension(i.Extension)
if mimetype == "" {
mimetype = http.DetectContentType(buffer[:n])
}
switch {
case strings.HasPrefix(mimetype, "video"):
i.Type = "video"
i.detectSubtitles()
return nil
case strings.HasPrefix(mimetype, "audio"):
i.Type = "audio"
return nil
case strings.HasPrefix(mimetype, "image"):
i.Type = "image"
return nil
case isBinary(buffer[:n], n) || i.Size > 10*1024*1024: // 10 MB
i.Type = "blob"
return nil
default:
i.Type = "text"
if !modify {
i.Type = "textImmutable"
}
if saveContent {
afs := &afero.Afero{Fs: i.Fs}
content, err := afs.ReadFile(i.Path)
if err != nil {
return err
}
i.Content = string(content)
}
}
return nil
}
func (i *FileInfo) detectSubtitles() {
if i.Type != "video" {
return
}
i.Subtitles = []string{}
ext := filepath.Ext(i.Path)
// TODO: detect multiple languages. Base.Lang.vtt
path := strings.TrimSuffix(i.Path, ext) + ".vtt"
if _, err := i.Fs.Stat(path); err == nil {
i.Subtitles = append(i.Subtitles, path)
}
}
func (i *FileInfo) readListing(checker rules.Checker) error {
afs := &afero.Afero{Fs: i.Fs}
dir, err := afs.ReadDir(i.Path)
if err != nil {
return err
}
listing := &Listing{
Items: []*FileInfo{},
NumDirs: 0,
NumFiles: 0,
}
for _, f := range dir {
name := f.Name()
path := path.Join(i.Path, name)
if !checker.Check(path) {
continue
}
if strings.HasPrefix(f.Mode().String(), "L") {
// It's a symbolic link. We try to follow it. If it doesn't work,
// we stay with the link information instead if the target's.
info, err := i.Fs.Stat(path)
if err == nil {
f = info
}
}
file := &FileInfo{
Fs: i.Fs,
Name: name,
Size: f.Size(),
ModTime: f.ModTime(),
Mode: f.Mode(),
IsDir: f.IsDir(),
Extension: filepath.Ext(name),
Path: path,
}
if file.IsDir {
listing.NumDirs++
} else {
listing.NumFiles++
err := file.detectType(true, false)
if err != nil {
return err
}
}
listing.Items = append(listing.Items, file)
}
i.Listing = listing
return nil
}

108
files/listing.go Normal file
View File

@@ -0,0 +1,108 @@
package files
import (
"sort"
"strings"
"github.com/maruel/natural"
)
// Listing is a collection of files.
type Listing struct {
Items []*FileInfo `json:"items"`
NumDirs int `json:"numDirs"`
NumFiles int `json:"numFiles"`
Sorting Sorting `json:"sorting"`
}
// ApplySort applies the sort order using .Order and .Sort
func (l Listing) ApplySort() {
// Check '.Order' to know how to sort
if !l.Sorting.Asc {
switch l.Sorting.By {
case "name":
sort.Sort(sort.Reverse(byName(l)))
case "size":
sort.Sort(sort.Reverse(bySize(l)))
case "modified":
sort.Sort(sort.Reverse(byModified(l)))
default:
// If not one of the above, do nothing
return
}
} else { // If we had more Orderings we could add them here
switch l.Sorting.By {
case "name":
sort.Sort(byName(l))
case "size":
sort.Sort(bySize(l))
case "modified":
sort.Sort(byModified(l))
default:
sort.Sort(byName(l))
return
}
}
}
// Implement sorting for Listing
type byName Listing
type bySize Listing
type byModified Listing
// By Name
func (l byName) Len() int {
return len(l.Items)
}
func (l byName) Swap(i, j int) {
l.Items[i], l.Items[j] = l.Items[j], l.Items[i]
}
// Treat upper and lower case equally
func (l byName) Less(i, j int) bool {
if l.Items[i].IsDir && !l.Items[j].IsDir {
return true
}
if !l.Items[i].IsDir && l.Items[j].IsDir {
return false
}
return natural.Less(strings.ToLower(l.Items[j].Name), strings.ToLower(l.Items[i].Name))
}
// By Size
func (l bySize) Len() int {
return len(l.Items)
}
func (l bySize) Swap(i, j int) {
l.Items[i], l.Items[j] = l.Items[j], l.Items[i]
}
const directoryOffset = -1 << 31 // = math.MinInt32
func (l bySize) Less(i, j int) bool {
iSize, jSize := l.Items[i].Size, l.Items[j].Size
if l.Items[i].IsDir {
iSize = directoryOffset + iSize
}
if l.Items[j].IsDir {
jSize = directoryOffset + jSize
}
return iSize < jSize
}
// By Modified
func (l byModified) Len() int {
return len(l.Items)
}
func (l byModified) Swap(i, j int) {
l.Items[i], l.Items[j] = l.Items[j], l.Items[i]
}
func (l byModified) Less(i, j int) bool {
iModified, jModified := l.Items[i].ModTime, l.Items[j].ModTime
return iModified.Sub(jModified) < 0
}

7
files/sorting.go Normal file
View File

@@ -0,0 +1,7 @@
package files
// Sorting contains a sorting order.
type Sorting struct {
By string `json:"by"`
Asc bool `json:"asc"`
}

46
files/utils.go Normal file
View File

@@ -0,0 +1,46 @@
package files
import (
"unicode/utf8"
)
func isBinary(content []byte, n int) bool {
maybeStr := string(content)
runeCnt := utf8.RuneCount(content)
runeIndex := 0
gotRuneErrCnt := 0
firstRuneErrIndex := -1
for _, b := range maybeStr {
// 8 and below are control chars (e.g. backspace, null, eof, etc)
if b <= 8 {
return true
}
// 0xFFFD(65533) is the "error" Rune or "Unicode replacement character"
// see https://golang.org/pkg/unicode/utf8/#pkg-constants
if b == 0xFFFD {
//if it is not the last (utf8.UTFMax - x) rune
if runeCnt > utf8.UTFMax && runeIndex < runeCnt-utf8.UTFMax {
return true
} else {
//else it is the last (utf8.UTFMax - x) rune
//there maybe Vxxx, VVxx, VVVx, thus, we may got max 3 0xFFFD rune (asume V is the byte we got)
//for Chinese, it can only be Vxx, VVx, we may got max 2 0xFFFD rune
gotRuneErrCnt++
//mark the first time
if firstRuneErrIndex == -1 {
firstRuneErrIndex = runeIndex
}
}
}
runeIndex++
}
//if last (utf8.UTFMax - x ) rune has the "error" Rune, but not all
if firstRuneErrIndex != -1 && gotRuneErrCnt != runeCnt-firstRuneErrIndex {
return true
}
return false
}

39
fileutils/copy.go Normal file
View File

@@ -0,0 +1,39 @@
package fileutils
import (
"os"
"path"
"github.com/spf13/afero"
)
// Copy copies a file or folder from one place to another.
func Copy(fs afero.Fs, src, dst string) error {
if src = path.Clean("/" + src); src == "" {
return os.ErrNotExist
}
if dst = path.Clean("/" + dst); dst == "" {
return os.ErrNotExist
}
if src == "/" || dst == "/" {
// Prohibit copying from or to the virtual root directory.
return os.ErrInvalid
}
if dst == src {
return os.ErrInvalid
}
info, err := fs.Stat(src)
if err != nil {
return err
}
if info.IsDir() {
return CopyDir(fs, src, dst)
}
return CopyFile(fs, src, dst)
}

62
fileutils/dir.go Normal file
View File

@@ -0,0 +1,62 @@
package fileutils
import (
"errors"
"github.com/spf13/afero"
)
// CopyDir copies a directory from source to dest and all
// of its sub-directories. It doesn't stop if it finds an error
// during the copy. Returns an error if any.
func CopyDir(fs afero.Fs, source string, dest string) error {
// Get properties of source.
srcinfo, err := fs.Stat(source)
if err != nil {
return err
}
// Create the destination directory.
err = fs.MkdirAll(dest, srcinfo.Mode())
if err != nil {
return err
}
dir, _ := fs.Open(source)
obs, err := dir.Readdir(-1)
if err != nil {
return err
}
var errs []error
for _, obj := range obs {
fsource := source + "/" + obj.Name()
fdest := dest + "/" + obj.Name()
if obj.IsDir() {
// Create sub-directories, recursively.
err = CopyDir(fs, fsource, fdest)
if err != nil {
errs = append(errs, err)
}
} else {
// Perform the file copy.
err = CopyFile(fs, fsource, fdest)
if err != nil {
errs = append(errs, err)
}
}
}
var errString string
for _, err := range errs {
errString += err.Error() + "\n"
}
if errString != "" {
return errors.New(errString)
}
return nil
}

51
fileutils/file.go Normal file
View File

@@ -0,0 +1,51 @@
package fileutils
import (
"io"
"path/filepath"
"github.com/spf13/afero"
)
// CopyFile copies a file from source to dest and returns
// an error if any.
func CopyFile(fs afero.Fs, source string, dest string) error {
// Open the source file.
src, err := fs.Open(source)
if err != nil {
return err
}
defer src.Close()
// Makes the directory needed to create the dst
// file.
err = fs.MkdirAll(filepath.Dir(dest), 0666)
if err != nil {
return err
}
// Create the destination file.
dst, err := fs.Create(dest)
if err != nil {
return err
}
defer dst.Close()
// Copy the contents of the file.
_, err = io.Copy(dst, src)
if err != nil {
return err
}
// Copy the mode if the user can't
// open the file.
info, err := fs.Stat(source)
if err != nil {
err = fs.Chmod(dest, info.Mode())
if err != nil {
return err
}
}
return nil
}

1
frontend Submodule

Submodule frontend added at d45d7f92fb

42
go.mod Normal file
View File

@@ -0,0 +1,42 @@
module github.com/filebrowser/filebrowser/v2
require (
github.com/DataDog/zstd v1.4.0 // indirect
github.com/GeertJohan/go.rice v1.0.0
github.com/Sereal/Sereal v0.0.0-20190430203904-6faf9605eb56 // indirect
github.com/asdine/storm v2.1.2+incompatible
github.com/daaku/go.zipexe v1.0.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/dsnet/compress v0.0.1 // indirect
github.com/golang/protobuf v1.3.1 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/gorilla/mux v1.7.1
github.com/gorilla/websocket v1.4.0
github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1
github.com/mholt/archiver v3.1.1+incompatible
github.com/mholt/caddy v1.0.0
github.com/mitchellh/go-homedir v1.1.0
github.com/nwaples/rardecode v1.0.0 // indirect
github.com/pelletier/go-toml v1.4.0
github.com/pierrec/lz4 v0.0.0-20190131084431-473cd7ce01a1 // indirect
github.com/spf13/afero v1.2.2
github.com/spf13/cobra v0.0.3
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.3
github.com/spf13/viper v1.3.2
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
go.etcd.io/bbolt v1.3.2
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/appengine v1.5.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v2 v2.2.2
)

196
go.sum Normal file
View File

@@ -0,0 +1,196 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/zstd v1.4.0 h1:vhoV+DUHnRZdKW1i5UMjAk2G4JY8wN4ayRfYDNdEhwo=
github.com/DataDog/zstd v1.4.0/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/GeertJohan/go.incremental v1.0.0 h1:7AH+pY1XUgQE4Y1HcXYaMqAI0m9yrFqo/jt0CW30vsg=
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
github.com/GeertJohan/go.rice v1.0.0 h1:KkI6O9uMaQU3VEKaj01ulavtF7o1fWT7+pk/4voiMLQ=
github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0=
github.com/Sereal/Sereal v0.0.0-20190430203904-6faf9605eb56 h1:3trCIB5GsAOIY8NxlfMztCYIhVsW9V5sZ+brsecjaiI=
github.com/Sereal/Sereal v0.0.0-20190430203904-6faf9605eb56/go.mod h1:D0JMgToj/WdxCgd30Kc1UcA9E+WdZoJqeVOuYW7iTBM=
github.com/akavel/rsrc v0.8.0 h1:zjWn7ukO9Kc5Q62DOJCcxGpXC18RawVtYAGdz2aLlfw=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/asdine/storm v2.1.2+incompatible h1:dczuIkyqwY2LrtXPz8ixMrU/OFgZp71kbKTHGrXYt/Q=
github.com/asdine/storm v2.1.2+incompatible/go.mod h1:RarYDc9hq1UPLImuiXK3BIWPJLdIygvV3PsInK0FbVQ=
github.com/bifurcation/mint v0.0.0-20180715133206-93c51c6ce115/go.mod h1:zVt7zX3K/aDCk9Tj+VM7YymsX66ERvzCJzw8rFCX2JU=
github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E=
github.com/daaku/go.zipexe v1.0.1 h1:wV4zMsDOI2SZ2m7Tdz1Ps96Zrx+TzaK15VbUaGozw0M=
github.com/daaku/go.zipexe v1.0.1/go.mod h1:5xWogtqlYnfBXkSB1o9xysukNP9GTvaNkqzUZbt3Bw8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q=
github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo=
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-acme/lego v2.5.0+incompatible/go.mod h1:yzMNe9CasVUhkquNvti5nAtPmG94USbYxYrZfTkIn0M=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.7.1 h1:Dw4jY2nghMMRsh1ol8dv1axHkDwMQK2DHerMNJsIpJU=
github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1 h1:2MkEawJQTmAr6YI7T7j7SKxdTmYJOcaJZfzeVPr56PM=
github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1/go.mod h1:lwnswzFVSy7B/k81M5rOLUU0fOBKHrDRIkPIBZd7PBo=
github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE=
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jimstudt/http-authentication v0.0.0-20140401203705-3eca13d6893a/go.mod h1:wK6yTYYcgjHE1Z1QtXACPDjcFJyBskHEdagmnq3vsP8=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/lucas-clemente/aes12 v0.0.0-20171027163421-cd47fb39b79f/go.mod h1:JpH9J1c9oX6otFSgdUHwUBUizmKlrMjxWnIAjff4m04=
github.com/lucas-clemente/quic-clients v0.1.0/go.mod h1:y5xVIEoObKqULIKivu+gD/LU90pL73bTdtQjPBvtCBk=
github.com/lucas-clemente/quic-go v0.10.2/go.mod h1:hvaRS9IHjFLMq76puFJeWNfmn+H70QZ/CXoxqw9bzao=
github.com/lucas-clemente/quic-go-certificates v0.0.0-20160823095156-d2f86524cced/go.mod h1:NCcRLrOTZbzhZvixZLlERbJtDtYsmMw8Jc4vS8Z0g58=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/marten-seemann/qtls v0.2.3 h1:0yWJ43C62LsZt08vuQJDK1uC1czUc3FJeCLPoNAI4vA=
github.com/marten-seemann/qtls v0.2.3/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk=
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1 h1:PEhRT94KBTY4E0KdCYmhvDGWjSFBxc68j2M6PMRix8U=
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1/go.mod h1:wI697HNhDFM/vBruYM3ckbszQ2+DOIeH9qdBKMdf288=
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 v1.0.0 h1:KI6RPGih2GFzWRPG8s9clKK28Ns4ZlVMKR/v7mxq6+c=
github.com/mholt/caddy v1.0.0/go.mod h1:PzUpQ3yGCTuEuy0KSxEeB4TZOi3zBZ8BR/zY0RBP414=
github.com/mholt/certmagic v0.5.0/go.mod h1:g4cOPxcjV0oFq3qwpjSA30LReKD8AoIfwAY9VvG35NY=
github.com/miekg/dns v1.1.3/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0=
github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229 h1:E2B8qYyeSgv5MXpmzZXRNp8IAQ4vjxIjhpAf5hv/tAg=
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E=
github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMBOs=
github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
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.4.0 h1:u3Z1r+oOXJIkxqw34zVhyPgjBsm6X2wn21NWs/HfSeg=
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
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/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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
go.etcd.io/bbolt v1.3.2 h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25 h1:jsG6UpNLt9iAsb0S2AGW28DveNzzgmbXR+ENoPjUeIU=
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225 h1:kNX+jCowfMYzvlSvJu5pQWEmyWFrBXJ3PBy10xKMXK8=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190328230028-74de082e2cca/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 h1:6M3SDHlHHDCx2PcQw3S4KsR170vGqDhJDOmpVd4Hjak=
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e h1:ZytStCyV048ZqDsWHiYDdoI2Vd4msMcrDECFxS+tL9c=
golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 h1:rM0ROo5vb9AdYJi1110yjWGMej9ITfKddS89P3Fkhug=
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/mcuadros/go-syslog.v2 v2.2.1/go.mod h1:l5LPIyOOyIdQquNg+oU6Z3524YwrcqEm0aKH+5zpt2U=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@@ -3,150 +3,34 @@ package http
import (
"encoding/json"
"net/http"
"net/url"
"os"
"strings"
"time"
"github.com/dgrijalva/jwt-go"
jwt "github.com/dgrijalva/jwt-go"
"github.com/dgrijalva/jwt-go/request"
fm "github.com/filebrowser/filebrowser"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/users"
)
const reCaptchaAPI = "https://www.google.com/recaptcha/api/siteverify"
type cred struct {
Password string `json:"password"`
Username string `json:"username"`
ReCaptcha string `json:"recaptcha"`
type userInfo struct {
ID uint `json:"id"`
Locale string `json:"locale"`
ViewMode users.ViewMode `json:"viewMode"`
Perm users.Permissions `json:"perm"`
Commands []string `json:"commands"`
LockPassword bool `json:"lockPassword"`
}
// reCaptcha checks the reCaptcha code.
func reCaptcha(secret string, response string) (bool, error) {
body := url.Values{}
body.Set("secret", secret)
body.Add("response", response)
client := &http.Client{}
resp, err := client.Post(reCaptchaAPI, "application/x-www-form-urlencoded", strings.NewReader(body.Encode()))
if err != nil {
return false, err
}
if resp.StatusCode != http.StatusOK {
return false, nil
}
var data struct {
Success bool `json:"success"`
}
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
return false, err
}
return data.Success, nil
}
// authHandler processes the authentication for the user.
func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// NoAuth instances shouldn't call this method.
if c.NoAuth {
return 0, nil
}
// Receive the credentials from the request and unmarshal them.
var cred cred
if r.Body == nil {
return http.StatusForbidden, nil
}
err := json.NewDecoder(r.Body).Decode(&cred)
if err != nil {
return http.StatusForbidden, nil
}
// If ReCaptcha is enabled, check the code.
if len(c.ReCaptchaSecret) > 0 {
ok, err := reCaptcha(c.ReCaptchaSecret, cred.ReCaptcha)
if err != nil {
return http.StatusForbidden, err
}
if !ok {
return http.StatusForbidden, nil
}
}
// Checks if the user exists.
u, err := c.Store.Users.GetByUsername(cred.Username, c.NewFS)
if err != nil {
return http.StatusForbidden, nil
}
// Checks if the password is correct.
if !fm.CheckPasswordHash(cred.Password, u.Password) {
return http.StatusForbidden, nil
}
c.User = u
return printToken(c, w)
}
// 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.
func renewAuthHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
ok, u := validateAuth(c, r)
if !ok {
return http.StatusForbidden, nil
}
c.User = u
return printToken(c, w)
}
// claims is the JWT claims.
type claims struct {
fm.User
type authToken struct {
User userInfo `json:"user"`
jwt.StandardClaims
}
// printToken prints the final JWT token to the user.
func printToken(c *fm.Context, w http.ResponseWriter) (int, error) {
// Creates a copy of the user and removes it password
// hash so it never arrives to the user.
u := fm.User{}
u = *c.User
u.Password = ""
// Builds the claims.
claims := claims{
u,
jwt.StandardClaims{
ExpiresAt: time.Now().Add(time.Hour * 24).Unix(),
Issuer: "File Manager",
},
}
// Creates the token and signs it.
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
signed, err := token.SignedString(c.Key)
if err != nil {
return http.StatusInternalServerError, err
}
// Writes the token.
w.Header().Set("Content-Type", "cty")
w.Write([]byte(signed))
return 0, nil
}
type extractor []string
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.
// The former prevents incompatibility with URLs that previously
@@ -155,42 +39,142 @@ func (e extractor) ExtractToken(r *http.Request) (string, error) {
return token, nil
}
cookie, err := r.Cookie("auth")
if err != nil {
auth := r.URL.Query().Get("auth")
if auth == "" {
return "", request.ErrNoTokenInRequest
}
return cookie.Value, nil
return auth, nil
}
// validateAuth is used to validate the authentication and returns the
// User if it is valid.
func validateAuth(c *fm.Context, r *http.Request) (bool, *fm.User) {
if c.NoAuth {
c.User = c.DefaultUser
return true, c.User
func withUser(fn handleFunc) handleFunc {
return func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
keyFunc := func(token *jwt.Token) (interface{}, error) {
return d.settings.Key, nil
}
var tk authToken
token, err := request.ParseFromRequestWithClaims(r, &extractor{}, &tk, keyFunc)
if err != nil || !token.Valid {
return http.StatusForbidden, nil
}
expired := !tk.VerifyExpiresAt(time.Now().Add(time.Hour).Unix(), true)
updated := d.store.Users.LastUpdate(tk.User.ID) > tk.IssuedAt
if expired || updated {
w.Header().Add("X-Renew-Token", "true")
}
d.user, err = d.store.Users.Get(d.server.Root, tk.User.ID)
if err != nil {
return http.StatusInternalServerError, err
}
return fn(w, r, d)
}
}
keyFunc := func(token *jwt.Token) (interface{}, error) {
return c.Key, nil
}
func withAdmin(fn handleFunc) handleFunc {
return withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
if !d.user.Perm.Admin {
return http.StatusForbidden, nil
}
var claims claims
token, err := request.ParseFromRequestWithClaims(r,
extractor{},
&claims,
keyFunc,
)
return fn(w, r, d)
})
}
if err != nil || !token.Valid {
return false, nil
}
u, err := c.Store.Users.Get(claims.User.ID, c.NewFS)
var loginHandler = func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
auther, err := d.store.Auth.Get(d.settings.AuthMethod)
if err != nil {
return false, nil
return http.StatusInternalServerError, err
}
c.User = u
return true, u
user, err := auther.Auth(r, d.store.Users, d.server.Root)
if err == os.ErrPermission {
return http.StatusForbidden, nil
} else if err != nil {
return http.StatusInternalServerError, err
} else {
return printToken(w, r, d, user)
}
}
type signupBody struct {
Username string `json:"username"`
Password string `json:"password"`
}
var signupHandler = func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
if !d.settings.Signup {
return http.StatusMethodNotAllowed, nil
}
if r.Body == nil {
return http.StatusBadRequest, nil
}
info := &signupBody{}
err := json.NewDecoder(r.Body).Decode(info)
if err != nil {
return http.StatusBadRequest, err
}
if info.Password == "" || info.Username == "" {
return http.StatusBadRequest, nil
}
user := &users.User{
Username: info.Username,
}
d.settings.Defaults.Apply(user)
pwd, err := users.HashPwd(info.Password)
if err != nil {
return http.StatusInternalServerError, err
}
user.Password = pwd
err = d.store.Users.Save(user)
if err == errors.ErrExist {
return http.StatusConflict, err
} else if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, nil
}
var renewHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
return printToken(w, r, d, d.user)
})
func printToken(w http.ResponseWriter, r *http.Request, d *data, user *users.User) (int, error) {
claims := &authToken{
User: userInfo{
ID: user.ID,
Locale: user.Locale,
ViewMode: user.ViewMode,
Perm: user.Perm,
LockPassword: user.LockPassword,
Commands: user.Commands,
},
StandardClaims: jwt.StandardClaims{
IssuedAt: time.Now().Unix(),
ExpiresAt: time.Now().Add(time.Hour * 2).Unix(),
Issuer: "File Browser",
},
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
signed, err := token.SignedString(d.settings.Key)
if err != nil {
return http.StatusInternalServerError, err
}
w.Header().Set("Content-Type", "cty")
w.Write([]byte(signed))
return 0, nil
}

104
http/commands.go Normal file
View File

@@ -0,0 +1,104 @@
package http
import (
"bufio"
"io"
"log"
"net/http"
"os/exec"
"strings"
"time"
"github.com/filebrowser/filebrowser/v2/runner"
"github.com/gorilla/websocket"
)
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
var (
cmdNotAllowed = []byte("Command not allowed.")
)
func wsErr(ws *websocket.Conn, r *http.Request, status int, err error) {
txt := http.StatusText(status)
if err != nil || status >= 400 {
log.Printf("%s: %v %s %v", r.URL.Path, status, r.RemoteAddr, err)
}
ws.WriteControl(websocket.CloseInternalServerErr, []byte(txt), time.Now().Add(10*time.Second))
}
var commandsHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
return http.StatusInternalServerError, err
}
defer conn.Close()
var raw string
for {
_, msg, err := conn.ReadMessage()
if err != nil {
wsErr(conn, r, http.StatusInternalServerError, err)
return 0, nil
}
raw = strings.TrimSpace(string(msg))
if raw != "" {
break
}
}
if !d.user.CanExecute(strings.Split(raw, " ")[0]) {
err := conn.WriteMessage(websocket.TextMessage, cmdNotAllowed)
if err != nil {
wsErr(conn, r, http.StatusInternalServerError, err)
}
return 0, nil
}
command, err := runner.ParseCommand(d.settings, raw)
if err != nil {
err := conn.WriteMessage(websocket.TextMessage, []byte(err.Error()))
if err != nil {
wsErr(conn, r, http.StatusInternalServerError, err)
}
return 0, nil
}
cmd := exec.Command(command[0], command[1:]...)
cmd.Dir = d.user.FullPath(r.URL.Path)
stdout, err := cmd.StdoutPipe()
if err != nil {
wsErr(conn, r, http.StatusInternalServerError, err)
return 0, nil
}
stderr, err := cmd.StderrPipe()
if err != nil {
wsErr(conn, r, http.StatusInternalServerError, err)
return 0, nil
}
if err := cmd.Start(); err != nil {
wsErr(conn, r, http.StatusInternalServerError, err)
return 0, nil
}
s := bufio.NewScanner(io.MultiReader(stdout, stderr))
for s.Scan() {
conn.WriteMessage(websocket.TextMessage, s.Bytes())
}
if err := cmd.Wait(); err != nil {
wsErr(conn, r, http.StatusInternalServerError, err)
}
return 0, nil
})

68
http/data.go Normal file
View File

@@ -0,0 +1,68 @@
package http
import (
"log"
"net/http"
"strconv"
"github.com/filebrowser/filebrowser/v2/runner"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/storage"
"github.com/filebrowser/filebrowser/v2/users"
)
type handleFunc func(w http.ResponseWriter, r *http.Request, d *data) (int, error)
type data struct {
*runner.Runner
settings *settings.Settings
server *settings.Server
store *storage.Storage
user *users.User
raw interface{}
}
// Check implements rules.Checker.
func (d *data) Check(path string) bool {
for _, rule := range d.user.Rules {
if rule.Matches(path) {
return rule.Allow
}
}
for _, rule := range d.settings.Rules {
if rule.Matches(path) {
return rule.Allow
}
}
return true
}
func handle(fn handleFunc, prefix string, storage *storage.Storage, server *settings.Server) http.Handler {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
settings, err := storage.Settings.Get()
if err != nil {
log.Fatalln("ERROR: couldn't get settings")
return
}
status, err := fn(w, r, &data{
Runner: &runner.Runner{Settings: settings},
store: storage,
settings: settings,
server: server,
})
if status != 0 {
txt := http.StatusText(status)
http.Error(w, strconv.Itoa(status)+" "+txt, status)
}
if status >= 400 || err != nil {
log.Printf("%s: %v %s %v", r.URL.Path, status, r.RemoteAddr, err)
}
})
return http.StripPrefix(prefix, handler)
}

View File

@@ -1,103 +0,0 @@
package http
import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
fm "github.com/filebrowser/filebrowser"
"github.com/hacdias/fileutils"
"github.com/mholt/archiver"
)
// downloadHandler creates an archive in one of the supported formats (zip, tar,
// tar.gz or tar.bz2) and sends it to be downloaded.
func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// If the file isn't a directory, serve it using http.ServeFile. We display it
// inline if it is requested.
if !c.File.IsDir {
return downloadFileHandler(c, w, r)
}
query := r.URL.Query().Get("format")
files := []string{}
names := strings.Split(r.URL.Query().Get("files"), ",")
// If there are files in the query, sanitize their names.
// Otherwise, just append the current path.
if len(names) != 0 {
for _, name := range names {
// Unescape the name.
name, err := url.QueryUnescape(name)
if err != nil {
return http.StatusInternalServerError, err
}
// Clean the slashes.
name = fileutils.SlashClean(name)
files = append(files, filepath.Join(c.File.Path, name))
}
} else {
files = append(files, c.File.Path)
}
var (
extension string
ar archiver.Archiver
)
switch query {
// If the format is true, just set it to "zip".
case "zip", "true", "":
extension, ar = ".zip", archiver.Zip
case "tar":
extension, ar = ".tar", archiver.Tar
case "targz":
extension, ar = ".tar.gz", archiver.TarGz
case "tarbz2":
extension, ar = ".tar.bz2", archiver.TarBz2
case "tarxz":
extension, ar = ".tar.xz", archiver.TarXZ
default:
return http.StatusNotImplemented, nil
}
// Defines the file name.
name := c.File.Name
if name == "." || name == "" {
name = "archive"
}
name += extension
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(name))
err := ar.Write(w, files)
return 0, err
}
func downloadFileHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
file, err := os.Open(c.File.Path)
defer file.Close()
if err != nil {
return http.StatusInternalServerError, err
}
stat, err := file.Stat()
if err != nil {
return http.StatusInternalServerError, err
}
if r.URL.Query().Get("inline") == "true" {
w.Header().Set("Content-Disposition", "inline")
} else {
// As per RFC6266 section 4.3
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(c.File.Name))
}
http.ServeContent(w, r, stat.Name(), stat.ModTime(), file)
return 0, nil
}

View File

@@ -1,343 +1,69 @@
package http
import (
"encoding/json"
"html/template"
"log"
"net/http"
"os"
"path/filepath"
"strings"
"time"
fm "github.com/filebrowser/filebrowser"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/storage"
"github.com/gorilla/mux"
)
// Handler returns a function compatible with http.HandleFunc.
func Handler(m *fm.FileBrowser) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
code, err := serve(&fm.Context{
FileBrowser: m,
User: nil,
File: nil,
}, w, r)
if code >= 400 {
w.WriteHeader(code)
txt := http.StatusText(code)
log.Printf("%v: %v %v\n", r.URL.Path, code, txt)
w.Write([]byte(txt + "\n"))
}
if err != nil {
log.Print(err)
}
})
type modifyRequest struct {
What string `json:"what"` // Answer to: what data type?
Which []string `json:"which"` // Answer to: which fields?
}
// serve is the main entry point of this HTML application.
func serve(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// 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!
p := strings.TrimPrefix(r.URL.Path, c.BaseURL)
func NewHandler(storage *storage.Storage, server *settings.Server) (http.Handler, error) {
server.Clean()
if len(p) >= len(r.URL.Path) && c.BaseURL != "" {
return http.StatusNotFound, nil
r := mux.NewRouter()
index, static := getStaticHandlers(storage, server)
// NOTE: This fixes the issue where it would redirect if people did not put a
// trailing slash in the end. I hate this decision since this allows some awful
// URLs https://www.gorillatoolkit.org/pkg/mux#Router.SkipClean
r = r.SkipClean(true)
monkey := func(fn handleFunc, prefix string) http.Handler {
return handle(fn, prefix, storage, server)
}
r.URL.Path = p
r.PathPrefix("/static").Handler(static)
r.NotFoundHandler = index
// Check if this request is made to the service worker. If so,
// pass it through a template to add the needed variables.
if r.URL.Path == "/sw.js" {
return renderFile(c, w, "sw.js")
}
api := r.PathPrefix("/api").Subrouter()
// Checks if this request is made to the static assets folder. If so, and
// if it is a GET request, returns with the asset. Otherwise, returns
// a status not implemented.
if matchURL(r.URL.Path, "/static") {
if r.Method != http.MethodGet {
return http.StatusNotImplemented, nil
}
api.Handle("/login", monkey(loginHandler, ""))
api.Handle("/signup", monkey(signupHandler, ""))
api.Handle("/renew", monkey(renewHandler, ""))
return staticHandler(c, w, r)
}
users := api.PathPrefix("/users").Subrouter()
users.Handle("", monkey(usersGetHandler, "")).Methods("GET")
users.Handle("", monkey(userPostHandler, "")).Methods("POST")
users.Handle("/{id:[0-9]+}", monkey(userPutHandler, "")).Methods("PUT")
users.Handle("/{id:[0-9]+}", monkey(userGetHandler, "")).Methods("GET")
users.Handle("/{id:[0-9]+}", monkey(userDeleteHandler, "")).Methods("DELETE")
// Checks if this request is made to the API and directs to the
// API handler if so.
if matchURL(r.URL.Path, "/api") {
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/api")
return apiHandler(c, w, r)
}
api.PathPrefix("/resources").Handler(monkey(resourceGetHandler, "/api/resources")).Methods("GET")
api.PathPrefix("/resources").Handler(monkey(resourceDeleteHandler, "/api/resources")).Methods("DELETE")
api.PathPrefix("/resources").Handler(monkey(resourcePostPutHandler, "/api/resources")).Methods("POST")
api.PathPrefix("/resources").Handler(monkey(resourcePostPutHandler, "/api/resources")).Methods("PUT")
api.PathPrefix("/resources").Handler(monkey(resourcePatchHandler, "/api/resources")).Methods("PATCH")
// If it is a request to the preview and a static website generator is
// active, build the preview.
if strings.HasPrefix(r.URL.Path, "/preview") && c.StaticGen != nil {
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/preview")
return c.StaticGen.Preview(c, w, r)
}
api.PathPrefix("/share").Handler(monkey(shareGetsHandler, "/api/share")).Methods("GET")
api.PathPrefix("/share").Handler(monkey(sharePostHandler, "/api/share")).Methods("POST")
api.PathPrefix("/share").Handler(monkey(shareDeleteHandler, "/api/share")).Methods("DELETE")
if strings.HasPrefix(r.URL.Path, "/share/") {
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/share/")
return sharePage(c, w, r)
}
api.Handle("/settings", monkey(settingsGetHandler, "")).Methods("GET")
api.Handle("/settings", monkey(settingsPutHandler, "")).Methods("PUT")
// Any other request should show the index.html file.
w.Header().Set("x-frame-options", "SAMEORIGIN")
w.Header().Set("x-content-type-options", "nosniff")
w.Header().Set("x-xss-protection", "1; mode=block")
api.PathPrefix("/raw").Handler(monkey(rawHandler, "/api/raw")).Methods("GET")
api.PathPrefix("/command").Handler(monkey(commandsHandler, "/api/command")).Methods("GET")
api.PathPrefix("/search").Handler(monkey(searchHandler, "/api/search")).Methods("GET")
return renderFile(c, w, "index.html")
}
// staticHandler handles the static assets path.
func staticHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
if r.URL.Path != "/static/manifest.json" {
http.FileServer(c.Assets.HTTPBox()).ServeHTTP(w, r)
return 0, nil
}
return renderFile(c, w, "static/manifest.json")
}
// apiHandler is the main entry point for the /api endpoint.
func apiHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
if r.URL.Path == "/auth/get" {
return authHandler(c, w, r)
}
if r.URL.Path == "/auth/renew" {
return renewAuthHandler(c, w, r)
}
valid, _ := validateAuth(c, r)
if !valid {
return http.StatusForbidden, nil
}
c.Router, r.URL.Path = splitURL(r.URL.Path)
if !c.User.Allowed(r.URL.Path) {
return http.StatusForbidden, nil
}
if c.StaticGen != nil {
// If we are using the 'magic url' for the settings,
// we should redirect the request for the acutual path.
if r.URL.Path == "/settings" {
r.URL.Path = c.StaticGen.SettingsPath()
}
// Executes the Static website generator hook.
code, err := c.StaticGen.Hook(c, w, r)
if code != 0 || err != nil {
return code, err
}
}
if c.Router == "checksum" || c.Router == "download" {
var err error
c.File, err = fm.GetInfo(r.URL, c.FileBrowser, c.User)
if err != nil {
return ErrorToHTTP(err, false), err
}
}
var code int
var err error
switch c.Router {
case "download":
code, err = downloadHandler(c, w, r)
case "checksum":
code, err = checksumHandler(c, w, r)
case "command":
code, err = command(c, w, r)
case "search":
code, err = search(c, w, r)
case "resource":
code, err = resourceHandler(c, w, r)
case "users":
code, err = usersHandler(c, w, r)
case "settings":
code, err = settingsHandler(c, w, r)
case "share":
code, err = shareHandler(c, w, r)
default:
code = http.StatusNotFound
}
return code, err
}
// 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) {
query := r.URL.Query().Get("algo")
val, err := c.File.Checksum(query)
if err == fm.ErrInvalidOption {
return http.StatusBadRequest, err
} else if err != nil {
return http.StatusInternalServerError, err
}
w.Write([]byte(val))
return 0, nil
}
// splitURL splits the path and returns everything that stands
// before the first slash and everything that goes after.
func splitURL(path string) (string, string) {
if path == "" {
return "", ""
}
path = strings.TrimPrefix(path, "/")
i := strings.Index(path, "/")
if i == -1 {
return "", path
}
return path[0:i], path[i:]
}
// renderFile renders a file using a template with some needed variables.
func renderFile(c *fm.Context, w http.ResponseWriter, file string) (int, error) {
tpl := template.Must(template.New("file").Parse(c.Assets.MustString(file)))
var contentType string
switch filepath.Ext(file) {
case ".html":
contentType = "text/html"
case ".js":
contentType = "application/javascript"
case ".json":
contentType = "application/json"
default:
contentType = "text"
}
w.Header().Set("Content-Type", contentType+"; charset=utf-8")
data := map[string]interface{}{
"BaseURL": c.RootURL(),
"NoAuth": c.NoAuth,
"Version": fm.Version,
"CSS": template.CSS(c.CSS),
"ReCaptcha": c.ReCaptchaKey != "" && c.ReCaptchaSecret != "",
"ReCaptchaKey": c.ReCaptchaKey,
}
if c.StaticGen != nil {
data["StaticGen"] = c.StaticGen.Name()
}
err := tpl.Execute(w, data)
if err != nil {
return http.StatusInternalServerError, err
}
return 0, nil
}
// sharePage build the share page.
func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
s, err := c.Store.Share.Get(r.URL.Path)
if err == fm.ErrNotExist {
w.WriteHeader(http.StatusNotFound)
return renderFile(c, w, "static/share/404.html")
}
if err != nil {
return http.StatusInternalServerError, err
}
if s.Expires && s.ExpireDate.Before(time.Now()) {
c.Store.Share.Delete(s.Hash)
w.WriteHeader(http.StatusNotFound)
return renderFile(c, w, "static/share/404.html")
}
r.URL.Path = s.Path
info, err := os.Stat(s.Path)
if err != nil {
c.Store.Share.Delete(s.Hash)
return ErrorToHTTP(err, false), err
}
c.File = &fm.File{
Path: s.Path,
Name: info.Name(),
ModTime: info.ModTime(),
Mode: info.Mode(),
IsDir: info.IsDir(),
Size: info.Size(),
}
dl := r.URL.Query().Get("dl")
if dl == "" || dl == "0" {
tpl := template.Must(template.New("file").Parse(c.Assets.MustString("static/share/index.html")))
w.Header().Set("Content-Type", "text/html; charset=utf-8")
err := tpl.Execute(w, map[string]interface{}{
"BaseURL": c.RootURL(),
"File": c.File,
})
if err != nil {
return http.StatusInternalServerError, err
}
return 0, nil
}
return downloadHandler(c, w, r)
}
// renderJSON prints the JSON version of data to the browser.
func renderJSON(w http.ResponseWriter, data interface{}) (int, error) {
marsh, err := json.Marshal(data)
if err != nil {
return http.StatusInternalServerError, err
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if _, err := w.Write(marsh); err != nil {
return http.StatusInternalServerError, err
}
return 0, nil
}
// matchURL checks if the first URL matches the second.
func matchURL(first, second string) bool {
first = strings.ToLower(first)
second = strings.ToLower(second)
return strings.HasPrefix(first, second)
}
// ErrorToHTTP converts errors to HTTP Status Code.
func ErrorToHTTP(err error, gone bool) int {
switch {
case err == nil:
return http.StatusOK
case os.IsPermission(err):
return http.StatusForbidden
case os.IsNotExist(err):
if !gone {
return http.StatusNotFound
}
return http.StatusGone
case os.IsExist(err):
return http.StatusConflict
default:
return http.StatusInternalServerError
}
public := api.PathPrefix("/public").Subrouter()
public.PathPrefix("/dl").Handler(monkey(publicDlHandler, "/api/public/dl/")).Methods("GET")
public.PathPrefix("/share").Handler(monkey(publicShareHandler, "/api/public/share/")).Methods("GET")
return stripPrefix(server.BaseURL, r), nil
}

60
http/public.go Normal file
View File

@@ -0,0 +1,60 @@
package http
import (
"net/http"
"strings"
"github.com/filebrowser/filebrowser/v2/files"
)
var withHashFile = func(fn handleFunc) handleFunc {
return func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
link, err := d.store.Share.GetByHash(r.URL.Path)
if err != nil {
link, err = d.store.Share.GetByHash(ifPathWithName(r))
if err != nil {
return errToStatus(err), err
}
}
user, err := d.store.Users.Get(d.server.Root, link.UserID)
if err != nil {
return errToStatus(err), err
}
d.user = user
file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: link.Path,
Modify: d.user.Perm.Modify,
Expand: false,
Checker: d,
})
if err != nil {
return errToStatus(err), err
}
d.raw = file
return fn(w, r, d)
}
}
func ifPathWithName(r *http.Request) string {
pathElements := strings.Split(r.URL.Path, "/")
id := pathElements[len(pathElements)-2]
return id
}
var publicShareHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
return renderJSON(w, r, d.raw)
})
var publicDlHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
file := d.raw.(*files.FileInfo)
if !file.IsDir {
return rawFileHandler(w, r, file)
}
return rawDirHandler(w, r, d, file)
})

177
http/raw.go Normal file
View File

@@ -0,0 +1,177 @@
package http
import (
"errors"
"net/http"
"net/url"
"path/filepath"
"strings"
"github.com/filebrowser/filebrowser/v2/files"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/hacdias/fileutils"
"github.com/mholt/archiver"
)
func parseQueryFiles(r *http.Request, f *files.FileInfo, u *users.User) ([]string, error) {
files := []string{}
names := strings.Split(r.URL.Query().Get("files"), ",")
if len(names) == 0 {
files = append(files, f.Path)
} else {
for _, name := range names {
name, err := url.QueryUnescape(strings.Replace(name, "+", "%2B", -1))
if err != nil {
return nil, err
}
name = fileutils.SlashClean(name)
files = append(files, filepath.Join(f.Path, name))
}
}
return files, nil
}
func parseQueryAlgorithm(r *http.Request) (string, archiver.Writer, error) {
switch r.URL.Query().Get("algo") {
case "zip", "true", "":
return ".zip", archiver.NewZip(), nil
case "tar":
return ".tar", archiver.NewTar(), nil
case "targz":
return ".tar.gz", archiver.NewTarGz(), nil
case "tarbz2":
return ".tar.bz2", archiver.NewTarBz2(), nil
case "tarxz":
return ".tar.xz", archiver.NewTarXz(), nil
case "tarlz4":
return ".tar.lz4", archiver.NewTarLz4(), nil
case "tarsz":
return ".tar.sz", archiver.NewTarSz(), nil
default:
return "", nil, errors.New("format not implemented")
}
}
var rawHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
if !d.user.Perm.Download {
return http.StatusAccepted, nil
}
file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: false,
Checker: d,
})
if err != nil {
return errToStatus(err), err
}
if !file.IsDir {
return rawFileHandler(w, r, file)
}
return rawDirHandler(w, r, d, file)
})
func addFile(ar archiver.Writer, d *data, path string) error {
// Checks are always done with paths with "/" as path separator.
path = strings.Replace(path, "\\", "/", -1)
if !d.Check(path) {
return nil
}
info, err := d.user.Fs.Stat(path)
if err != nil {
return err
}
file, err := d.user.Fs.Open(path)
if err != nil {
return err
}
defer file.Close()
err = ar.Write(archiver.File{
FileInfo: archiver.FileInfo{
FileInfo: info,
CustomName: strings.TrimPrefix(path, "/"),
},
ReadCloser: file,
})
if err != nil {
return err
}
if info.IsDir() {
names, err := file.Readdirnames(0)
if err != nil {
return err
}
for _, name := range names {
err = addFile(ar, d, filepath.Join(path, name))
if err != nil {
return err
}
}
}
return nil
}
func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.FileInfo) (int, error) {
filenames, err := parseQueryFiles(r, file, d.user)
if err != nil {
return http.StatusInternalServerError, err
}
extension, ar, err := parseQueryAlgorithm(r)
if err != nil {
return http.StatusInternalServerError, err
}
name := file.Name
if name == "." || name == "" {
name = "archive"
}
name += extension
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(name))
err = ar.Create(w)
if err != nil {
return http.StatusInternalServerError, err
}
defer ar.Close()
for _, fname := range filenames {
err = addFile(ar, d, fname)
if err != nil {
return http.StatusInternalServerError, err
}
}
return 0, nil
}
func rawFileHandler(w http.ResponseWriter, r *http.Request, file *files.FileInfo) (int, error) {
fd, err := file.Fs.Open(file.Path)
if err != nil {
return http.StatusInternalServerError, err
}
defer fd.Close()
if r.URL.Query().Get("inline") == "true" {
w.Header().Set("Content-Disposition", "inline")
} else {
// As per RFC6266 section 4.3
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(file.Name))
}
http.ServeContent(w, r, file.Name, file.ModTime, fd)
return 0, nil
}

View File

@@ -1,386 +1,158 @@
package http
import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
fm "github.com/filebrowser/filebrowser"
"github.com/hacdias/fileutils"
"github.com/filebrowser/filebrowser/v2/files"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/fileutils"
)
// sanitizeURL sanitizes the URL to prevent path transversal
// using fileutils.SlashClean and adds the trailing slash bar.
func sanitizeURL(url string) string {
path := fileutils.SlashClean(url)
if strings.HasSuffix(url, "/") && path != "/" {
return path + "/"
}
return path
}
func resourceHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
r.URL.Path = sanitizeURL(r.URL.Path)
switch r.Method {
case http.MethodGet:
return resourceGetHandler(c, w, r)
case http.MethodDelete:
return resourceDeleteHandler(c, w, r)
case http.MethodPut:
// Before save command handler.
path := filepath.Join(c.User.Scope, r.URL.Path)
if err := c.Runner("before_save", path, "", c.User); err != nil {
return http.StatusInternalServerError, err
}
code, err := resourcePostPutHandler(c, w, r)
if code != http.StatusOK {
return code, err
}
// After save command handler.
if err := c.Runner("after_save", path, "", c.User); err != nil {
return http.StatusInternalServerError, err
}
return code, err
case http.MethodPatch:
return resourcePatchHandler(c, w, r)
case http.MethodPost:
return resourcePostPutHandler(c, w, r)
}
return http.StatusNotImplemented, nil
}
func resourceGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// Gets the information of the directory/file.
f, err := fm.GetInfo(r.URL, c.FileBrowser, c.User)
var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs,
Path: r.URL.Path,
Modify: d.user.Perm.Modify,
Expand: true,
Checker: d,
})
if err != nil {
return ErrorToHTTP(err, false), err
return errToStatus(err), err
}
// If it's a dir and the path doesn't end with a trailing slash,
// add a trailing slash to the path.
if f.IsDir && !strings.HasSuffix(r.URL.Path, "/") {
r.URL.Path = r.URL.Path + "/"
if file.IsDir {
file.Listing.Sorting = d.user.Sorting
file.Listing.ApplySort()
return renderJSON(w, r, file)
}
// If it is a dir, go and serve the listing.
if f.IsDir {
c.File = f
return listingHandler(c, w, r)
if checksum := r.URL.Query().Get("checksum"); checksum != "" {
err := file.Checksum(checksum)
if err == errors.ErrInvalidOption {
return http.StatusBadRequest, nil
} else if err != nil {
return http.StatusInternalServerError, err
}
// do not waste bandwidth if we just want the checksum
file.Content = ""
}
// Tries to get the file type.
if err = f.GetFileType(true); err != nil {
return ErrorToHTTP(err, true), err
}
return renderJSON(w, r, file)
})
// Serve a preview if the file can't be edited or the
// user has no permission to edit this file. Otherwise,
// just serve the editor.
if !f.CanBeEdited() || !c.User.AllowEdit {
f.Kind = "preview"
return renderJSON(w, f)
}
f.Kind = "editor"
// Tries to get the editor data.
if err = f.GetEditor(); err != nil {
return http.StatusInternalServerError, err
}
return renderJSON(w, f)
}
func listingHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
f := c.File
f.Kind = "listing"
// Tries to get the listing data.
if err := f.GetListing(c.User, r); err != nil {
return ErrorToHTTP(err, true), err
}
listing := f.Listing
// Defines the cookie scope.
cookieScope := c.RootURL()
if cookieScope == "" {
cookieScope = "/"
}
// Copy the query values into the Listing struct
if sort, order, err := handleSortOrder(w, r, cookieScope); err == nil {
listing.Sort = sort
listing.Order = order
} else {
return http.StatusBadRequest, err
}
listing.ApplySort()
return renderJSON(w, f)
}
func resourceDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// Prevent the removal of the root directory.
if r.URL.Path == "/" || !c.User.AllowEdit {
var resourceDeleteHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
if r.URL.Path == "/" || !d.user.Perm.Delete {
return http.StatusForbidden, nil
}
// Fire the before trigger.
if err := c.Runner("before_delete", r.URL.Path, "", c.User); err != nil {
return http.StatusInternalServerError, err
}
err := d.RunHook(func() error {
return d.user.Fs.RemoveAll(r.URL.Path)
}, "delete", r.URL.Path, "", d.user)
// Remove the file or folder.
err := c.User.FileSystem.RemoveAll(r.URL.Path)
if err != nil {
return ErrorToHTTP(err, true), err
}
// Fire the after trigger.
if err := c.Runner("after_delete", r.URL.Path, "", c.User); err != nil {
return http.StatusInternalServerError, err
return errToStatus(err), err
}
return http.StatusOK, nil
}
})
func resourcePostPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
if !c.User.AllowNew && r.Method == http.MethodPost {
var resourcePostPutHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
if !d.user.Perm.Create && r.Method == http.MethodPost {
return http.StatusForbidden, nil
}
if !c.User.AllowEdit && r.Method == http.MethodPut {
if !d.user.Perm.Modify && r.Method == http.MethodPut {
return http.StatusForbidden, nil
}
// Discard any invalid upload before returning to avoid connection
// reset error.
defer func() {
io.Copy(ioutil.Discard, r.Body)
}()
// Checks if the current request is for a directory and not a file.
// For directories, only allow POST for creation.
if strings.HasSuffix(r.URL.Path, "/") {
// If the method is PUT, we return 405 Method not Allowed, because
// POST should be used instead.
if r.Method == http.MethodPut {
return http.StatusMethodNotAllowed, nil
}
// Otherwise we try to create the directory.
err := c.User.FileSystem.Mkdir(r.URL.Path, 0776)
return ErrorToHTTP(err, false), err
err := d.user.Fs.MkdirAll(r.URL.Path, 0775)
return errToStatus(err), err
}
// If using POST method, we are trying to create a new file so it is not
// desirable to override an already existent file. Thus, we check
// if the file already exists. If so, we just return a 409 Conflict.
if r.Method == http.MethodPost && r.Header.Get("Action") != "override" {
if _, err := c.User.FileSystem.Stat(r.URL.Path); err == nil {
return http.StatusConflict, errors.New("There is already a file on that path")
if r.Method == http.MethodPost && r.URL.Query().Get("override") != "true" {
if _, err := d.user.Fs.Stat(r.URL.Path); err == nil {
return http.StatusConflict, nil
}
}
// Fire the before trigger.
if err := c.Runner("before_upload", r.URL.Path, "", c.User); err != nil {
return http.StatusInternalServerError, err
}
// Create/Open the file.
f, err := c.User.FileSystem.OpenFile(r.URL.Path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0776)
if err != nil {
return ErrorToHTTP(err, false), err
}
defer f.Close()
// Copies the new content for the file.
_, err = io.Copy(f, r.Body)
if err != nil {
return ErrorToHTTP(err, false), err
}
// Gets the info about the file.
fi, err := f.Stat()
if err != nil {
return ErrorToHTTP(err, false), err
}
// Check if this instance has a Static Generator and handles publishing
// or scheduling if it's the case.
if c.StaticGen != nil {
code, err := resourcePublishSchedule(c, w, r)
if code != 0 {
return code, err
}
}
// Writes the ETag Header.
etag := fmt.Sprintf(`"%x%x"`, fi.ModTime().UnixNano(), fi.Size())
w.Header().Set("ETag", etag)
// Fire the after trigger.
if err := c.Runner("after_upload", r.URL.Path, "", c.User); err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, nil
}
func resourcePublishSchedule(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
publish := r.Header.Get("Publish")
schedule := r.Header.Get("Schedule")
if publish != "true" && schedule == "" {
return 0, nil
}
if !c.User.AllowPublish {
return http.StatusForbidden, nil
}
if publish == "true" {
return resourcePublish(c, w, r)
}
t, err := time.Parse("2006-01-02T15:04", schedule)
if err != nil {
return http.StatusInternalServerError, err
}
c.Cron.AddFunc(t.Format("05 04 15 02 01 *"), func() {
_, err := resourcePublish(c, w, r)
err := d.RunHook(func() error {
file, err := d.user.Fs.OpenFile(r.URL.Path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775)
if err != nil {
log.Print(err)
return err
}
})
defer file.Close()
return http.StatusOK, nil
}
_, err = io.Copy(file, r.Body)
if err != nil {
return err
}
func resourcePublish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
path := filepath.Join(c.User.Scope, r.URL.Path)
// Gets the info about the file.
info, err := file.Stat()
if err != nil {
return err
}
// Before save command handler.
if err := c.Runner("before_publish", path, "", c.User); err != nil {
return http.StatusInternalServerError, err
}
etag := fmt.Sprintf(`"%x%x"`, info.ModTime().UnixNano(), info.Size())
w.Header().Set("ETag", etag)
return nil
}, "upload", r.URL.Path, "", d.user)
code, err := c.StaticGen.Publish(c, w, r)
if err != nil {
return code, err
}
// Executed the before publish command.
if err := c.Runner("before_publish", path, "", c.User); err != nil {
return http.StatusInternalServerError, err
}
return code, nil
}
// resourcePatchHandler is the entry point for resource handler.
func resourcePatchHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
if !c.User.AllowEdit {
return http.StatusForbidden, nil
}
dst := r.Header.Get("Destination")
action := r.Header.Get("Action")
dst, err := url.QueryUnescape(dst)
if err != nil {
return ErrorToHTTP(err, true), err
}
return errToStatus(err), err
})
var resourcePatchHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
src := r.URL.Path
dst := r.URL.Query().Get("destination")
action := r.URL.Query().Get("action")
dst, err := url.QueryUnescape(dst)
if err != nil {
return errToStatus(err), err
}
if dst == "/" || src == "/" {
return http.StatusForbidden, nil
}
if action == "copy" {
// Fire the after trigger.
if err := c.Runner("before_copy", src, dst, c.User); err != nil {
return http.StatusInternalServerError, err
switch action {
case "copy":
if !d.user.Perm.Create {
return http.StatusForbidden, nil
}
// Copy the file.
err = c.User.FileSystem.Copy(src, dst)
// Fire the after trigger.
if err := c.Runner("after_copy", src, dst, c.User); err != nil {
return http.StatusInternalServerError, err
}
} else {
// Fire the after trigger.
if err := c.Runner("before_rename", src, dst, c.User); err != nil {
return http.StatusInternalServerError, err
}
// Rename the file.
err = c.User.FileSystem.Rename(src, dst)
// Fire the after trigger.
if err := c.Runner("after_rename", src, dst, c.User); err != nil {
return http.StatusInternalServerError, err
case "rename":
default:
action = "rename"
if !d.user.Perm.Rename {
return http.StatusForbidden, nil
}
}
return ErrorToHTTP(err, true), err
}
// handleSortOrder gets and stores for a Listing the 'sort' and 'order',
// and reads 'limit' if given. The latter is 0 if not given. Sets cookies.
func handleSortOrder(w http.ResponseWriter, r *http.Request, scope string) (sort string, order string, err error) {
sort = r.URL.Query().Get("sort")
order = r.URL.Query().Get("order")
// If the query 'sort' or 'order' is empty, use defaults or any values
// previously saved in Cookies.
switch sort {
case "":
sort = "name"
if sortCookie, sortErr := r.Cookie("sort"); sortErr == nil {
sort = sortCookie.Value
err = d.RunHook(func() error {
if action == "copy" {
return fileutils.Copy(d.user.Fs, src, dst)
}
case "name", "size":
http.SetCookie(w, &http.Cookie{
Name: "sort",
Value: sort,
MaxAge: 31536000,
Path: scope,
Secure: r.TLS != nil,
})
}
switch order {
case "":
order = "asc"
if orderCookie, orderErr := r.Cookie("order"); orderErr == nil {
order = orderCookie.Value
}
case "asc", "desc":
http.SetCookie(w, &http.Cookie{
Name: "order",
Value: order,
MaxAge: 31536000,
Path: scope,
Secure: r.TLS != nil,
})
}
return d.user.Fs.Rename(src, dst)
}, action, src, dst, d.user)
return
}
return errToStatus(err), err
})

28
http/search.go Normal file
View File

@@ -0,0 +1,28 @@
package http
import (
"net/http"
"os"
"github.com/filebrowser/filebrowser/v2/search"
)
var searchHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
response := []map[string]interface{}{}
query := r.URL.Query().Get("query")
err := search.Search(d.user.Fs, r.URL.Path, query, d, func(path string, f os.FileInfo) error {
response = append(response, map[string]interface{}{
"dir": f.IsDir(),
"path": path,
})
return nil
})
if err != nil {
return http.StatusInternalServerError, err
}
return renderJSON(w, r, response)
})

View File

@@ -1,146 +1,52 @@
package http
import (
"bytes"
"encoding/json"
"net/http"
"reflect"
fm "github.com/filebrowser/filebrowser"
"github.com/mitchellh/mapstructure"
"github.com/filebrowser/filebrowser/v2/rules"
"github.com/filebrowser/filebrowser/v2/settings"
)
type modifySettingsRequest struct {
*modifyRequest
Data struct {
CSS string `json:"css"`
Commands map[string][]string `json:"commands"`
StaticGen map[string]interface{} `json:"staticGen"`
} `json:"data"`
type settingsData struct {
Signup bool `json:"signup"`
CreateUserDir bool `json:"createUserDir"`
Defaults settings.UserDefaults `json:"defaults"`
Rules []rules.Rule `json:"rules"`
Branding settings.Branding `json:"branding"`
Shell []string `json:"shell"`
Commands map[string][]string `json:"commands"`
}
type option struct {
Variable string `json:"variable"`
Name string `json:"name"`
Value interface{} `json:"value"`
}
func parsePutSettingsRequest(r *http.Request) (*modifySettingsRequest, error) {
// Checks if the request body is empty.
if r.Body == nil {
return nil, fm.ErrEmptyRequest
var settingsGetHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
data := &settingsData{
Signup: d.settings.Signup,
CreateUserDir: d.settings.CreateUserDir,
Defaults: d.settings.Defaults,
Rules: d.settings.Rules,
Branding: d.settings.Branding,
Shell: d.settings.Shell,
Commands: d.settings.Commands,
}
// Parses the request body and checks if it's well formed.
mod := &modifySettingsRequest{}
err := json.NewDecoder(r.Body).Decode(mod)
if err != nil {
return nil, err
}
return renderJSON(w, r, data)
})
// Checks if the request type is right.
if mod.What != "settings" {
return nil, fm.ErrWrongDataType
}
return mod, nil
}
func settingsHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
if r.URL.Path != "" && r.URL.Path != "/" {
return http.StatusNotFound, nil
}
switch r.Method {
case http.MethodGet:
return settingsGetHandler(c, w, r)
case http.MethodPut:
return settingsPutHandler(c, w, r)
}
return http.StatusMethodNotAllowed, nil
}
type settingsGetRequest struct {
CSS string `json:"css"`
Commands map[string][]string `json:"commands"`
StaticGen []option `json:"staticGen"`
}
func settingsGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
if !c.User.Admin {
return http.StatusForbidden, nil
}
result := &settingsGetRequest{
Commands: c.Commands,
StaticGen: []option{},
CSS: c.CSS,
}
if c.StaticGen != nil {
t := reflect.TypeOf(c.StaticGen).Elem()
for i := 0; i < t.NumField(); i++ {
if t.Field(i).Name[0] == bytes.ToLower([]byte{t.Field(i).Name[0]})[0] {
continue
}
result.StaticGen = append(result.StaticGen, option{
Variable: t.Field(i).Name,
Name: t.Field(i).Tag.Get("name"),
Value: reflect.ValueOf(c.StaticGen).Elem().FieldByName(t.Field(i).Name).Interface(),
})
}
}
return renderJSON(w, result)
}
func settingsPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
if !c.User.Admin {
return http.StatusForbidden, nil
}
mod, err := parsePutSettingsRequest(r)
var settingsPutHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
req := &settingsData{}
err := json.NewDecoder(r.Body).Decode(req)
if err != nil {
return http.StatusBadRequest, err
}
// Update the commands.
if mod.Which == "commands" {
if err := c.Store.Config.Save("commands", mod.Data.Commands); err != nil {
return http.StatusInternalServerError, err
}
d.settings.Signup = req.Signup
d.settings.CreateUserDir = req.CreateUserDir
d.settings.Defaults = req.Defaults
d.settings.Rules = req.Rules
d.settings.Branding = req.Branding
d.settings.Shell = req.Shell
d.settings.Commands = req.Commands
c.Commands = mod.Data.Commands
return http.StatusOK, nil
}
// Update the global CSS.
if mod.Which == "css" {
if err := c.Store.Config.Save("css", mod.Data.CSS); err != nil {
return http.StatusInternalServerError, err
}
c.CSS = mod.Data.CSS
return http.StatusOK, nil
}
// Update the static generator options.
if mod.Which == "staticGen" {
err = mapstructure.Decode(mod.Data.StaticGen, c.StaticGen)
if err != nil {
return http.StatusInternalServerError, err
}
err = c.Store.Config.Save("staticgen_"+c.StaticGen.Name(), c.StaticGen)
if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, nil
}
return http.StatusMethodNotAllowed, nil
}
err = d.store.Settings.Save(d.settings)
return errToStatus(err), err
})

View File

@@ -1,87 +1,78 @@
package http
import (
"encoding/hex"
"crypto/rand"
"encoding/base64"
"net/http"
"path/filepath"
"strconv"
"strings"
"time"
fm "github.com/filebrowser/filebrowser"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/share"
)
func shareHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
r.URL.Path = sanitizeURL(r.URL.Path)
func withPermShare(fn handleFunc) handleFunc {
return withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
if !d.user.Perm.Share {
return http.StatusForbidden, nil
}
switch r.Method {
case http.MethodGet:
return shareGetHandler(c, w, r)
case http.MethodDelete:
return shareDeleteHandler(c, w, r)
case http.MethodPost:
return sharePostHandler(c, w, r)
}
return http.StatusNotImplemented, nil
return fn(w, r, d)
})
}
func shareGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
path := filepath.Join(c.User.Scope, r.URL.Path)
s, err := c.Store.Share.GetByPath(path)
if err == fm.ErrNotExist {
return http.StatusNotFound, nil
var shareGetsHandler = withPermShare(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
s, err := d.store.Share.Gets(r.URL.Path, d.user.ID)
if err == errors.ErrNotExist {
return renderJSON(w, r, []*share.Link{})
}
if err != nil {
return http.StatusInternalServerError, err
}
for i, link := range s {
if link.Expires && link.ExpireDate.Before(time.Now()) {
c.Store.Share.Delete(link.Hash)
s = append(s[:i], s[i+1:]...)
}
return renderJSON(w, r, s)
})
var shareDeleteHandler = withPermShare(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
hash := strings.TrimSuffix(r.URL.Path, "/")
hash = strings.TrimPrefix(hash, "/")
if hash == "" {
return http.StatusBadRequest, nil
}
if len(s) == 0 {
return http.StatusNotFound, nil
}
err := d.store.Share.Delete(hash)
return errToStatus(err), err
})
return renderJSON(w, s)
}
func sharePostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
path := filepath.Join(c.User.Scope, r.URL.Path)
var s *fm.ShareLink
expire := r.URL.Query().Get("expires")
var sharePostHandler = withPermShare(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
var s *share.Link
rawExpire := r.URL.Query().Get("expires")
unit := r.URL.Query().Get("unit")
if expire == "" {
if rawExpire == "" {
var err error
s, err = c.Store.Share.GetPermanent(path)
s, err = d.store.Share.GetPermanent(r.URL.Path, d.user.ID)
if err == nil {
w.Write([]byte(c.RootURL() + "/share/" + s.Hash))
w.Write([]byte(d.server.BaseURL + "/share/" + s.Hash))
return 0, nil
}
}
bytes, err := fm.GenerateRandomBytes(32)
bytes := make([]byte, 6)
_, err := rand.Read(bytes)
if err != nil {
return http.StatusInternalServerError, err
}
str := hex.EncodeToString(bytes)
str := base64.URLEncoding.EncodeToString(bytes)
s = &fm.ShareLink{
Path: path,
Hash: str,
Expires: expire != "",
}
var expire int64 = 0
if expire != "" {
num, err := strconv.Atoi(expire)
if rawExpire != "" {
num, err := strconv.Atoi(rawExpire)
if err != nil {
return http.StatusInternalServerError, err
}
@@ -98,30 +89,19 @@ func sharePostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
add = time.Hour * time.Duration(num)
}
s.ExpireDate = time.Now().Add(add)
expire = time.Now().Add(add).Unix()
}
if err := c.Store.Share.Save(s); err != nil {
s = &share.Link{
Path: r.URL.Path,
Hash: str,
Expire: expire,
UserID: d.user.ID,
}
if err := d.store.Share.Save(s); err != nil {
return http.StatusInternalServerError, err
}
return renderJSON(w, s)
}
func shareDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
s, err := c.Store.Share.Get(strings.TrimPrefix(r.URL.Path, "/"))
if err == fm.ErrNotExist {
return http.StatusNotFound, nil
}
if err != nil {
return http.StatusInternalServerError, err
}
err = c.Store.Share.Delete(s.Hash)
if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, nil
}
return renderJSON(w, r, s)
})

126
http/static.go Normal file
View File

@@ -0,0 +1,126 @@
package http
import (
"encoding/json"
"log"
"net/http"
"os"
"path/filepath"
"strings"
"text/template"
rice "github.com/GeertJohan/go.rice"
"github.com/filebrowser/filebrowser/v2/auth"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/storage"
"github.com/filebrowser/filebrowser/v2/version"
)
func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *data, box *rice.Box, file, contentType string) (int, error) {
w.Header().Set("Content-Type", contentType)
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{}{
"Name": d.settings.Branding.Name,
"DisableExternal": d.settings.Branding.DisableExternal,
"BaseURL": d.server.BaseURL,
"Version": version.Version,
"StaticURL": staticURL,
"Signup": d.settings.Signup,
"NoAuth": d.settings.AuthMethod == auth.MethodNoAuth,
"LoginPage": auther.LoginPage(),
"CSS": false,
"ReCaptcha": false,
}
if d.settings.Branding.Files != "" {
path := filepath.Join(d.settings.Branding.Files, "custom.css")
_, err := os.Stat(path)
if err != nil && !os.IsNotExist(err) {
log.Printf("couldn't load custom styles: %v", err)
}
if err == nil {
data["CSS"] = true
}
}
if d.settings.AuthMethod == auth.MethodJSONAuth {
raw, err := d.store.Auth.Get(d.settings.AuthMethod)
if err != nil {
return http.StatusInternalServerError, err
}
auther := raw.(*auth.JSONAuth)
if auther.ReCaptcha != nil {
data["ReCaptcha"] = auther.ReCaptcha.Key != "" && auther.ReCaptcha.Secret != ""
data["ReCaptchaHost"] = auther.ReCaptcha.Host
data["ReCaptchaKey"] = auther.ReCaptcha.Key
}
}
b, err := json.MarshalIndent(data, "", " ")
if err != nil {
return http.StatusInternalServerError, err
}
data["Json"] = string(b)
index := template.Must(template.New("index").Delims("[{[", "]}]").Parse(box.MustString(file)))
err = index.Execute(w, data)
if err != nil {
return http.StatusInternalServerError, err
}
return 0, nil
}
func getStaticHandlers(storage *storage.Storage, server *settings.Server) (http.Handler, http.Handler) {
box := rice.MustFindBox("../frontend/dist")
handler := http.FileServer(box.HTTPBox())
index := handle(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
if r.Method != http.MethodGet {
return http.StatusNotFound, nil
}
w.Header().Set("x-xss-protection", "1; mode=block")
return handleWithStaticData(w, r, d, box, "index.html", "text/html; charset=utf-8")
}, "", storage, server)
static := handle(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
if r.Method != http.MethodGet {
return http.StatusNotFound, nil
}
if d.settings.Branding.Files != "" {
if strings.HasPrefix(r.URL.Path, "img/") {
path := filepath.Join(d.settings.Branding.Files, r.URL.Path)
if _, err := os.Stat(path); err == nil {
http.ServeFile(w, r, path)
return 0, nil
}
} else if r.URL.Path == "custom.css" && d.settings.Branding.Files != "" {
http.ServeFile(w, r, filepath.Join(d.settings.Branding.Files, "custom.css"))
return 0, nil
}
}
if !strings.HasSuffix(r.URL.Path, ".js") {
handler.ServeHTTP(w, r)
return 0, nil
}
return handleWithStaticData(w, r, d, box, r.URL.Path, "application/javascript; charset=utf-8")
}, "/static/", storage, server)
return index, static
}

View File

@@ -2,123 +2,85 @@ package http
import (
"encoding/json"
"errors"
"log"
"net/http"
"os"
"sort"
"strconv"
"strings"
fm "github.com/filebrowser/filebrowser"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/gorilla/mux"
)
type modifyRequest struct {
What string `json:"what"` // Answer to: what data type?
Which string `json:"which"` // Answer to: which field?
}
type modifyUserRequest struct {
*modifyRequest
Data *fm.User `json:"data"`
modifyRequest
Data *users.User `json:"data"`
}
// usersHandler is the entry point of the users API. It's just a router
// to send the request to its
func usersHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// If the user isn't admin and isn't making a PUT
// request, then return forbidden.
if !c.User.Admin && r.Method != http.MethodPut {
return http.StatusForbidden, nil
}
switch r.Method {
case http.MethodGet:
return usersGetHandler(c, w, r)
case http.MethodPost:
return usersPostHandler(c, w, r)
case http.MethodDelete:
return usersDeleteHandler(c, w, r)
case http.MethodPut:
return usersPutHandler(c, w, r)
}
return http.StatusNotImplemented, nil
}
// getUserID returns the id from the user which is present
// in the request url. If the url is invalid and doesn't
// contain a valid ID, it returns an fm.Error.
func getUserID(r *http.Request) (int, error) {
// Obtains the ID in string from the URL and converts
// it into an integer.
sid := strings.TrimPrefix(r.URL.Path, "/")
sid = strings.TrimSuffix(sid, "/")
id, err := strconv.Atoi(sid)
func getUserID(r *http.Request) (uint, error) {
vars := mux.Vars(r)
i, err := strconv.ParseUint(vars["id"], 10, 0)
if err != nil {
return http.StatusBadRequest, err
return 0, err
}
return id, nil
return uint(i), err
}
// getUser returns the user which is present in the request
// body. If the body is empty or the JSON is invalid, it
// returns an fm.Error.
func getUser(c *fm.Context, r *http.Request) (*fm.User, string, error) {
// Checks if the request body is empty.
func getUser(w http.ResponseWriter, r *http.Request) (*modifyUserRequest, error) {
if r.Body == nil {
return nil, "", fm.ErrEmptyRequest
return nil, errors.ErrEmptyRequest
}
// Parses the request body and checks if it's well formed.
mod := &modifyUserRequest{}
err := json.NewDecoder(r.Body).Decode(mod)
req := &modifyUserRequest{}
err := json.NewDecoder(r.Body).Decode(req)
if err != nil {
return nil, "", err
return nil, err
}
// Checks if the request type is right.
if mod.What != "user" {
return nil, "", fm.ErrWrongDataType
if req.What != "user" {
return nil, errors.ErrInvalidDataType
}
mod.Data.FileSystem = c.NewFS(mod.Data.Scope)
return mod.Data, mod.Which, nil
return req, nil
}
func usersGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// Request for the default user data.
if r.URL.Path == "/base" {
return renderJSON(w, c.DefaultUser)
}
// Request for the listing of users.
if r.URL.Path == "/" {
users, err := c.Store.Users.Gets(c.NewFS)
func withSelfOrAdmin(fn handleFunc) handleFunc {
return withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
id, err := getUserID(r)
if err != nil {
return http.StatusInternalServerError, err
}
for _, u := range users {
// Removes the user password so it won't
// be sent to the front-end.
u.Password = ""
if d.user.ID != id && !d.user.Perm.Admin {
return http.StatusForbidden, nil
}
sort.Slice(users, func(i, j int) bool {
return users[i].ID < users[j].ID
})
d.raw = id
return fn(w, r, d)
})
}
return renderJSON(w, users)
}
id, err := getUserID(r)
var usersGetHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
users, err := d.store.Users.Gets(d.server.Root)
if err != nil {
return http.StatusInternalServerError, err
}
u, err := c.Store.Users.Get(id, c.NewFS)
if err == fm.ErrExist {
for _, u := range users {
u.Password = ""
}
sort.Slice(users, func(i, j int) bool {
return users[i].ID < users[j].ID
})
return renderJSON(w, r, users)
})
var userGetHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
u, err := d.store.Users.Get(d.server.Root, d.raw.(uint))
if err == errors.ErrNotExist {
return http.StatusNotFound, err
}
@@ -127,257 +89,107 @@ func usersGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
}
u.Password = ""
return renderJSON(w, u)
}
return renderJSON(w, r, u)
})
func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
if r.URL.Path != "/" {
return http.StatusMethodNotAllowed, nil
}
u, _, err := getUser(c, r)
if err != nil {
return http.StatusBadRequest, err
}
// Checks if username isn't empty.
if u.Username == "" {
return http.StatusBadRequest, fm.ErrEmptyUsername
}
// Checks if scope isn't empty.
if u.Scope == "" {
return http.StatusBadRequest, fm.ErrEmptyScope
}
// Checks if password isn't empty.
if u.Password == "" {
return http.StatusBadRequest, fm.ErrEmptyPassword
}
// Initialize rules if they're not initialized.
if u.Rules == nil {
u.Rules = []*fm.Rule{}
}
// If the view mode is empty, initialize with the default one.
if u.ViewMode == "" {
u.ViewMode = c.DefaultUser.ViewMode
}
// Initialize commands if not initialized.
if u.Commands == nil {
u.Commands = []string{}
}
// It's a new user so the ID will be auto created.
if u.ID != 0 {
u.ID = 0
}
// Checks if the scope exists.
if code, err := checkFS(u.Scope); err != nil {
return code, err
}
// Hashes the password.
pw, err := fm.HashPassword(u.Password)
if err != nil {
return http.StatusInternalServerError, err
}
u.Password = pw
u.ViewMode = fm.MosaicViewMode
// Saves the user to the database.
err = c.Store.Users.Save(u)
if err == fm.ErrExist {
return http.StatusConflict, err
}
if err != nil {
return http.StatusInternalServerError, err
}
// Set the Location header and return.
w.Header().Set("Location", "/settings/users/"+strconv.Itoa(u.ID))
w.WriteHeader(http.StatusCreated)
return 0, nil
}
func checkFS(path string) (int, error) {
info, err := os.Stat(path)
if err != nil {
if !os.IsNotExist(err) {
return http.StatusInternalServerError, err
}
err = os.MkdirAll(path, 0666)
if err != nil {
return http.StatusInternalServerError, err
}
return 0, nil
}
if !info.IsDir() {
return http.StatusBadRequest, errors.New("Scope is not a dir")
}
return 0, nil
}
func usersDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
if r.URL.Path == "/" {
return http.StatusMethodNotAllowed, nil
}
id, err := getUserID(r)
if err != nil {
return http.StatusInternalServerError, err
}
// Deletes the user from the database.
err = c.Store.Users.Delete(id)
if err == fm.ErrNotExist {
return http.StatusNotFound, fm.ErrNotExist
}
if err != nil {
return http.StatusInternalServerError, err
var userDeleteHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
err := d.store.Users.Delete(d.raw.(uint))
if err == errors.ErrNotExist {
return http.StatusNotFound, err
}
return http.StatusOK, nil
}
})
func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// New users should be created on /api/users.
if r.URL.Path == "/" {
return http.StatusMethodNotAllowed, nil
}
// Gets the user ID from the URL and checks if it's valid.
id, err := getUserID(r)
if err != nil {
return http.StatusInternalServerError, err
}
// Checks if the user has permission to access this page.
if !c.User.Admin && id != c.User.ID {
return http.StatusForbidden, nil
}
// Gets the user from the request body.
u, which, err := getUser(c, r)
var userPostHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
req, err := getUser(w, r)
if err != nil {
return http.StatusBadRequest, err
}
// If we're updating the default user. Only for NoAuth
// implementations. Used to change the viewMode.
if id == 0 && c.NoAuth {
c.DefaultUser.ViewMode = u.ViewMode
return http.StatusOK, nil
if len(req.Which) != 0 {
return http.StatusBadRequest, nil
}
// Updates the CSS and locale.
if which == "partial" {
c.User.CSS = u.CSS
c.User.Locale = u.Locale
c.User.ViewMode = u.ViewMode
if req.Data.Password == "" {
return http.StatusBadRequest, errors.ErrEmptyPassword
}
req.Data.Password, err = users.HashPwd(req.Data.Password)
if err != nil {
return http.StatusInternalServerError, err
}
userHome, err := d.settings.MakeUserDir(req.Data.Username, req.Data.Scope, d.server.Root)
if err != nil {
log.Printf("create user: failed to mkdir user home dir: [%s]", userHome)
return http.StatusInternalServerError, err
}
req.Data.Scope = userHome
log.Printf("user: %s, home dir: [%s].", req.Data.Username, userHome)
err = d.store.Users.Save(req.Data)
if err != nil {
return http.StatusInternalServerError, err
}
w.Header().Set("Location", "/settings/users/"+strconv.FormatUint(uint64(req.Data.ID), 10))
return http.StatusCreated, nil
})
var userPutHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
req, err := getUser(w, r)
if err != nil {
return http.StatusBadRequest, err
}
if req.Data.ID != d.raw.(uint) {
return http.StatusBadRequest, nil
}
if len(req.Which) == 1 && req.Which[0] == "all" {
if !d.user.Perm.Admin {
return http.StatusForbidden, err
}
if req.Data.Password != "" {
req.Data.Password, err = users.HashPwd(req.Data.Password)
} else {
var suser *users.User
suser, err = d.store.Users.Get(d.server.Root, d.raw.(uint))
req.Data.Password = suser.Password
}
err = c.Store.Users.Update(c.User, "CSS", "Locale", "ViewMode")
if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, nil
req.Which = []string{}
}
// Updates the Password.
if which == "password" {
if u.Password == "" {
return http.StatusBadRequest, fm.ErrEmptyPassword
for k, v := range req.Which {
if v == "password" {
if !d.user.Perm.Admin && d.user.LockPassword {
return http.StatusForbidden, nil
}
req.Data.Password, err = users.HashPwd(req.Data.Password)
if err != nil {
return http.StatusInternalServerError, err
}
}
if id == c.User.ID && c.User.LockPassword {
if !d.user.Perm.Admin && (v == "scope" || v == "perm" || v == "username") {
return http.StatusForbidden, nil
}
c.User.Password, err = fm.HashPassword(u.Password)
if err != nil {
return http.StatusInternalServerError, err
}
err = c.Store.Users.Update(c.User, "Password")
if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, nil
req.Which[k] = strings.Title(v)
}
// If can only be all.
if which != "all" {
return http.StatusBadRequest, fm.ErrInvalidUpdateField
}
// Checks if username isn't empty.
if u.Username == "" {
return http.StatusBadRequest, fm.ErrEmptyUsername
}
// Checks if filesystem isn't empty.
if u.Scope == "" {
return http.StatusBadRequest, fm.ErrEmptyScope
}
// Checks if the scope exists.
if code, err := checkFS(u.Scope); err != nil {
return code, err
}
// Initialize rules if they're not initialized.
if u.Rules == nil {
u.Rules = []*fm.Rule{}
}
// Initialize commands if not initialized.
if u.Commands == nil {
u.Commands = []string{}
}
// Gets the current saved user from the in-memory map.
suser, err := c.Store.Users.Get(id, c.NewFS)
if err == fm.ErrNotExist {
return http.StatusNotFound, nil
}
if err != nil {
return http.StatusInternalServerError, err
}
u.ID = id
// Changes the password if the request wants it.
if u.Password != "" {
pw, err := fm.HashPassword(u.Password)
if err != nil {
return http.StatusInternalServerError, err
}
u.Password = pw
} else {
u.Password = suser.Password
}
// Updates the whole User struct because we always are supposed
// to send a new entire object.
err = c.Store.Users.Update(u)
err = d.store.Users.Update(req.Data, req.Which...)
if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, nil
}
})

59
http/utils.go Normal file
View File

@@ -0,0 +1,59 @@
package http
import (
"encoding/json"
"net/http"
"net/url"
"os"
"strings"
"github.com/filebrowser/filebrowser/v2/errors"
)
func renderJSON(w http.ResponseWriter, r *http.Request, data interface{}) (int, error) {
marsh, err := json.Marshal(data)
if err != nil {
return http.StatusInternalServerError, err
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if _, err := w.Write(marsh); err != nil {
return http.StatusInternalServerError, err
}
return 0, nil
}
func errToStatus(err error) int {
switch {
case err == nil:
return http.StatusOK
case os.IsPermission(err):
return http.StatusForbidden
case os.IsNotExist(err), err == errors.ErrNotExist:
return http.StatusNotFound
case os.IsExist(err), err == errors.ErrExist:
return http.StatusConflict
default:
return http.StatusInternalServerError
}
}
// This is an addaptation if http.StripPrefix in which we don't
// return 404 if the page doesn't have the needed prefix.
func stripPrefix(prefix string, h http.Handler) http.Handler {
if prefix == "" {
return h
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
p := strings.TrimPrefix(r.URL.Path, prefix)
r2 := new(http.Request)
*r2 = *r
r2.URL = new(url.URL)
*r2.URL = *r.URL
r2.URL.Path = p
h.ServeHTTP(w, r2)
})
}

View File

@@ -1,339 +0,0 @@
package http
import (
"bytes"
"encoding/json"
"mime"
"net/http"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"time"
fm "github.com/filebrowser/filebrowser"
"github.com/gorilla/websocket"
)
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
var (
cmdNotImplemented = []byte("Command not implemented.")
cmdNotAllowed = []byte("Command not allowed.")
)
// 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) {
// Upgrades the connection to a websocket and checks for fm.Errors.
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
return 0, err
}
defer conn.Close()
var (
message []byte
command []string
)
// Starts an infinite loop until a valid command is captured.
for {
_, message, err = conn.ReadMessage()
if err != nil {
return http.StatusInternalServerError, err
}
command = strings.Split(string(message), " ")
if len(command) != 0 {
break
}
}
// Check if the command is allowed
allowed := false
for _, cmd := range c.User.Commands {
if cmd == command[0] {
allowed = true
}
}
if !allowed {
err = conn.WriteMessage(websocket.BinaryMessage, cmdNotAllowed)
if err != nil {
return http.StatusInternalServerError, err
}
return 0, nil
}
// Check if the program is talled is installed on the computer.
if _, err = exec.LookPath(command[0]); err != nil {
err = conn.WriteMessage(websocket.BinaryMessage, cmdNotImplemented)
if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusNotImplemented, nil
}
// Gets the path and initializes a buffer.
path := c.User.Scope + "/" + r.URL.Path
path = filepath.Clean(path)
buff := new(bytes.Buffer)
// Sets up the command executation.
cmd := exec.Command(command[0], command[1:]...)
cmd.Dir = path
cmd.Stderr = buff
cmd.Stdout = buff
// Starts the command and checks for fm.Errors.
err = cmd.Start()
if err != nil {
return http.StatusInternalServerError, err
}
// Set a 'done' variable to check whetever the command has already finished
// running or not. This verification is done using a goroutine that uses the
// method .Wait() from the command.
done := false
go func() {
err = cmd.Wait()
done = true
}()
// Function to print the current information on the buffer to the connection.
print := func() error {
by := buff.Bytes()
if len(by) > 0 {
err = conn.WriteMessage(websocket.TextMessage, by)
if err != nil {
return err
}
}
return nil
}
// While the command hasn't finished running, continue sending the output
// to the client in intervals of 100 milliseconds.
for !done {
if err = print(); err != nil {
return http.StatusInternalServerError, err
}
time.Sleep(100 * time.Millisecond)
}
// After the command is done executing, send the output one more time to the
// browser to make sure it gets the latest information.
if err = print(); err != nil {
return http.StatusInternalServerError, err
}
return 0, nil
}
var (
typeRegexp = regexp.MustCompile(`type:(\w+)`)
)
type condition func(path string) bool
type searchOptions struct {
CaseInsensitive bool
Conditions []condition
Terms []string
}
func extensionCondition(extension string) condition {
return func(path string) bool {
return filepath.Ext(path) == "."+extension
}
}
func imageCondition(path string) bool {
extension := filepath.Ext(path)
mimetype := mime.TypeByExtension(extension)
return strings.HasPrefix(mimetype, "image")
}
func audioCondition(path string) bool {
extension := filepath.Ext(path)
mimetype := mime.TypeByExtension(extension)
return strings.HasPrefix(mimetype, "audio")
}
func videoCondition(path string) bool {
extension := filepath.Ext(path)
mimetype := mime.TypeByExtension(extension)
return strings.HasPrefix(mimetype, "video")
}
func parseSearch(value string) *searchOptions {
opts := &searchOptions{
CaseInsensitive: strings.Contains(value, "case:insensitive"),
Conditions: []condition{},
Terms: []string{},
}
// removes the options from the value
value = strings.Replace(value, "case:insensitive", "", -1)
value = strings.Replace(value, "case:sensitive", "", -1)
value = strings.TrimSpace(value)
types := typeRegexp.FindAllStringSubmatch(value, -1)
for _, t := range types {
if len(t) == 1 {
continue
}
switch t[1] {
case "image":
opts.Conditions = append(opts.Conditions, imageCondition)
case "audio", "music":
opts.Conditions = append(opts.Conditions, audioCondition)
case "video":
opts.Conditions = append(opts.Conditions, videoCondition)
default:
opts.Conditions = append(opts.Conditions, extensionCondition(t[1]))
}
}
if len(types) > 0 {
// Remove the fields from the search value.
value = typeRegexp.ReplaceAllString(value, "")
}
// If it's canse insensitive, put everything in lowercase.
if opts.CaseInsensitive {
value = strings.ToLower(value)
}
// Remove the spaces from the search value.
value = strings.TrimSpace(value)
if value == "" {
return opts
}
// if the value starts with " and finishes what that character, we will
// only search for that term
if value[0] == '"' && value[len(value)-1] == '"' {
unique := strings.TrimPrefix(value, "\"")
unique = strings.TrimSuffix(unique, "\"")
opts.Terms = []string{unique}
return opts
}
opts.Terms = strings.Split(value, " ")
return opts
}
// search searches for a file or directory.
func search(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// Upgrades the connection to a websocket and checks for fm.Errors.
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
return 0, err
}
defer conn.Close()
var (
value string
search *searchOptions
message []byte
)
// Starts an infinite loop until a valid command is captured.
for {
_, message, err = conn.ReadMessage()
if err != nil {
return http.StatusInternalServerError, err
}
if len(message) != 0 {
value = string(message)
break
}
}
search = parseSearch(value)
scope := strings.TrimPrefix(r.URL.Path, "/")
scope = "/" + scope
scope = c.User.Scope + scope
scope = strings.Replace(scope, "\\", "/", -1)
scope = filepath.Clean(scope)
err = filepath.Walk(scope, func(path string, f os.FileInfo, err error) error {
if search.CaseInsensitive {
path = strings.ToLower(path)
}
path = strings.TrimPrefix(path, scope)
path = strings.TrimPrefix(path, "/")
path = strings.Replace(path, "\\", "/", -1)
// Only execute if there are conditions to meet.
if len(search.Conditions) > 0 {
match := false
for _, t := range search.Conditions {
if t(path) {
match = true
break
}
}
// If doesn't meet the condition, go to the next.
if !match {
return nil
}
}
if len(search.Terms) > 0 {
is := false
// Checks if matches the terms and if it is allowed.
for _, term := range search.Terms {
if is {
break
}
if strings.Contains(path, term) {
if !c.User.Allowed(path) {
return nil
}
is = true
}
}
if !is {
return nil
}
}
response, _ := json.Marshal(map[string]interface{}{
"dir": f.IsDir(),
"path": path,
})
return conn.WriteMessage(websocket.TextMessage, response)
})
if err != nil {
return http.StatusInternalServerError, err
}
return 0, nil
}

12
main.go Normal file
View File

@@ -0,0 +1,12 @@
package main
import (
"runtime"
"github.com/filebrowser/filebrowser/v2/cmd"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
cmd.Execute()
}

View File

@@ -1,8 +0,0 @@
{
"name": "filebrowser",
"author": "File Browser contributors",
"private": true,
"dependencies": {
"filebrowser-frontend": "^1.0.3"
}
}

View File

@@ -1,21 +0,0 @@
#!/bin/bash
set -e
echo "Building assets"
./build.sh
echo "Updating version number to $1..."
sed -i "s|(untracked)|$1|g" filebrowser.go
git add -A
git commit -m "chore: version $1"
git tag "v$1"
git push
git push --tags
echo "Commiting untracked version notice..."
sed -i "s|$1|(untracked)|g" filebrowser.go
git add -A
git commit -m "chore: setting untracked version [ci skip]"
git push
echo "Done!"

View File

@@ -1 +0,0 @@
48f80ccfd160585c4a9e60e1f90399ec17c185ea

44
rules/rules.go Normal file
View File

@@ -0,0 +1,44 @@
package rules
import (
"regexp"
"strings"
)
// Checker is a Rules checker.
type Checker interface {
Check(path string) bool
}
// Rule is a allow/disallow rule.
type Rule struct {
Regex bool `json:"regex"`
Allow bool `json:"allow"`
Path string `json:"path"`
Regexp *Regexp `json:"regexp"`
}
// Matches matches a path against a rule.
func (r *Rule) Matches(path string) bool {
if r.Regex {
return r.Regexp.MatchString(path)
}
return strings.HasPrefix(path, r.Path)
}
// Regexp is a wrapper to the native regexp type where we
// save the raw expression.
type Regexp struct {
Raw string `json:"raw"`
regexp *regexp.Regexp
}
// MatchString checks if a string matches the regexp.
func (r *Regexp) MatchString(s string) bool {
if r.regexp == nil {
r.regexp = regexp.MustCompile(r.Raw)
}
return r.regexp.MatchString(s)
}

34
runner/parser.go Normal file
View File

@@ -0,0 +1,34 @@
package runner
import (
"os/exec"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/mholt/caddy"
)
// ParseCommand parses the command taking in account if the current
// instance uses a shell to run the commands or just calls the binary
// directyly.
func ParseCommand(s *settings.Settings, raw string) ([]string, error) {
command := []string{}
if len(s.Shell) == 0 {
cmd, args, err := caddy.SplitCommandAndArgs(raw)
if err != nil {
return nil, err
}
_, err = exec.LookPath(cmd)
if err != nil {
return nil, err
}
command = append(command, cmd)
command = append(command, args...)
} else {
command = append(s.Shell, raw)
}
return command, nil
}

81
runner/runner.go Normal file
View File

@@ -0,0 +1,81 @@
package runner
import (
"fmt"
"log"
"os"
"os/exec"
"strings"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
)
// Runner is a commands runner.
type Runner struct {
*settings.Settings
}
// RunHook runs the hooks for the before and after event.
func (r *Runner) RunHook(fn func() error, evt, path, dst string, user *users.User) error {
path = user.FullPath(path)
dst = user.FullPath(dst)
if val, ok := r.Commands["before_"+evt]; ok {
for _, command := range val {
err := r.exec(command, "before_"+evt, path, dst, user)
if err != nil {
return err
}
}
}
err := fn()
if err != nil {
return err
}
if val, ok := r.Commands["after_"+evt]; ok {
for _, command := range val {
err := r.exec(command, "after_"+evt, path, dst, user)
if err != nil {
return err
}
}
}
return nil
}
func (r *Runner) exec(raw, evt, path, dst string, user *users.User) error {
blocking := true
if strings.HasSuffix(raw, "&") {
blocking = false
raw = strings.TrimSpace(strings.TrimSuffix(raw, "&"))
}
command, err := ParseCommand(r.Settings, raw)
if err != nil {
return err
}
cmd := exec.Command(command[0], command[1:]...)
cmd.Env = append(os.Environ(), fmt.Sprintf("FILE=%s", path))
cmd.Env = append(cmd.Env, fmt.Sprintf("SCOPE=%s", user.Scope))
cmd.Env = append(cmd.Env, fmt.Sprintf("TRIGGER=%s", evt))
cmd.Env = append(cmd.Env, fmt.Sprintf("USERNAME=%s", user.Username))
cmd.Env = append(cmd.Env, fmt.Sprintf("DESTINATION=%s", dst))
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if !blocking {
log.Printf("[INFO] Nonblocking Command: \"%s\"", strings.Join(command, " "))
return cmd.Start()
}
log.Printf("[INFO] Blocking Command: \"%s\"", strings.Join(command, " "))
return cmd.Run()
}

102
search/conditions.go Normal file
View File

@@ -0,0 +1,102 @@
package search
import (
"mime"
"path/filepath"
"regexp"
"strings"
)
var (
typeRegexp = regexp.MustCompile(`type:(\w+)`)
)
type condition func(path string) bool
func extensionCondition(extension string) condition {
return func(path string) bool {
return filepath.Ext(path) == "."+extension
}
}
func imageCondition(path string) bool {
extension := filepath.Ext(path)
mimetype := mime.TypeByExtension(extension)
return strings.HasPrefix(mimetype, "image")
}
func audioCondition(path string) bool {
extension := filepath.Ext(path)
mimetype := mime.TypeByExtension(extension)
return strings.HasPrefix(mimetype, "audio")
}
func videoCondition(path string) bool {
extension := filepath.Ext(path)
mimetype := mime.TypeByExtension(extension)
return strings.HasPrefix(mimetype, "video")
}
func parseSearch(value string) *searchOptions {
opts := &searchOptions{
CaseSensitive: strings.Contains(value, "case:sensitive"),
Conditions: []condition{},
Terms: []string{},
}
// removes the options from the value
value = strings.Replace(value, "case:insensitive", "", -1)
value = strings.Replace(value, "case:sensitive", "", -1)
value = strings.TrimSpace(value)
types := typeRegexp.FindAllStringSubmatch(value, -1)
for _, t := range types {
if len(t) == 1 {
continue
}
switch t[1] {
case "image":
opts.Conditions = append(opts.Conditions, imageCondition)
case "audio", "music":
opts.Conditions = append(opts.Conditions, audioCondition)
case "video":
opts.Conditions = append(opts.Conditions, videoCondition)
default:
opts.Conditions = append(opts.Conditions, extensionCondition(t[1]))
}
}
if len(types) > 0 {
// Remove the fields from the search value.
value = typeRegexp.ReplaceAllString(value, "")
}
// If it's canse insensitive, put everything in lowercase.
if !opts.CaseSensitive {
value = strings.ToLower(value)
}
// Remove the spaces from the search value.
value = strings.TrimSpace(value)
if value == "" {
return opts
}
// if the value starts with " and finishes what that character, we will
// only search for that term
if value[0] == '"' && value[len(value)-1] == '"' {
unique := strings.TrimPrefix(value, "\"")
unique = strings.TrimSuffix(unique, "\"")
opts.Terms = []string{unique}
return opts
}
opts.Terms = strings.Split(value, " ")
return opts
}

69
search/search.go Normal file
View File

@@ -0,0 +1,69 @@
package search
import (
"os"
"strings"
"github.com/filebrowser/filebrowser/v2/rules"
"github.com/spf13/afero"
)
type searchOptions struct {
CaseSensitive bool
Conditions []condition
Terms []string
}
// Search searches for a query in a fs.
func Search(fs afero.Fs, scope, query string, checker rules.Checker, found func(path string, f os.FileInfo) error) error {
search := parseSearch(query)
scope = strings.Replace(scope, "\\", "/", -1)
scope = strings.TrimPrefix(scope, "/")
scope = strings.TrimSuffix(scope, "/")
scope = "/" + scope + "/"
return afero.Walk(fs, scope, func(originalPath string, f os.FileInfo, err error) error {
originalPath = strings.Replace(originalPath, "\\", "/", -1)
originalPath = strings.TrimPrefix(originalPath, "/")
originalPath = "/" + originalPath
path := originalPath
if path == scope {
return nil
}
if !checker.Check(path) {
return nil
}
if !search.CaseSensitive {
path = strings.ToLower(path)
}
if len(search.Conditions) > 0 {
match := false
for _, t := range search.Conditions {
if t(path) {
match = true
break
}
}
if !match {
return nil
}
}
if len(search.Terms) > 0 {
for _, term := range search.Terms {
if strings.Contains(path, term) {
return found(strings.TrimPrefix(originalPath, scope), f)
}
}
}
return nil
})
}

8
settings/branding.go Normal file
View File

@@ -0,0 +1,8 @@
package settings
// Branding contains the branding settings of the app.
type Branding struct {
Name string `json:"name"`
DisableExternal bool `json:"disableExternal"`
Files string `json:"files"`
}

27
settings/defaults.go Normal file
View File

@@ -0,0 +1,27 @@
package settings
import (
"github.com/filebrowser/filebrowser/v2/files"
"github.com/filebrowser/filebrowser/v2/users"
)
// UserDefaults is a type that holds the default values
// for some fields on User.
type UserDefaults struct {
Scope string `json:"scope"`
Locale string `json:"locale"`
ViewMode users.ViewMode `json:"viewMode"`
Sorting files.Sorting `json:"sorting"`
Perm users.Permissions `json:"perm"`
Commands []string `json:"commands"`
}
// Apply applies the default options to a user.
func (d *UserDefaults) Apply(u *users.User) {
u.Scope = d.Scope
u.Locale = d.Locale
u.ViewMode = d.ViewMode
u.Perm = d.Perm
u.Sorting = d.Sorting
u.Commands = d.Commands
}

75
settings/dir.go Normal file
View File

@@ -0,0 +1,75 @@
package settings
import (
"errors"
"log"
"os"
"regexp"
"strings"
"github.com/spf13/afero"
)
var (
invalidFilenameChars = regexp.MustCompile(`[^0-9A-Za-z@_\-.]`)
dashes = regexp.MustCompile(`[\-]+`)
)
// MakeUserDir makes the user directory according to settings.
func (settings *Settings) MakeUserDir(username, userScope, serverRoot string) (string, error) {
var err error
userScope = strings.TrimSpace(userScope)
if userScope == "" || userScope == "./" {
userScope = "."
}
if !settings.CreateUserDir {
return userScope, nil
}
fs := afero.NewBasePathFs(afero.NewOsFs(), serverRoot)
// Use the default auto create logic only if specific scope is not the default scope
if userScope != settings.Defaults.Scope {
// Try create the dir, for example: settings.Defaults.Scope == "." and userScope == "./foo"
if userScope != "." {
err = fs.MkdirAll(userScope, os.ModePerm)
if err != nil {
log.Printf("create user: failed to mkdir user home dir: [%s]", userScope)
}
}
return userScope, err
}
// Clean username first
username = cleanUsername(username)
if username == "" || username == "-" || username == "." {
log.Printf("create user: invalid user for home dir creation: [%s]", username)
return "", errors.New("invalid user for home dir creation")
}
// Create default user dir
userHomeBase := settings.Defaults.Scope + string(os.PathSeparator) + "users"
userHome := userHomeBase + string(os.PathSeparator) + username
err = fs.MkdirAll(userHome, os.ModePerm)
if err != nil {
log.Printf("create user: failed to mkdir user home dir: [%s]", userHome)
} else {
log.Printf("create user: mkdir user home dir: [%s] successfully.", userHome)
}
return userHome, err
}
func cleanUsername(s string) string {
// Remove any trailing space to avoid ending on -
s = strings.Trim(s, " ")
s = strings.Replace(s, "..", "", -1)
// Replace all characters which not in the list `0-9A-Za-z@_\-.` with a dash
s = invalidFilenameChars.ReplaceAllString(s, "-")
// Remove any multiple dashes caused by replacements above
s = dashes.ReplaceAllString(s, "-")
return s
}

58
settings/settings.go Normal file
View File

@@ -0,0 +1,58 @@
package settings
import (
"crypto/rand"
"strings"
"github.com/filebrowser/filebrowser/v2/rules"
)
// AuthMethod describes an authentication method.
type AuthMethod string
// Settings contain the main settings of the application.
type Settings struct {
Key []byte `json:"key"`
Signup bool `json:"signup"`
CreateUserDir bool `json:"createUserDir"`
Defaults UserDefaults `json:"defaults"`
AuthMethod AuthMethod `json:"authMethod"`
Branding Branding `json:"branding"`
Commands map[string][]string `json:"commands"`
Shell []string `json:"shell"`
Rules []rules.Rule `json:"rules"`
}
// GetRules implements rules.Provider.
func (s *Settings) GetRules() []rules.Rule {
return s.Rules
}
// Server specific settings.
type Server struct {
Root string `json:"root"`
BaseURL string `json:"baseURL"`
Socket string `json:"socket"`
TLSKey string `json:"tlsKey"`
TLSCert string `json:"tlsCert"`
Port string `json:"port"`
Address string `json:"address"`
Log string `json:"log"`
}
// Clean cleans any variables that might need cleaning.
func (s *Server) Clean() {
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
}

97
settings/storage.go Normal file
View File

@@ -0,0 +1,97 @@
package settings
import (
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/rules"
"github.com/filebrowser/filebrowser/v2/users"
)
// StorageBackend is a settings storage backend.
type StorageBackend interface {
Get() (*Settings, error)
Save(*Settings) error
GetServer() (*Server, error)
SaveServer(*Server) error
}
// Storage is a settings storage.
type Storage struct {
back StorageBackend
}
// NewStorage creates a settings storage from a backend.
func NewStorage(back StorageBackend) *Storage {
return &Storage{back: back}
}
// Get returns the settings for the current instance.
func (s *Storage) Get() (*Settings, error) {
return s.back.Get()
}
var defaultEvents = []string{
"save",
"copy",
"rename",
"upload",
"delete",
}
// Save saves the settings for the current instance.
func (s *Storage) Save(set *Settings) error {
if len(set.Key) == 0 {
return errors.ErrEmptyKey
}
if set.Defaults.Locale == "" {
set.Defaults.Locale = "en"
}
if set.Defaults.Commands == nil {
set.Defaults.Commands = []string{}
}
if set.Defaults.ViewMode == "" {
set.Defaults.ViewMode = users.MosaicViewMode
}
if set.Rules == nil {
set.Rules = []rules.Rule{}
}
if set.Shell == nil {
set.Shell = []string{}
}
if set.Commands == nil {
set.Commands = map[string][]string{}
}
for _, event := range defaultEvents {
if _, ok := set.Commands["before_"+event]; !ok {
set.Commands["before_"+event] = []string{}
}
if _, ok := set.Commands["after_"+event]; !ok {
set.Commands["after_"+event] = []string{}
}
}
err := s.back.Save(set)
if err != nil {
return err
}
return nil
}
// GetServer wraps StorageBackend.GetServer.
func (s *Storage) GetServer() (*Server, error) {
return s.back.GetServer()
}
// SaveServer wraps StorageBackend.SaveServer and adds some verification.
func (s *Storage) SaveServer(ser *Server) error {
ser.Clean()
return s.back.SaveServer(ser)
}

9
share/share.go Normal file
View File

@@ -0,0 +1,9 @@
package share
// Link is the information needed to build a shareable link.
type Link struct {
Hash string `json:"hash" storm:"id,index"`
Path string `json:"path" storm:"index"`
UserID uint `json:"userID"`
Expire int64 `json:"expire"`
}

74
share/storage.go Normal file
View File

@@ -0,0 +1,74 @@
package share
import (
"time"
"github.com/filebrowser/filebrowser/v2/errors"
)
// StorageBackend is the interface to implement for a share storage.
type StorageBackend interface {
GetByHash(hash string) (*Link, error)
GetPermanent(path string, id uint) (*Link, error)
Gets(path string, id uint) ([]*Link, error)
Save(s *Link) error
Delete(hash string) error
}
// Storage is a storage.
type Storage struct {
back StorageBackend
}
// NewStorage creates a share links storage from a backend.
func NewStorage(back StorageBackend) *Storage {
return &Storage{back: back}
}
// GetByHash wraps a StorageBackend.GetByHash.
func (s *Storage) GetByHash(hash string) (*Link, error) {
link, err := s.back.GetByHash(hash)
if err != nil {
return nil, err
}
if link.Expire != 0 && link.Expire <= time.Now().Unix() {
s.Delete(link.Hash)
return nil, errors.ErrNotExist
}
return link, nil
}
// GetPermanent wraps a StorageBackend.GetPermanent
func (s *Storage) GetPermanent(path string, id uint) (*Link, error) {
return s.back.GetPermanent(path, id)
}
// Gets wraps a StorageBackend.Gets
func (s *Storage) Gets(path string, id uint) ([]*Link, error) {
links, err := s.back.Gets(path, id)
if err != nil {
return nil, err
}
for i, link := range links {
if link.Expire != 0 && link.Expire <= time.Now().Unix() {
s.Delete(link.Hash)
links = append(links[:i], links[i+1:]...)
}
}
return links, nil
}
// Save wraps a StorageBackend.Save
func (s *Storage) Save(l *Link) error {
return s.back.Save(l)
}
// Delete wraps a StorageBackend.Delete
func (s *Storage) Delete(hash string) error {
return s.back.Delete(hash)
}

View File

@@ -1,195 +0,0 @@
package staticgen
import (
"errors"
"io/ioutil"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"strings"
fm "github.com/filebrowser/filebrowser"
"github.com/hacdias/varutils"
)
var (
errUnsupportedFileType = errors.New("The type of the provided file isn't supported for this action")
)
// Hugo is the Hugo static website generator.
type Hugo struct {
// Website root
Root string `name:"Website Root"`
// Public folder
Public string `name:"Public Directory"`
// Hugo executable path
Exe string `name:"Hugo Executable"`
// Hugo arguments
Args []string `name:"Hugo Arguments"`
// Indicates if we should clean public before a new publish.
CleanPublic bool `name:"Clean Public"`
// previewPath is the temporary path for a preview
previewPath string
}
// SettingsPath retrieves the correct settings path.
func (h Hugo) SettingsPath() string {
var frontmatter string
var err error
if _, err = os.Stat(filepath.Join(h.Root, "config.yaml")); err == nil {
frontmatter = "yaml"
}
if _, err = os.Stat(filepath.Join(h.Root, "config.json")); err == nil {
frontmatter = "json"
}
if _, err = os.Stat(filepath.Join(h.Root, "config.toml")); err == nil {
frontmatter = "toml"
}
if frontmatter == "" {
return "/settings"
}
return "/config." + frontmatter
}
// Name is the plugin's name.
func (h Hugo) Name() string {
return "hugo"
}
// Hook is the pre-api handler.
func (h Hugo) Hook(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// If we are not using HTTP Post, we shall return Method Not Allowed
// since we are only working with this method.
if r.Method != http.MethodPost {
return 0, nil
}
if c.Router != "resource" {
return 0, nil
}
// We only care about creating new files from archetypes here. So...
if r.Header.Get("Archetype") == "" {
return 0, nil
}
if !c.User.AllowNew {
return http.StatusForbidden, nil
}
filename := filepath.Clean(r.URL.Path)
filename = strings.TrimPrefix(filename, string(filepath.Separator))
archetype := r.Header.Get("archetype")
ext := filepath.Ext(filename)
// If the request isn't for a markdown file, we can't
// handle it.
if ext != ".markdown" && ext != ".md" {
return http.StatusBadRequest, errUnsupportedFileType
}
// Tries to create a new file based on this archetype.
args := []string{"new", filename, "--kind", archetype}
if err := runCommand(h.Exe, args, h.Root); err != nil {
return http.StatusInternalServerError, err
}
// Writes the location of the new file to the Header.
w.Header().Set("Location", "/files/content/"+filename)
return http.StatusCreated, nil
}
// Publish publishes a post.
func (h Hugo) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
filename := filepath.Join(c.User.Scope, r.URL.Path)
// We only run undraft command if it is a file.
if strings.HasSuffix(filename, ".md") && strings.HasSuffix(filename, ".markdown") {
if err := h.undraft(filename); err != nil {
return http.StatusInternalServerError, err
}
}
// Regenerates the file
h.run(false)
return 0, nil
}
// Preview handles the preview path.
func (h *Hugo) Preview(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// Get a new temporary path if there is none.
if h.previewPath == "" {
path, err := ioutil.TempDir("", "")
if err != nil {
return http.StatusInternalServerError, err
}
h.previewPath = path
}
// Build the arguments to execute Hugo: change the base URL,
// build the drafts and update the destination.
args := h.Args
args = append(args, "--baseURL", c.RootURL()+"/preview/")
args = append(args, "--buildDrafts")
args = append(args, "--destination", h.previewPath)
// Builds the preview.
if err := runCommand(h.Exe, args, h.Root); err != nil {
return http.StatusInternalServerError, err
}
// Serves the temporary path with the preview.
http.FileServer(http.Dir(h.previewPath)).ServeHTTP(w, r)
return 0, nil
}
func (h Hugo) run(force bool) {
// If the CleanPublic option is enabled, clean it.
if h.CleanPublic {
os.RemoveAll(h.Public)
}
// Prevent running if watching is enabled
if b, pos := varutils.StringInSlice("--watch", h.Args); b && !force {
if len(h.Args) > pos && h.Args[pos+1] != "false" {
return
}
if len(h.Args) == pos+1 {
return
}
}
if err := runCommand(h.Exe, h.Args, h.Root); err != nil {
log.Println(err)
}
}
func (h Hugo) undraft(file string) error {
args := []string{"undraft", file}
if err := runCommand(h.Exe, args, h.Root); err != nil && !strings.Contains(err.Error(), "not a Draft") {
return err
}
return nil
}
// Setup sets up the plugin.
func (h *Hugo) Setup() error {
var err error
if h.Exe, err = exec.LookPath("hugo"); err != nil {
return err
}
return nil
}

View File

@@ -1,125 +0,0 @@
package staticgen
import (
"io/ioutil"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"strings"
fm "github.com/filebrowser/filebrowser"
)
// Jekyll is the Jekyll static website generator.
type Jekyll struct {
// Website root
Root string `name:"Website Root"`
// Public folder
Public string `name:"Public Directory"`
// Jekyll executable path
Exe string `name:"Executable"`
// Jekyll arguments
Args []string `name:"Arguments"`
// Indicates if we should clean public before a new publish.
CleanPublic bool `name:"Clean Public"`
// previewPath is the temporary path for a preview
previewPath string
}
// Name is the plugin's name.
func (j Jekyll) Name() string {
return "jekyll"
}
// SettingsPath retrieves the correct settings path.
func (j Jekyll) SettingsPath() string {
return "/_config.yml"
}
// Hook is the pre-api handler.
func (j Jekyll) Hook(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
return 0, nil
}
// Publish publishes a post.
func (j Jekyll) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
filename := filepath.Join(c.User.Scope, r.URL.Path)
// We only run undraft command if it is a file.
if err := j.undraft(filename); err != nil {
return http.StatusInternalServerError, err
}
// Regenerates the file
j.run()
return 0, nil
}
// Preview handles the preview path.
func (j *Jekyll) Preview(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
// Get a new temporary path if there is none.
if j.previewPath == "" {
path, err := ioutil.TempDir("", "")
if err != nil {
return http.StatusInternalServerError, err
}
j.previewPath = path
}
// Build the arguments to execute Hugo: change the base URL,
// build the drafts and update the destination.
args := j.Args
args = append(args, "--baseurl", c.RootURL()+"/preview/")
args = append(args, "--drafts")
args = append(args, "--destination", j.previewPath)
// Builds the preview.
if err := runCommand(j.Exe, args, j.Root); err != nil {
return http.StatusInternalServerError, err
}
// Serves the temporary path with the preview.
http.FileServer(http.Dir(j.previewPath)).ServeHTTP(w, r)
return 0, nil
}
func (j Jekyll) run() {
// If the CleanPublic option is enabled, clean it.
if j.CleanPublic {
os.RemoveAll(j.Public)
}
if err := runCommand(j.Exe, j.Args, j.Root); err != nil {
log.Println(err)
}
}
func (j Jekyll) undraft(file string) error {
if !strings.Contains(file, "_drafts") {
return nil
}
return os.Rename(file, strings.Replace(file, "_drafts", "_posts", 1))
}
// Setup sets up the plugin.
func (j *Jekyll) Setup() error {
var err error
if j.Exe, err = exec.LookPath("jekyll"); err != nil {
return err
}
if len(j.Args) == 0 {
j.Args = []string{"build"}
}
if j.Args[0] != "build" {
j.Args = append([]string{"build"}, j.Args...)
}
return nil
}

View File

@@ -1,19 +0,0 @@
package staticgen
import (
"errors"
"os/exec"
)
// runCommand executes an external command
func runCommand(command string, args []string, path string) error {
cmd := exec.Command(command, args...)
cmd.Dir = path
out, err := cmd.CombinedOutput()
if err != nil {
return errors.New(string(out))
}
return nil
}

33
storage/bolt/auth.go Normal file
View File

@@ -0,0 +1,33 @@
package bolt
import (
"github.com/asdine/storm"
"github.com/filebrowser/filebrowser/v2/auth"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/settings"
)
type authBackend struct {
db *storm.DB
}
func (s authBackend) Get(t settings.AuthMethod) (auth.Auther, error) {
var auther auth.Auther
switch t {
case auth.MethodJSONAuth:
auther = &auth.JSONAuth{}
case auth.MethodProxyAuth:
auther = &auth.ProxyAuth{}
case auth.MethodNoAuth:
auther = &auth.NoAuth{}
default:
return nil, errors.ErrInvalidAuthMethod
}
return auther, get(s.db, "auther", auther)
}
func (s authBackend) Save(a auth.Auther) error {
return save(s.db, "auther", a)
}

Some files were not shown because too many files have changed in this diff Show More