From 70fbc8c7b0d65fd71878520e5cb14e4a494137fa Mon Sep 17 00:00:00 2001 From: Jacob Weisz Date: Sat, 24 Sep 2022 05:29:27 +0000 Subject: Add Sandstorm packaging files (#26) I am not quite done here, I need to finish some of the packaging metadata, and I am going to maybe take a pass at permissions prior to release. Opening the pull request so you can easily track the progress. Note that Sandstorm app metadata is supposed to be less than 1 MB total, so I optimized your screenshots. I dare you to tell the difference with the naked eye. Co-authored-by: Jacob Weisz Reviewed-on: https://git.mills.io/prologic/tube/pulls/26 Co-authored-by: Jacob Weisz Co-committed-by: Jacob Weisz --- app/app.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/app.go') diff --git a/app/app.go b/app/app.go index 6b89c5b..11b06f4 100644 --- a/app/app.go +++ b/app/app.go @@ -97,10 +97,15 @@ func NewApp(cfg *Config) (*App, error) { // Setup Router authPassword := os.Getenv("auth_password") + isSandstorm := os.Getenv("SANDSTORM") r := mux.NewRouter().StrictSlash(true) r.HandleFunc("/", a.indexHandler).Methods("GET", "OPTIONS") - r.HandleFunc("/upload", middleware.OptionallyRequireAdminAuth(a.uploadHandler, authPassword)).Methods("GET", "OPTIONS", "POST") + if isSandstorm == "1" { + r.HandleFunc("/upload", middleware.RequireSandstormPermission(a.uploadHandler, "upload")).Methods("GET", "OPTIONS", "POST") + } else { + r.HandleFunc("/upload", middleware.OptionallyRequireAdminAuth(a.uploadHandler, authPassword)).Methods("GET", "OPTIONS", "POST") + } r.HandleFunc("/import", a.importHandler).Methods("GET", "OPTIONS", "POST") r.HandleFunc("/v/{id}.mp4", a.videoHandler).Methods("GET") r.HandleFunc("/v/{prefix}/{id}.mp4", a.videoHandler).Methods("GET") -- cgit v1.2.3