Skip to content

Commit

Permalink
Check endpoint validity for pre-signed URLs (#1027)
Browse files Browse the repository at this point in the history
Closes #1025.
  • Loading branch information
roman-khimov authored Nov 25, 2024
2 parents 811d52f + d817ab3 commit 9c44b1a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/s3-authmate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"os"
"os/signal"
"runtime"
Expand Down Expand Up @@ -477,6 +478,15 @@ It will be ceil rounded to the nearest amount of epoch.`,
})
}

u, err := url.Parse(endpointFlag)
if err != nil {
return fmt.Errorf("invalid endpoint %q: %w", endpointFlag, err)
}

if u.Scheme != "http" && u.Scheme != "https" {
return fmt.Errorf("invalid endpoint %[1]q, you must specify scheme. For instance: http://%[1]s or https://%[1]s", endpointFlag, err)
}

sess, err := session.NewSessionWithOptions(session.Options{
Config: cfg,
Profile: profileFlag,
Expand Down

0 comments on commit 9c44b1a

Please sign in to comment.