Skip to content

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

Merged
Tener merged 31 commits into
masterfrom
tener/tctl-sso-gh
May 26, 2022
Merged

New commands: tctl sso test, tctl sso configure for GitHub#12783
Tener merged 31 commits into
masterfrom
tener/tctl-sso-gh

Conversation

@Tener
Copy link
Copy Markdown
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, smallinsky and xacrimon May 20, 2022 11:37
Comment thread api/types/github.go Outdated
Comment thread lib/auth/clt.go Outdated
Comment thread lib/auth/github.go
Comment thread tool/tctl/sso/tester/github.go Outdated
Comment thread tool/tctl/sso/tester/github.go Outdated
Comment thread tool/tctl/sso/tester/command.go Outdated
Comment thread tool/tctl/sso/tester/command.go
Comment thread tool/tctl/sso/tester/command.go Outdated
Comment thread tool/tctl/sso/configure/teams_to_logins.go Outdated
Comment thread tool/tctl/sso/configure/github.go Outdated
@Tener Tener requested a review from smallinsky May 24, 2022 08:24
@Tener
Copy link
Copy Markdown
Contributor Author

Tener commented May 25, 2022

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

Copy link
Copy Markdown
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.

Comment thread tool/tctl/sso/tester/command.go
Comment thread tool/tctl/sso/tester/command.go Outdated
Comment thread lib/auth/saml.go
Comment on lines +375 to 377
diagCtx.info.Error = trace.UserMessage(err)

diagCtx.writeToBackend(ctx)
Copy link
Copy Markdown
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
Copy Markdown
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?

Comment thread tool/tctl/sso/configure/github.go Outdated
Comment thread tool/tctl/sso/configure/github.go Outdated
Comment thread tool/tctl/sso/configure/teams_to_logins.go
Comment thread tool/tctl/sso/configure/github.go Outdated
Comment thread tool/tctl/sso/configure/github.go Outdated
Comment thread tool/tctl/sso/tester/command.go
Comment thread tool/tctl/sso/tester/command.go Outdated
@Tener Tener requested a review from smallinsky May 25, 2022 14:46
@Tener
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread lib/auth/clt.go

// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread lib/auth/github.go Outdated
Comment thread lib/auth/github_test.go Outdated
@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