diff --git a/cmd/cloudx/client/handler.go b/cmd/cloudx/client/handler.go index 8e949309..55e0e48c 100644 --- a/cmd/cloudx/client/handler.go +++ b/cmd/cloudx/client/handler.go @@ -235,8 +235,14 @@ func (h *CommandHelper) HasValidContext() (*AuthContext, bool, error) { sess, _, err := client.FrontendApi.ToSession(h.Ctx).XSessionToken(c.SessionToken).Execute() if err != nil { + if h.IsQuiet { + return nil, false, errors.WithStack(ErrNoConfigQuiet) + } return nil, false, nil } else if sess == nil { + if h.IsQuiet { + return nil, false, errors.WithStack(ErrNoConfigQuiet) + } return nil, false, nil } return c, true, nil diff --git a/cmd/cloudx/proxy/proxy.go b/cmd/cloudx/proxy/proxy.go index 721d544a..a5e2b012 100644 --- a/cmd/cloudx/proxy/proxy.go +++ b/cmd/cloudx/proxy/proxy.go @@ -266,15 +266,15 @@ func run(cmd *cobra.Command, conf *config, version string, name string) error { }) if conf.isTunnel { - _, _ = fmt.Fprintf(os.Stderr, `To access Ory's APIs, use URL + _, _ = fmt.Fprintf(cmd.ErrOrStderr(), `To access Ory's APIs, use URL - %s + %[1]s and configure your SDKs to point to it, for example in JavaScript: import { V0alpha2Api, Configuration } from '@ory/client' const ory = new V0alpha2Api(new Configuration({ - basePath: 'http://localhost:4000', + basePath: '%[1]s', baseOptions: { withCredentials: true } @@ -282,7 +282,7 @@ and configure your SDKs to point to it, for example in JavaScript: `, conf.publicURL.String()) } else { - _, _ = fmt.Fprintf(os.Stderr, `To access your application via the Ory Proxy, open: + _, _ = fmt.Fprintf(cmd.ErrOrStderr(), `To access your application via the Ory Proxy, open: %s `, conf.publicURL.String()) @@ -290,15 +290,15 @@ and configure your SDKs to point to it, for example in JavaScript: if !conf.noOpen { // #nosec G204 - this is ok - if err := exec.Command("open", conf.publicURL.String()).Run(); err != nil { - _, _ = fmt.Fprintf(os.Stderr, "Unable to automatically open the proxy URL in your browser. Please open it manually!") + if err := exec.Command("open", fmt.Sprintf("%q", conf.publicURL.String())).Run(); err != nil { + _, _ = fmt.Fprintln(cmd.ErrOrStderr(), "Unable to automatically open the proxy URL in your browser. Please open it manually!") } } if err := graceful.Graceful(func() error { return server.ListenAndServe() }, func(ctx context.Context) error { - _, _ = fmt.Fprintf(os.Stderr, "http server was shutdown gracefully\n") + _, _ = fmt.Fprintln(cmd.ErrOrStderr(), "http server was shutdown gracefully") if err := server.Shutdown(ctx); err != nil { return err } diff --git a/go.mod b/go.mod index c3033f6c..c2cd7c3e 100644 --- a/go.mod +++ b/go.mod @@ -216,7 +216,7 @@ require ( github.com/ory/go-acc v0.2.9-0.20230103102148-6b1c9a70dbbe // indirect github.com/ory/go-convenience v0.1.0 // indirect github.com/ory/keto/proto v0.11.1-alpha.0 // indirect - github.com/ory/kratos-client-go v1.0.0 // indirect + github.com/ory/kratos-client-go v0.13.1 // indirect github.com/ory/mail/v3 v3.0.0 // indirect github.com/ory/nosurf v1.2.7 // indirect github.com/pborman/uuid v1.2.1 // indirect diff --git a/go.sum b/go.sum index 1fd465d8..ec18f6be 100644 --- a/go.sum +++ b/go.sum @@ -908,8 +908,8 @@ github.com/ory/keto/proto v0.11.1-alpha.0.0.20231229091411-ac44cabd79b7 h1:qHgWD github.com/ory/keto/proto v0.11.1-alpha.0.0.20231229091411-ac44cabd79b7/go.mod h1:6RagCXA7X1hhFSVjcy13ruIo8Dq/nj4J0mcN92qL+hY= github.com/ory/kratos v1.0.1-0.20240103153653-435d97e85f5e h1:tqYHVTlQ2a4pFESq/miUEnkyFQwB83apJOhSrdcjaas= github.com/ory/kratos v1.0.1-0.20240103153653-435d97e85f5e/go.mod h1:8CnmDmBUkWeGSd9fB9MG+sH5Y8msJVVl+avY2TZgTDI= -github.com/ory/kratos-client-go v1.0.0 h1:mm32FMJrt4pBv2KEuhuNtiewJApc8c1Kmz0+WFHhOMA= -github.com/ory/kratos-client-go v1.0.0/go.mod h1:a2Tl4cgQAxsjR59w3EfnH5hengabjXUHiEVDzdqiZI0= +github.com/ory/kratos-client-go v0.13.1 h1:o+pFV9ZRMFSBa4QeNJYbJeLz036UWU4p+7yfKghK+0E= +github.com/ory/kratos-client-go v0.13.1/go.mod h1:hkrFJuHSBQw+qN6Ks0faOAYhAKwtpjvhCZzsQ7g/Ufc= github.com/ory/mail v2.3.1+incompatible/go.mod h1:87D9/1gB6ewElQoN0lXJ0ayfqcj3cW3qCTXh+5E9mfU= github.com/ory/mail/v3 v3.0.0 h1:8LFMRj473vGahFD/ntiotWEd4S80FKYFtiZTDfOQ+sM= github.com/ory/mail/v3 v3.0.0/go.mod h1:JGAVeZF8YAlxbaFDUHqRZAKBCSeW2w1vuxf28hFbZAw=