Trying to fix 403 on many requests #143
							parent
							
								
									52e12c0b23
								
							
						
					
					
						commit
						d48867f603
					
				| 
						 | 
				
			
			@ -49,12 +49,11 @@ export default {
 | 
			
		|||
    download: function () {
 | 
			
		||||
      let url = `${this.$store.state.baseURL}/api/download`
 | 
			
		||||
      url += this.req.url.slice(6)
 | 
			
		||||
      url += `?token=${this.$store.state.jwt}`
 | 
			
		||||
 | 
			
		||||
      return url
 | 
			
		||||
    },
 | 
			
		||||
    raw: function () {
 | 
			
		||||
      return `${this.download()}&inline=true`
 | 
			
		||||
      return `${this.download()}?&inline=true`
 | 
			
		||||
    },
 | 
			
		||||
    back: function (event) {
 | 
			
		||||
      let uri = url.removeLastDir(this.$route.path) + '/'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -145,7 +145,7 @@ function checksum (url, algo) {
 | 
			
		|||
function command (url, command, onmessage, onclose) {
 | 
			
		||||
  let protocol = (ssl ? 'wss:' : 'ws:')
 | 
			
		||||
  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)
 | 
			
		||||
  conn.onopen = () => conn.send(command)
 | 
			
		||||
| 
						 | 
				
			
			@ -156,7 +156,7 @@ function command (url, command, onmessage, onclose) {
 | 
			
		|||
function search (url, search, onmessage, onclose) {
 | 
			
		||||
  let protocol = (ssl ? 'wss:' : 'ws:')
 | 
			
		||||
  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)
 | 
			
		||||
  conn.onopen = () => conn.send(search)
 | 
			
		||||
| 
						 | 
				
			
			@ -181,8 +181,6 @@ function download (format, ...files) {
 | 
			
		|||
    url += `/?files=${arg}&`
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  url += `token=${store.state.jwt}`
 | 
			
		||||
 | 
			
		||||
  if (format !== null) {
 | 
			
		||||
    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
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	token, _ = request.ArgumentExtractor{"token"}.ExtractToken(r)
 | 
			
		||||
	if token != "" {
 | 
			
		||||
		return token, nil
 | 
			
		||||
	cookie, err := r.Cookie("auth")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", request.ErrNoTokenInRequest
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return "", request.ErrNoTokenInRequest
 | 
			
		||||
	return cookie.Value, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// validateAuth is used to validate the authentication and returns the
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue