Skip to content

Core changes for "tctl sso test" command (SAML only).#10393

Closed
Tener wants to merge 8 commits into
masterfrom
tener/tsh-sso-test-pr
Closed

Core changes for "tctl sso test" command (SAML only).#10393
Tener wants to merge 8 commits into
masterfrom
tener/tsh-sso-test-pr

Conversation

@Tener
Copy link
Copy Markdown
Contributor

@Tener Tener commented Feb 16, 2022

These are the changes required for "tctl sso test" command. For now only implemented for SAML.

See: #9270 for original issue.

Actual command: https://github.com/gravitational/teleport.e/pull/398

Changes to trace library: gravitational/trace#74

@Tener Tener requested review from r0mant and smallinsky February 16, 2022 15:24
@Tener Tener marked this pull request as ready for review February 22, 2022 07:48
@github-actions github-actions Bot added the rfd Request for Discussion label Feb 22, 2022
@github-actions github-actions Bot requested a review from xacrimon February 22, 2022 07:49
Comment thread lib/auth/clt.go Outdated

// try to recover diagnostic info from proxy error
var di *SsoDiagnosticInfo
di = nil
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.

Di is already nil you don't need to reset it again.

Comment thread lib/auth/clt.go Outdated
di = nil

var ssoDi SsoDiagnosticInfo
if trace.UnwrapProxyField(err, "sso-diag-info", &ssoDi) {
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.

missing error check.

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.

UnwrapProxyField returns boolean, not an error?

Comment thread lib/auth/saml.go
Comment on lines +458 to +459
di.SetProblem("Failed to parse SAML response", err)
return nil, di, trace.Wrap(err)
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.

Does the di needs to be returned with err != nil

What about decoupling error message and successful fileds from SsoDiagnosticInfo
and proagating error to the http caller by return nil, trace.Wrap(err).WithField(SSODiagnosticErrors, di)

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.

Does the di needs to be returned with err != nil

Yeah, it does, that is part of the difficulty here. For example, even though the user has logged in successfully with SSO they may still be interested in the list of roles they were assigned along with the claims returned from IdP. The point of having SsoDiagnosticInfo is so we don't have to go around hunting for the data that we need. The UnwrapProxyField is really an unfortunate corner case rather than something I'd like to use elsewhere.

Comment thread lib/auth/apiserver.go
response, di, err := auth.ValidateSAMLResponse(req.Response)
if err != nil {
return nil, trace.Wrap(err)
return nil, trace.Wrap(err).AddField("sso-diag-info", di)
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 di field can be propagated by the auth.ValidateSAMLResponse handler. So the auth.ValidateSAMLResponse will return only response and err where err will have preset diagnostic ErrorField

@Tener Tener requested a review from smallinsky February 23, 2022 12:53
@xacrimon
Copy link
Copy Markdown
Contributor

xacrimon commented Feb 24, 2022

If this involved interacting with any SAML response data from a third party IdP like Azure AD (which it seems to do), please make sure that this also works when Azure AD Encrypted SAML is enabled. That part of the standard sometimes behaves wierdly and usually needs to be manually tested when making SAML changes.

@Tener
Copy link
Copy Markdown
Contributor Author

Tener commented Feb 25, 2022

If this involved interacting with any SAML response data from a third party IdP like Azure AD (which it seems to do), please make sure that this also works when Azure AD Encrypted SAML is enabled. That part of the standard sometimes behaves wierdly and usually needs to be manually tested when making SAML changes.

Thanks for the tip, I'll make sure to go through that flow.

@Tener
Copy link
Copy Markdown
Contributor Author

Tener commented Mar 29, 2022

Switching to another PR: #11508

@Tener Tener closed this Mar 29, 2022
@Tener Tener deleted the tener/tsh-sso-test-pr branch July 22, 2022 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rfd Request for Discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants