diff --git a/go.mod b/go.mod index fee2abf1b91..bf2f2873e6f 100644 --- a/go.mod +++ b/go.mod @@ -39,8 +39,8 @@ require ( github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a github.com/wk8/go-ordered-map/v2 v2.1.8 github.com/zealic/go2node v0.1.0 - go.jetpack.io/envsec v0.0.16-0.20240111222345-e1fd0e1204ca - go.jetpack.io/pkg v0.0.0-20240108193620-a28b84329d15 + go.jetpack.io/envsec v0.0.16-0.20240214025624-d233cf877eec + go.jetpack.io/pkg v0.0.0-20240213204231-ec96be3d78fb golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 golang.org/x/mod v0.15.0 golang.org/x/sync v0.6.0 diff --git a/go.sum b/go.sum index d5ae011b051..54406436477 100644 --- a/go.sum +++ b/go.sum @@ -363,8 +363,12 @@ github.com/zealic/go2node v0.1.0 h1:ofxpve08cmLJBwFdI0lPCk9jfwGWOSD+s6216x0oAaA= github.com/zealic/go2node v0.1.0/go.mod h1:GrkFr+HctXwP7vzcU9RsgtAeJjTQ6Ud0IPCQAqpTfBg= go.jetpack.io/envsec v0.0.16-0.20240111222345-e1fd0e1204ca h1:7Ocnr+mVZTCG8MHlcAdW5d8ir7eqZTmD8S/aEskjXWk= go.jetpack.io/envsec v0.0.16-0.20240111222345-e1fd0e1204ca/go.mod h1:kCgRGNSHU5AgQXQGUenohPPDoUd87SRL00uOzQsa+Q8= +go.jetpack.io/envsec v0.0.16-0.20240214025624-d233cf877eec h1:IvdOF1C8tAxvKEauWBd/4IWXZfeyXh5vmcfTrcTBPvQ= +go.jetpack.io/envsec v0.0.16-0.20240214025624-d233cf877eec/go.mod h1:koTmI1q2QKqtxaX4P/7r5ygODwgJQ56FKoKRfzpZ0bM= go.jetpack.io/pkg v0.0.0-20240108193620-a28b84329d15 h1:ztX3CydpNKLePPMRmWgdi4HcxE/AXY6HViOJOmmYNiA= go.jetpack.io/pkg v0.0.0-20240108193620-a28b84329d15/go.mod h1:kGUL8aZ7ddvoGro0AQxXos9GKn5Qw0J18qW7d5FP4Ws= +go.jetpack.io/pkg v0.0.0-20240213204231-ec96be3d78fb h1:ELaZEV3BL+/GDfPxWPXt6ODNig/VlywWhfAC4P8EG5A= +go.jetpack.io/pkg v0.0.0-20240213204231-ec96be3d78fb/go.mod h1:kGUL8aZ7ddvoGro0AQxXos9GKn5Qw0J18qW7d5FP4Ws= go.jetpack.io/typeid v1.0.0 h1:8gQ+iYGdyiQ0Pr40ydSB/PzMOIwlXX5DTojp1CBeSPQ= go.jetpack.io/typeid v1.0.0/go.mod h1:+UPEaECUgFxgAjFPn5Yf9eO/3ft/3xZ98Eahv9JW/GQ= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= diff --git a/internal/boxcli/auth.go b/internal/boxcli/auth.go index 19f34b8868f..c3c7c65738a 100644 --- a/internal/boxcli/auth.go +++ b/internal/boxcli/auth.go @@ -38,7 +38,7 @@ func loginCmd() *cobra.Command { Short: "Login to devbox", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { - c, err := auth.NewClient(build.Issuer(), build.ClientID(), scopes) + c, err := newAuthClient() if err != nil { return err } @@ -60,7 +60,7 @@ func logoutCmd() *cobra.Command { Short: "Logout from devbox", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { - c, err := auth.NewClient(build.Issuer(), build.ClientID(), scopes) + c, err := newAuthClient() if err != nil { return err } @@ -110,9 +110,18 @@ func whoAmICmd() *cobra.Command { } func genSession(ctx context.Context) (*session.Token, error) { - c, err := auth.NewClient(build.Issuer(), build.ClientID(), scopes) + c, err := newAuthClient() if err != nil { return nil, err } return c.GetSession(ctx) } + +func newAuthClient() (*auth.Client, error) { + return auth.NewClient( + build.Issuer(), + build.ClientID(), + scopes, + build.SuccessRedirect(), + ) +} diff --git a/internal/build/build.go b/internal/build/build.go index c28e7d6bdf8..8f07fc3d090 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -80,3 +80,10 @@ func JetpackAPIHost() string { } return "https://api.jetpack.io" } + +func SuccessRedirect() string { + if IsDev { + return "https://auth.jetpack.dev/account/login/success" + } + return "https://auth.jetpack.io/account/login/success" +}