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

chore(*) make the authentication interface type oblivious #2271

Merged
merged 1 commit into from
Jul 2, 2021
Merged

chore(*) make the authentication interface type oblivious #2271

merged 1 commit into from
Jul 2, 2021

Conversation

jpeach
Copy link
Contributor

@jpeach jpeach commented Jul 2, 2021

Summary

There are two proxy types that can be authenticated and in the future there may be more. Rather than adding a new method for authenticating each proxy type, switch to authenticating a generic model Resource and allow each authenticator implentation to type switch internally.

This allows the xDS authentication callbacks to be insensitive to the DP proxy type, except when fetching an existing resource, which needs to allocate an instance of the concrete type.

The other approach I considered was making each Authenticator implementation responsible for a authenticating a single type, then using a factory interface to choose the right instance. I didn't go with that, since there was more scaffolding and the benefits over the internal type switch weren't very clear.

Full changelog

N/A

Issues resolved

N/A

Documentation

N/A

Testing

  • Unit tests
  • E2E tests
  • Manual testing on Universal
  • Manual testing on Kubernetes

@codecov-commenter
Copy link

Codecov Report

Merging #2271 (1dd0d59) into master (17666e4) will increase coverage by 0.31%.
The diff coverage is 51.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2271      +/-   ##
==========================================
+ Coverage   51.61%   51.92%   +0.31%     
==========================================
  Files         910      914       +4     
  Lines       41206    41241      +35     
==========================================
+ Hits        21268    21416     +148     
+ Misses      17901    17765     -136     
- Partials     2037     2060      +23     
Impacted Files Coverage Δ
pkg/xds/auth/k8s/authenticator.go 0.00% <0.00%> (ø)
pkg/xds/auth/universal/authenticator.go 76.19% <42.85%> (-6.67%) ⬇️
pkg/xds/auth/universal/noop_authenticator.go 50.00% <42.85%> (-16.67%) ⬇️
pkg/xds/auth/callbacks.go 81.81% <81.25%> (+5.52%) ⬆️
pkg/core/xds/metadata.go 62.16% <0.00%> (-2.71%) ⬇️
api/internal/util/proto/types.go 50.00% <0.00%> (ø)
...k8s/native/controllers/proxytemplate_controller.go 0.00% <0.00%> (ø)
...kg/plugins/resources/k8s/native/pkg/test/within.go 100.00% <0.00%> (ø)
api/internal/util/proto/proto.go 62.50% <0.00%> (ø)
pkg/xds/generator/direct_access_proxy_generator.go 81.57% <0.00%> (+1.31%) ⬆️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17666e4...1dd0d59. Read the comment docs.

There are two proxy types that can be authenticated and in the future
there may be more. Rather than adding a new method for authenticating
each proxy type, switch to authenticating a generic model Resource and
allow each authenticator implentation to type switch internally.

This allows the xDS authentication callbacks to be insensitive to the
DP proxy type, except when fetching an existing resource, which needs
to allocate an instance of the concrete type.

Signed-off-by: James Peach <james.peach@konghq.com>
@jpeach jpeach changed the title Chore/obliviate auth callbacks chore(*) make the authentication interface type oblivious Jul 2, 2021
@jpeach jpeach marked this pull request as ready for review July 2, 2021 04:22
@jpeach jpeach requested a review from a team as a code owner July 2, 2021 04:22
Copy link
Contributor

@lobkovilya lobkovilya left a comment

Choose a reason for hiding this comment

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

Nice! I really like the fact Authenticator interface is not ugly anymore

@jpeach jpeach merged commit d2710d6 into kumahq:master Jul 2, 2021
@jpeach jpeach deleted the chore/obliviate-auth-callbacks branch July 2, 2021 06:51
mergify bot pushed a commit that referenced this pull request Jul 5, 2021
There are two proxy types that can be authenticated and in the future
there may be more. Rather than adding a new method for authenticating
each proxy type, switch to authenticating a generic model Resource and
allow each authenticator implentation to type switch internally.

This allows the xDS authentication callbacks to be insensitive to the
DP proxy type, except when fetching an existing resource, which needs
to allocate an instance of the concrete type.

Signed-off-by: James Peach <james.peach@konghq.com>
(cherry picked from commit d2710d6)
jakubdyszkiewicz pushed a commit that referenced this pull request Jul 5, 2021
There are two proxy types that can be authenticated and in the future
there may be more. Rather than adding a new method for authenticating
each proxy type, switch to authenticating a generic model Resource and
allow each authenticator implentation to type switch internally.

This allows the xDS authentication callbacks to be insensitive to the
DP proxy type, except when fetching an existing resource, which needs
to allocate an instance of the concrete type.

Signed-off-by: James Peach <james.peach@konghq.com>
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.

None yet

4 participants