From e0ea1c0b7c7d5056f29ea539b0ae376b65c96b5f Mon Sep 17 00:00:00 2001 From: djelusic Date: Tue, 8 Mar 2022 12:43:43 +0100 Subject: [PATCH] fix initial admin token --- node/api/setup/setup.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/node/api/setup/setup.go b/node/api/setup/setup.go index 6cbbc50..c26da1d 100644 --- a/node/api/setup/setup.go +++ b/node/api/setup/setup.go @@ -126,7 +126,6 @@ func (s *Setup) terraformCreate(req *dto.SetupRequest) (*dto.SetupResponse, erro AuthEnv: n.AuthEnv(), ResourceTags: n.ResourceTags(), } - var t string if n.GithubAuthEnabled() { publicKey, privateKey, err := token.KeyPair() if err != nil { @@ -134,12 +133,6 @@ func (s *Setup) terraformCreate(req *dto.SetupRequest) (*dto.SetupResponse, erro } data.PublicKey = publicKey data.PrivateKey = privateKey - t, err = token.JWT(privateKey, &domain.AccessTokenClaims{ - Node: n, - }, 7*24*time.Hour) - if err != nil { - return nil, err - } } tf, err := terraform.Setup(data) if err != nil { @@ -161,6 +154,15 @@ func (s *Setup) terraformCreate(req *dto.SetupRequest) (*dto.SetupResponse, erro if err := s.store.Put(domain.NodeConfigKey, n); err != nil { return nil, err } + var t string + if n.GithubAuthEnabled() { + t, err = token.JWT(data.PrivateKey, &domain.AccessTokenClaims{ + Node: n, + }, 7*24*time.Hour) + if err != nil { + return nil, err + } + } return &dto.SetupResponse{ APIGatewayRestURL: url, CliRole: cliRole,