diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 92b206f..4b158b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,10 +20,10 @@ repos: rev: 3.0.0 hooks: - id: alejandra-system - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.3 - hooks: - - id: prettier + # - repo: https://github.com/pre-commit/mirrors-prettier + # rev: v3.0.3 + # hooks: + # - id: prettier - repo: local hooks: - id: swag diff --git a/config.go b/config.go index fd09915..bbe9847 100644 --- a/config.go +++ b/config.go @@ -63,6 +63,7 @@ type Config struct { AllowChangingPlayerName bool AllowMultipleAccessTokens bool AllowSkins bool + AllowTextureFromURL bool ApplicationOwner string ApplicationName string BaseURL string @@ -108,6 +109,7 @@ func DefaultConfig() Config { AllowCapes: true, AllowChangingPlayerName: true, AllowSkins: true, + AllowTextureFromURL: false, ApplicationName: "Drasl", ApplicationOwner: "Anonymous", BaseURL: "", diff --git a/user.go b/user.go index 2450eeb..0e765f9 100644 --- a/user.go +++ b/user.go @@ -449,6 +449,9 @@ func (app *App) UpdateUser( } if skinURL != nil { + if !app.Config.AllowTextureFromURL && !callerIsAdmin { + return User{}, NewBadRequestUserError("Setting a skin from a URL is not allowed.") + } res, err := MakeHTTPClient().Get(*skinURL) if err != nil { return User{}, NewBadRequestUserError("Couldn't download skin from that URL: %s", err) @@ -481,6 +484,9 @@ func (app *App) UpdateUser( return User{}, NewBadRequestUserError("Can't specify both a cape file and a cape URL.") } if capeURL != nil { + if !app.Config.AllowTextureFromURL && !callerIsAdmin { + return User{}, NewBadRequestUserError("Setting a cape from a URL is not allowed.") + } res, err := MakeHTTPClient().Get(*capeURL) if err != nil { return User{}, NewBadRequestUserError("Couldn't download cape from that URL: %s", err) diff --git a/view/profile.tmpl b/view/profile.tmpl index 7c443d6..6c1d6c8 100644 --- a/view/profile.tmpl +++ b/view/profile.tmpl @@ -352,19 +352,21 @@ {{ if or .App.Config.AllowSkins .User.IsAdmin }}

Skin

-
- -

-

-
+

+ {{ if or .App.Config.AllowTextureFromURL .User.IsAdmin }} +

+
+ +

+ {{ end }}

Cape

-
- -

-

-
+

+ {{ if or .App.Config.AllowTextureFromURL .User.IsAdmin }} +

+
+ +

+ {{ end }}