Skip to content

Commit

Permalink
[preprocessor/webhook] add browsertrix qs secret in config
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Jun 18, 2024
1 parent cba5e97 commit 32a6628
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ type Config struct {
NftContractAddress string `toml:"nft_contract_address"`
} `toml:"numbers"`
Browsertrix struct {
User string `toml:"user"`
Password string `toml:"password"`
User string `toml:"user"`
Password string `toml:"password"`
WebhookSecret string `toml:"webhook_secret"`
} `toml:"browsertrix"`
}

Expand Down
1 change: 1 addition & 0 deletions example_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ nft_contract_address = "0xabc" # Optional
# app.browsertrix.com
user = "user"
password = "password"
webhook_secret = "random_string" # A random string defined by us for auth in qs
6 changes: 6 additions & 0 deletions webhook/browsertrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ type CrawlMetadata struct {
}

func handleBrowsertrixEvent(w http.ResponseWriter, r *http.Request) {
webhookSecret := r.URL.Query().Get("s")
if webhookSecret != config.GetConfig().Browsertrix.WebhookSecret {
writeJsonResponse(w, http.StatusUnauthorized, map[string]string{"error": "invalid secret"})
return
}

var e BrowsertrixCrawlFinishedResponse
defer r.Body.Close()
data, err := io.ReadAll(r.Body)
Expand Down

0 comments on commit 32a6628

Please sign in to comment.