Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

feat(sg): add command to generate a dotcom user gateway access token#63125

Merged
janhartman merged 5 commits intomainfrom
jan/sg-gen-gateway-access-token-cmd
Jun 7, 2024
Merged

feat(sg): add command to generate a dotcom user gateway access token#63125
janhartman merged 5 commits intomainfrom
jan/sg-gen-gateway-access-token-cmd

Conversation

@janhartman
Copy link
Contributor

@janhartman janhartman commented Jun 6, 2024

We can now generate gateway access tokens from sg instead of having to manually wrangle a script to do it every time. This will help with making Cody Gateway easier to run locally.

Test plan

Tested locally.

@cla-bot cla-bot bot added the cla-signed label Jun 6, 2024
@janhartman janhartman requested review from a team and rafax June 6, 2024 15:00
)

func genGatewayAccessTokenExec(c *cli.Context) error {
accessToken, err := accesstoken.GenerateDotcomUserGatewayAccessToken(c.Args().Get(0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
accessToken, err := accesstoken.GenerateDotcomUserGatewayAccessToken(c.Args().Get(0))
// we use the current binary name (ie. `sg`) as the token prefix since that is required for the token to be generated
tokenPrefix := c.Args().Get(0)
accessToken, err := accesstoken.GenerateDotcomUserGatewayAccessToken(tokenPrefix)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the token prefix though - inside the 0-th arg we have the full sgp_local token.

Copy link
Contributor

@burmudar burmudar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

Few small comments!

@janhartman janhartman requested a review from burmudar June 6, 2024 16:59
@burmudar
Copy link
Contributor

burmudar commented Jun 7, 2024

@janhartman added some improvements here https://github.com/sourcegraph/sourcegraph/pull/63149

janhartman and others added 3 commits June 7, 2024 12:14
Add some messaging around generating a token as well as when arguments
are missing


## Test plan
Tested locally

## Changelog
@janhartman janhartman enabled auto-merge (squash) June 7, 2024 10:37
@janhartman
Copy link
Contributor Author

@burmudar mind approving so we can merge?

@janhartman janhartman merged commit aa615bc into main Jun 7, 2024
@janhartman janhartman deleted the jan/sg-gen-gateway-access-token-cmd branch June 7, 2024 10:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants