Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
126 lines
2.6 KiB
Go
126 lines
2.6 KiB
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/cortezaproject/corteza/server/system/service"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// Will perform OpenID connect auto-configuration
|
|
func Sink(ctx context.Context, app serviceInitializer) *cobra.Command {
|
|
var (
|
|
expires string
|
|
srup = service.SinkRequestUrlParams{}
|
|
)
|
|
|
|
cmd := &cobra.Command{
|
|
Use: "sink",
|
|
Short: "Sink",
|
|
}
|
|
|
|
signatureCmd := &cobra.Command{
|
|
Use: "signature",
|
|
Short: "Creates signature for sink HTTP endpoint",
|
|
PreRunE: commandPreRunInitService(app),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
if expires != "" {
|
|
// validate expiration date if set
|
|
if exp, err := time.Parse("2006-01-02", expires); err != nil {
|
|
return err
|
|
} else {
|
|
srup.Expires = &exp
|
|
}
|
|
}
|
|
|
|
if su, srup, err := service.DefaultSink.SignURL(srup); err != nil {
|
|
return err
|
|
} else {
|
|
cmd.Println(su)
|
|
|
|
cmd.Println("Sink request constraints:")
|
|
if srup.SignatureInPath {
|
|
cmd.Println(" - signature should be part of path")
|
|
} else {
|
|
cmd.Println(" - signature should be part of query-string")
|
|
}
|
|
|
|
if srup.Method != "" {
|
|
cmd.Printf(" - expecting request method %q\n", srup.Method)
|
|
|
|
}
|
|
if srup.Expires != nil {
|
|
cmd.Printf(" - signature expires at: %s\n", srup.Expires)
|
|
|
|
}
|
|
if srup.MaxBodySize > 0 {
|
|
cmd.Printf(" - max request body size is %d Kb\n", srup.MaxBodySize/1024)
|
|
|
|
} else {
|
|
cmd.Println(" - body size is not limited")
|
|
|
|
}
|
|
if srup.ContentType != "" {
|
|
cmd.Printf(" - expecting content type to be %q\n", srup.ContentType)
|
|
|
|
}
|
|
if srup.Path != "" {
|
|
cmd.Printf(" - valid path under /sink: %q\n", srup.Path)
|
|
|
|
}
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|
|
|
|
signatureCmd.Flags().StringVar(
|
|
&srup.Origin,
|
|
"origin",
|
|
"",
|
|
"Origin of the request (arbitrary string, optional)")
|
|
|
|
signatureCmd.Flags().StringVar(
|
|
&srup.ContentType,
|
|
"content-type",
|
|
"",
|
|
"Content type (optional)")
|
|
|
|
signatureCmd.Flags().StringVar(
|
|
&srup.Path,
|
|
"path",
|
|
"",
|
|
"Full sink request path (do not include /sink prefix, add / for just root)")
|
|
|
|
signatureCmd.Flags().StringVar(
|
|
&expires,
|
|
"expires",
|
|
"",
|
|
"Date of expiration (YYYY-MM-DD, optional)")
|
|
|
|
signatureCmd.Flags().StringVar(
|
|
&srup.Method,
|
|
"method",
|
|
"",
|
|
"HTTP method that will be used (optional)")
|
|
|
|
signatureCmd.Flags().Int64Var(
|
|
&srup.MaxBodySize,
|
|
"max-body-size",
|
|
0,
|
|
"Max allowed body size")
|
|
|
|
signatureCmd.Flags().BoolVar(
|
|
&srup.SignatureInPath,
|
|
"signature-in-path",
|
|
false,
|
|
"Include signature in a path instead of query string")
|
|
|
|
cmd.AddCommand(
|
|
signatureCmd,
|
|
)
|
|
|
|
return cmd
|
|
}
|