Émettez une URL signée dans Golang.
import sign "github.com/aws/aws-sdk-go/service/cloudfront/sign"
func main() {
type CFConfig struct {
KeyID string
Domain string
KeyPath string
}
// cloud front config
cfConf := &model.CFConfig{
KeyID: "xxxxxxxxxxxxCQ"
Domain: "http://xxx.cloudfront.net",
KeyPath: "key/xxxxxxxxxxxxCQ",
}
privKey, err := sign.LoadPEMPrivKeyFile(r.cfConf.KeyPath)
if err != nil {
log.Println("failed to load pem file:", err)
return "", err
}
keyID := r.cfConf.KeyID
signer := sign.NewURLSigner(keyID, privKey)
path := "s3 Chemin du contenu auquel vous souhaitez autoriser l'accès"
signedURL, err := signer.Sign(r.cfConf.Domain+path, time.Now().Add(1*time.Hour))
if err != nil {
log.Fatalf("Failed to sign url, err: %s\n", err.Error())
}
return signedURL, err
}