Skip to content

Commit

Permalink
deploy: tigris statics: go back to hardcoded tokenizer
Browse files Browse the repository at this point in the history
  • Loading branch information
alichay committed Aug 27, 2024
1 parent e9ca121 commit d5a7c5e
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions internal/command/deploy/machines_tigrisstatics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io/fs"
"mime"
Expand Down Expand Up @@ -49,7 +48,8 @@ const (
// will forward requests upstream with HTTPS.
tigrisUrl = "http://" + tigrisHostname

// tokenizerUrl = "https://tokenizer.fly.io"
tokenizerUrl = "https://tokenizer.fly.io"
tokenizerSealKey = "3afdb665d93f741adc98a6cfecb36f1e02403a095e8efa921fd2321857011f42"
)

// TODO(allison): Delete the statics bucket when the app is deleted.
Expand Down Expand Up @@ -187,9 +187,11 @@ func (md *machineDeployment) staticsTokenizeTigrisSecrets(
AppID: &appId,
},
},
AllowedHosts: []string{tigrisHostname},
AllowedHosts: []string{fmt.Sprintf("%s.%s", md.tigrisStatics.bucket, tigrisHostname)},
}

fmt.Fprintf(iostreams.FromContext(ctx).Out, "Creating token valid for '%s'\n", input.AllowedHosts[0])

inputJson, err := json.Marshal(input)
if err != nil {
return "", err
Expand Down Expand Up @@ -220,23 +222,13 @@ type headerInjectTransport struct {
func (t *headerInjectTransport) RoundTrip(req *http.Request) (*http.Response, error) {
req.Header.Add("Proxy-Tokenizer", t.token)
req.Header.Add("Proxy-Authorization", t.macaroon)

return t.transport.RoundTrip(req)
}

// Create the tigris bucket if not created.
func (md *machineDeployment) staticsInitialize(ctx context.Context) error {

// TODO(allison): This is temporary debug code. Remove me.
tokenizerUrl := os.Getenv("FLY_TOKENIZER_URL")
if tokenizerUrl == "" {
return errors.New("please specify FLY_TOKENIZER_URL")
}
// TODO(allison): Pull this from somewhere sensible, such as an API on the Tokenizer directly?
tokenizerSealKey := os.Getenv("FLY_TOKENIZER_SEAL_KEY")
if tokenizerSealKey == "" {
return errors.New("please specify FLY_TOKENIZER_SEAL_KEY")
}

md.tigrisStatics.bucket = md.appConfig.AppName + "-statics"

if err := md.staticsEnsureBucketCreated(ctx, tokenizerSealKey); err != nil {
Expand Down

0 comments on commit d5a7c5e

Please sign in to comment.