Skip to content

auth: Remove Upsert/Delete from SAMLService interface#18634

Merged
camscale merged 3 commits intomasterfrom
camh/narrow-saml-interface
Nov 24, 2022
Merged

auth: Remove Upsert/Delete from SAMLService interface#18634
camscale merged 3 commits intomasterfrom
camh/narrow-saml-interface

Conversation

@camscale
Copy link
Copy Markdown
Contributor

@camscale camscale commented Nov 21, 2022

Remove the Upsert and Delete methods from the SAMLService interface. It
was intended for these to be part of the SAML "plugin", however they are
needed for the operator tests to be able to create and delete the SAML
connectors.

The methods are back to being implemented directly in the auth.Server.
This does not cause any real issues with the rest in the enterprise repo
as the upsert/delete logic is just manipulating the local backend with
no actual SAML logic in it. The Get* methods had already been kept in
the auth.Server for the same reason.

This narrows the SAMLService interface to just creating the SAML auth
request and validating the response that comes back from the SAML
identity provider. This is the core of the SAML-specific logic.

Issue: https://github.com/gravitational/teleport.e/issues/525

@camscale
Copy link
Copy Markdown
Contributor Author

@ravicious @smallinsky This PR will need to go in before I can merge https://github.com/gravitational/teleport.e/pull/597 and #18285

@camscale camscale force-pushed the camh/narrow-saml-interface branch from 3bb515c to 071c21e Compare November 21, 2022 06:03
@camscale
Copy link
Copy Markdown
Contributor Author

I've added @ravicious and @smallinsky as reviewers as this is part of the PR series that they have already reviewed - this is a last minute change that I could not make work within the other PRs (see linked issue for PRs).

Comment thread lib/auth/saml.go Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please wrap auth.ErrRequiresEnterprise here and anywhere else where you're checking for an enterprise license.

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.

Good catch. That's because I factored the error to the top-level, there's no (useful) trace information, so I should now wrap at the point the error is returned? Otherwise if I had return trace.AccessDenied(errMsg), that would wrap correctly?

Also, were you also asking me to rename the var? I'll rename to ErrSAMLRequiresEnterprise since the error message contains SAML (and will conflict with OIDC when I do that next).

Copy link
Copy Markdown
Collaborator

@zmb3 zmb3 Nov 23, 2022

Choose a reason for hiding this comment

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

No, not asking you to rename.

Basically I want errors.Is(err, ErrRequiresEnterprise) to return true for whatever err it is you return. This way we have a consistent way of checking whether an error is due to requiring enterprise without resorting to string comparisons.

So something like fmt.Errorf or trace.Wrap should do the trick.

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.

ack. sorry I went looking for ErrRequiresEnterprise but didn't find it - hence my confusion - I must have mistyped. Will update.

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.

done

@camscale
Copy link
Copy Markdown
Contributor Author

@zmb3 PTAL

Remove the Upsert and Delete methods from the SAMLService interface. It
was intended for these to be part of the SAML "plugin", however they are
needed for the operator tests to be able to create and delete the SAML
connectors.

The methods are back to being implemented directly in the `auth.Server`.
This does not cause any real issues with the rest in the enterprise repo
as the upsert/delete logic is just manipulating the local backend with
no actual SAML logic in it. The `Get*` methods had already been kept in
the `auth.Server` for the same reason.

This narrows the `SAMLService` interface to just creating the SAML auth
request and validating the response that comes back from the SAML
identity provider. This is the core of the SAML-specific logic.
Rename error variable to be more explicit, and ensure it is wrapped when
returned from a function.

Addresses: https://github.com/gravitational/teleport/pull/18634/files#r1029449563
@camscale camscale force-pushed the camh/narrow-saml-interface branch from 0ea5f94 to 550a864 Compare November 24, 2022 04:29
@camscale camscale merged commit 7656052 into master Nov 24, 2022
@camscale camscale deleted the camh/narrow-saml-interface branch April 6, 2023 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants