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

Add backend Service and Cache support for SPIFFE Federation resource #45054

Merged
merged 16 commits into from
Aug 12, 2024

Conversation

strideynet
Copy link
Contributor

@strideynet strideynet commented Aug 5, 2024

Part of #44861
As per #43348

Adds the local service implementation for SPIFFE Federation and support for this in the Cache used by the Auth Server.

Notably, I've broken out the cache additions for this resource into it's own file rather than appending to the rather unwieldy collections.go. I'm hoping we can kick off a bit of a trend here 😅

@strideynet strideynet force-pushed the strideynet/add-backend-cache-for-spiffe-federation branch from 0454551 to 6c02c18 Compare August 5, 2024 11:40
Base automatically changed from strideynet/add-protos-for-spiffe-federation to master August 5, 2024 15:27
@strideynet strideynet force-pushed the strideynet/add-backend-cache-for-spiffe-federation branch from 12a1f47 to 89f7816 Compare August 6, 2024 08:24
@strideynet strideynet force-pushed the strideynet/add-backend-cache-for-spiffe-federation branch from 89f7816 to 7c8a4b8 Compare August 6, 2024 08:26
@strideynet
Copy link
Contributor Author

Waiting on #45058 to merge to let us tidy this up a little more.

@strideynet strideynet added the no-changelog Indicates that a PR does not require a changelog entry label Aug 8, 2024
@strideynet strideynet marked this pull request as ready for review August 8, 2024 08:39
@@ -132,6 +132,7 @@ require (
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

another go-jose version 😢

@@ -94,6 +94,7 @@ type Config struct {
SAMLIdPSession services.SAMLIdPSession
SecReports services.SecReports
SnowflakeSession services.SnowflakeSession
SPIFFEFederations cache.SPIFFEFederationReader
Copy link
Contributor

Choose a reason for hiding this comment

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

any special reason to store the interface in the cache package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the cache's dependency. In this case, had I used services.SPIFFEFederations, I'd be requiring methods which are not required by the cache to function (e.g the write side)

I'd usually have this kind of interfaces unexported, but, there's a bit of a weird case here where the functionality in accesspoint really feels like it belongs elsewhere. It's essentially a weird extension of the cache package itself. I'd considered redeclaring SPIFFEFederationsReader within accesspoint, but, I think that there's a better solution down the road (e.g a accesspoint.UpstreamReaders struct which holds the interfaces that the cache uses to populate).

Largely, I'm trying to play with the idea that the services.FoosService interfaces are unnecessary and problematic. We've see the symptoms of this across our codebase: weirdly named interfaces with "Ext" or "Internal" and methods that just return NotImplemented hung off "wrapper" structs that embed some other type that only partially implements an interface.

I thought about having services.SPIFFEFederationsReader, but it seems to really be the same problem, we should be aiming to create interfaces where they are consumed, not where they are implemented, and to have these interfaces declare the minimum amount of methods. If we think it's not the right time to start solving this problem, then I'm happy to create services.SPIFFEFederationsReader and use that, but I feel like that's just prolonging us ever solving this problem.

lib/services/spiffe_federations.go Outdated Show resolved Hide resolved
@strideynet strideynet requested review from timothyb89 and removed request for espadolini August 8, 2024 12:24
@strideynet strideynet added this pull request to the merge queue Aug 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 12, 2024
@strideynet strideynet added this pull request to the merge queue Aug 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 12, 2024
@strideynet strideynet added this pull request to the merge queue Aug 12, 2024
Merged via the queue into master with commit 797fc69 Aug 12, 2024
38 checks passed
@strideynet strideynet deleted the strideynet/add-backend-cache-for-spiffe-federation branch August 12, 2024 12:43
@public-teleport-github-review-bot

@strideynet See the table below for backport results.

Branch Result
branch/v15 Failed
branch/v16 Failed

strideynet added a commit that referenced this pull request Aug 12, 2024
…45054)

* Start adding `lib/services` content for SPIFFEFederation type

* Add SPIFFEFederation resource to cache

* Wire SPIFFEFederation into cache

* Fix NewTestAuthServer

* Start writing tests

* Add more test cases to validation

* Add tests to cache for SPIFFEFederation

* More test coverage

* Add test for DeleteSPIFFEFederations

* Finish off tests for SPIFFEFederation resource

* go mod tidy

* Go mod tidy

* Appease linter

* Avoid forcing kind/version in MarshalSPIFFEFederation

* more linter appeasal
strideynet added a commit that referenced this pull request Aug 13, 2024
…45054)

* Start adding `lib/services` content for SPIFFEFederation type

* Add SPIFFEFederation resource to cache

* Wire SPIFFEFederation into cache

* Fix NewTestAuthServer

* Start writing tests

* Add more test cases to validation

* Add tests to cache for SPIFFEFederation

* More test coverage

* Add test for DeleteSPIFFEFederations

* Finish off tests for SPIFFEFederation resource

* go mod tidy

* Go mod tidy

* Appease linter

* Avoid forcing kind/version in MarshalSPIFFEFederation

* more linter appeasal
github-merge-queue bot pushed a commit that referenced this pull request Aug 14, 2024
…ource (#45054) (#45384)

* Add backend Service and Cache support for SPIFFE Federation resource (#45054)

* Start adding `lib/services` content for SPIFFEFederation type

* Add SPIFFEFederation resource to cache

* Wire SPIFFEFederation into cache

* Fix NewTestAuthServer

* Start writing tests

* Add more test cases to validation

* Add tests to cache for SPIFFEFederation

* More test coverage

* Add test for DeleteSPIFFEFederations

* Finish off tests for SPIFFEFederation resource

* go mod tidy

* Go mod tidy

* Appease linter

* Avoid forcing kind/version in MarshalSPIFFEFederation

* more linter appeasal

* Go mod tidily

* Fix imports

* Forgot to remove merge conflict boundary
jiml-cookie pushed a commit to cookieai-jar/teleport that referenced this pull request Sep 6, 2024
…ource (gravitational#45054) (gravitational#45412)

* Add backend Service and Cache support for SPIFFE Federation resource (gravitational#45054)

* Start adding `lib/services` content for SPIFFEFederation type

* Add SPIFFEFederation resource to cache

* Wire SPIFFEFederation into cache

* Fix NewTestAuthServer

* Start writing tests

* Add more test cases to validation

* Add tests to cache for SPIFFEFederation

* More test coverage

* Add test for DeleteSPIFFEFederations

* Finish off tests for SPIFFEFederation resource

* go mod tidy

* Go mod tidy

* Appease linter

* Avoid forcing kind/version in MarshalSPIFFEFederation

* more linter appeasal

* Ignore ID change in cache tests

* Go mod tidy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v15 backport/branch/v16 no-changelog Indicates that a PR does not require a changelog entry size/lg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants