mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
Trying to fix 403 on many requests #143
Former-commit-id: 372cd53a6822a5e308b1db41593d1285f4c4ea22 [formerly 32161936b6b381a5c945ac404005f00cbc947499] [formerly 9572d67b6ead3d407f5899dcb46c2c7527fea437 [formerly d48867f603
]]
Former-commit-id: 411c250031965f3e66c8acb341871800c120e637 [formerly 7801398085d8d8ed0e306e4fea63b94f6729b541]
Former-commit-id: fe0c0ad2201510b10cb0ac724a3066ee4378fd67
This commit is contained in:
parent
bb27d51c3a
commit
4487f8c42e
@ -49,12 +49,11 @@ export default {
|
|||||||
download: function () {
|
download: function () {
|
||||||
let url = `${this.$store.state.baseURL}/api/download`
|
let url = `${this.$store.state.baseURL}/api/download`
|
||||||
url += this.req.url.slice(6)
|
url += this.req.url.slice(6)
|
||||||
url += `?token=${this.$store.state.jwt}`
|
|
||||||
|
|
||||||
return url
|
return url
|
||||||
},
|
},
|
||||||
raw: function () {
|
raw: function () {
|
||||||
return `${this.download()}&inline=true`
|
return `${this.download()}?&inline=true`
|
||||||
},
|
},
|
||||||
back: function (event) {
|
back: function (event) {
|
||||||
let uri = url.removeLastDir(this.$route.path) + '/'
|
let uri = url.removeLastDir(this.$route.path) + '/'
|
||||||
|
@ -145,7 +145,7 @@ function checksum (url, algo) {
|
|||||||
function command (url, command, onmessage, onclose) {
|
function command (url, command, onmessage, onclose) {
|
||||||
let protocol = (ssl ? 'wss:' : 'ws:')
|
let protocol = (ssl ? 'wss:' : 'ws:')
|
||||||
url = removePrefix(url)
|
url = removePrefix(url)
|
||||||
url = `${protocol}//${window.location.hostname}${store.state.baseURL}/api/command${url}?token=${store.state.jwt}`
|
url = `${protocol}//${window.location.hostname}${store.state.baseURL}/api/command${url}`
|
||||||
|
|
||||||
let conn = new window.WebSocket(url)
|
let conn = new window.WebSocket(url)
|
||||||
conn.onopen = () => conn.send(command)
|
conn.onopen = () => conn.send(command)
|
||||||
@ -156,7 +156,7 @@ function command (url, command, onmessage, onclose) {
|
|||||||
function search (url, search, onmessage, onclose) {
|
function search (url, search, onmessage, onclose) {
|
||||||
let protocol = (ssl ? 'wss:' : 'ws:')
|
let protocol = (ssl ? 'wss:' : 'ws:')
|
||||||
url = removePrefix(url)
|
url = removePrefix(url)
|
||||||
url = `${protocol}//${window.location.hostname}${store.state.baseURL}/api/search${url}?token=${store.state.jwt}`
|
url = `${protocol}//${window.location.hostname}${store.state.baseURL}/api/search${url}`
|
||||||
|
|
||||||
let conn = new window.WebSocket(url)
|
let conn = new window.WebSocket(url)
|
||||||
conn.onopen = () => conn.send(search)
|
conn.onopen = () => conn.send(search)
|
||||||
@ -181,8 +181,6 @@ function download (format, ...files) {
|
|||||||
url += `/?files=${arg}&`
|
url += `/?files=${arg}&`
|
||||||
}
|
}
|
||||||
|
|
||||||
url += `token=${store.state.jwt}`
|
|
||||||
|
|
||||||
if (format !== null) {
|
if (format !== null) {
|
||||||
url += `&format=${format}`
|
url += `&format=${format}`
|
||||||
}
|
}
|
||||||
|
8
auth.go
8
auth.go
@ -96,12 +96,12 @@ func (e extractor) ExtractToken(r *http.Request) (string, error) {
|
|||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
token, _ = request.ArgumentExtractor{"token"}.ExtractToken(r)
|
cookie, err := r.Cookie("auth")
|
||||||
if token != "" {
|
if err != nil {
|
||||||
return token, nil
|
return "", request.ErrNoTokenInRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", request.ErrNoTokenInRequest
|
return cookie.Value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateAuth is used to validate the authentication and returns the
|
// validateAuth is used to validate the authentication and returns the
|
||||||
|
Loading…
Reference in New Issue
Block a user