fix: remove ?url for image proxy

This commit is contained in:
httpjamesm 2023-02-02 19:15:55 -05:00
parent 7b80c55dd2
commit 15b843d46b
No known key found for this signature in database
3 changed files with 3 additions and 14 deletions

View File

@ -1,3 +1,3 @@
package config package config
var Version = "1.5" var Version = "1.5.1"

View File

@ -19,12 +19,6 @@ func GetImage(c *gin.Context) {
return return
} }
url := c.Query("url")
if url == "" {
c.String(400, "Missing url")
return
}
// validate the auth token // validate the auth token
token, err := jwt.ParseWithClaims(authorization, &types.ImageProxyClaims{}, func(token *jwt.Token) (interface{}, error) { token, err := jwt.ParseWithClaims(authorization, &types.ImageProxyClaims{}, func(token *jwt.Token) (interface{}, error) {
@ -51,11 +45,6 @@ func GetImage(c *gin.Context) {
return return
} }
if claims.ImageURL != url {
c.String(400, "Request & token mismatch")
return
}
if claims.Exp < time.Now().Unix() { if claims.Exp < time.Now().Unix() {
c.String(400, "Token expired") c.String(400, "Token expired")
return return
@ -63,7 +52,7 @@ func GetImage(c *gin.Context) {
// download the image // download the image
client := resty.New() client := resty.New()
resp, err := client.R().Get(url) resp, err := client.R().Get(claims.ImageURL)
if err != nil { if err != nil {
c.AbortWithStatus(500) c.AbortWithStatus(500)
return return

View File

@ -25,7 +25,7 @@ func ReplaceImgTags(inHtml string) string {
authToken, _ := generateImageProxyAuth(src) authToken, _ := generateImageProxyAuth(src)
// replace the img tag with a proxied url // replace the img tag with a proxied url
inHtml = strings.Replace(inHtml, imgTag, fmt.Sprintf(`<img src="%s/proxy?url=%s&auth=%s">`, os.Getenv("APP_URL"), src, authToken), 1) inHtml = strings.Replace(inHtml, imgTag, fmt.Sprintf(`<img src="%s/proxy?auth=%s">`, os.Getenv("APP_URL"), authToken), 1)
} }
return inHtml return inHtml