Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New commands: tctl sso test, tctl sso configure for GitHub #12783

Merged
merged 31 commits into from
May 26, 2022

Conversation

Tener
Copy link
Contributor

@Tener Tener commented May 20, 2022

Follow up to:

This PR adds tclt sso configure github and tctl sso test commands. The commands are described in RFDs:

This is the last code piece of work for #9270. (Some work remains before we can close the issue entirely.)

This PR requires follow up changes in teleport.e, done under this PR: https://github.com/gravitational/teleport.e/pull/434

@github-actions github-actions bot added the tctl tctl - Teleport admin tool label May 20, 2022
@github-actions github-actions bot requested review from Joerger and zmb3 May 20, 2022 11:33
@Tener Tener requested review from r0mant, xacrimon and smallinsky May 20, 2022 11:37
api/types/github.go Outdated Show resolved Hide resolved
lib/auth/clt.go Outdated Show resolved Hide resolved
lib/auth/github.go Show resolved Hide resolved
tool/tctl/sso/tester/github.go Outdated Show resolved Hide resolved
tool/tctl/sso/tester/github.go Outdated Show resolved Hide resolved
tool/tctl/sso/tester/command.go Outdated Show resolved Hide resolved
tool/tctl/sso/tester/command.go Show resolved Hide resolved
tool/tctl/sso/tester/command.go Outdated Show resolved Hide resolved
tool/tctl/sso/configure/teams_to_logins.go Outdated Show resolved Hide resolved
tool/tctl/sso/configure/github.go Outdated Show resolved Hide resolved
@Tener Tener requested a review from smallinsky May 24, 2022 08:24
@Tener
Copy link
Contributor Author

Tener commented May 25, 2022

Kind reminder @Joerger @zmb3 @r0mant @xacrimon @smallinsky .

Copy link
Contributor

@smallinsky smallinsky left a comment

Choose a reason for hiding this comment

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

LGTM when remaining comments will be addressed.

tool/tctl/sso/tester/command.go Outdated Show resolved Hide resolved
tool/tctl/sso/tester/command.go Outdated Show resolved Hide resolved
Comment on lines +375 to 377
diagCtx.info.Error = trace.UserMessage(err)

diagCtx.writeToBackend(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we simplify this to:

diagCtx := a.newSSODiagContext(types.KindSAML)
defer diagCtx.writeToBackend(ctx)
auth, err := a.validateSAMLResponse(ctx, diagCtx, samlResponse)
if err != nil {
    diagCtx.info.Error = trace.UserMessage(err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh, I think the current code is simpler? We used to check against err, but trace.UserMessage handles that already, so the conditional is actually redundant.

diagCtx := m.newSSODiagContext(types.KindGithub)
auth, err := m.validateGithubAuthCallback(ctx, diagCtx, q)
diagCtx.info.Error = trace.UserMessage(err)
diagCtx.writeToBackend(ctx)

Personally, I think defer makes it harder to reason about the function. Do we really need it?

tool/tctl/sso/configure/github.go Outdated Show resolved Hide resolved
tool/tctl/sso/configure/github.go Outdated Show resolved Hide resolved
tool/tctl/sso/configure/teams_to_logins.go Show resolved Hide resolved
tool/tctl/sso/configure/github.go Outdated Show resolved Hide resolved
tool/tctl/sso/configure/github.go Outdated Show resolved Hide resolved
tool/tctl/sso/tester/command.go Show resolved Hide resolved
tool/tctl/sso/tester/command.go Outdated Show resolved Hide resolved
@Tener Tener requested a review from smallinsky May 25, 2022 14:46
@Tener
Copy link
Contributor Author

Tener commented May 25, 2022

@smallinsky thanks for review, hopefully I addressed your points; do let me know what you think about #12783 (comment)

Copy link
Contributor

@Joerger Joerger left a comment

Choose a reason for hiding this comment

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

Looks good overall, I'll give it another pass tomorrow

@@ -1254,9 +1254,22 @@ func (c *Client) CreateGithubAuthRequest(req services.GithubAuthRequest) (*servi
return &response, nil
}

// GetGithubAuthRequest gets Github AuthnRequest
func (c *Client) GetGithubAuthRequest(ctx context.Context, id string) (*services.GithubAuthRequest, error) {
out, err := c.Get(ctx, c.Endpoint("github", "requests", "get", id), url.Values{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason that this needs to be an http request rather than gRPC? lib/auth.Client is deprecated in favor of api/client.Client, which is the purely gRPC client - #6394

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding the gRPC endpoint would require adding the relevant types to .proto files and more refactoring besides. This is not necessarily the wrong thing to do, but I'm afraid it would balloon the size of this already large PR even more. Also, I think it would make sense to move all methods from a given group in one go, rather than have some implemented on HTTP side, and some on gRPC side.

Copy link
Contributor

@Joerger Joerger May 26, 2022

Choose a reason for hiding this comment

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

I think that making new http endpoints only makes things more confusing for developers. IMO it'd be better to take a hard lined approach of only adding new endpoints to gRPC, even if that fits less smoothly in the current code base. Otherwise we may have more instances of http endpoints being added needlessly, moving us further away from having a purely gRPC, public API, in one place.

Before this gets pushed to a release branch, we should move these new (and old) http endpoints to gRPC. I can create a follow up PR for this.

Copy link
Contributor Author

@Tener Tener May 26, 2022

Choose a reason for hiding this comment

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

Before this gets pushed to a release branch, we should move these new (and old) http endpoints to gRPC. I can create a follow up PR for this.

Sure, let's do it. There should be enough time before the v10 release to make this happen. This feature won't be merged to v9 either.

lib/auth/github.go Outdated Show resolved Hide resolved
lib/auth/github_test.go Outdated Show resolved Hide resolved
@Tener Tener enabled auto-merge (squash) May 26, 2022 21:10
@Tener Tener merged commit 9377f7c into master May 26, 2022
@Tener Tener deleted the tener/tctl-sso-gh branch July 22, 2022 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tctl tctl - Teleport admin tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants