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

Operator: Adds authorization to the operator API #7111

Merged
merged 10 commits into from Jan 11, 2024

Conversation

JoshVanL
Copy link
Contributor

@JoshVanL JoshVanL commented Oct 30, 2023

Today, the operator does no authorization on clients making requests for
resources. This means that it is currently possible for any
authenticated client to get any Component/HTTPEndpoint/Resiliency in any
namespace. This includes the ability for any client is able to get
Dapr secrets in any namespace.

PR updates the operator to add authorization to the operator API. The
API server will ensure that the client's identity (SPIFFE ID) resides in
the same namespace as the requested resource namespace. This is done by
parsing the clients SPIFFE SVID of the mTLS connection.

If the client does not reside in the same namespace, then the request is
rejected with a permission denied.


The health server has been updated so that a target number can be given
where the health server will only return healthy once the consumer has
given the target number of healthy calls. This is useful for the
operator so that the operator only reports healthy once all informers
and servers have started. Without this change, clients would attempt to
connect to the API server when it wasn't actually ready to serve
requests. This was surfaced in the integration tests.

The PR adds an authz operator integration test which proves that the API
server will only honour requests with clients in the appropriate
namespace.

The Kubernetes intergration process now has the ability to serve
HTTP/2.0 informer requests from the API server controller runtime
informers- added so that informer reliant functions (ComponentUpdate,
HTTPEndpointUpdate, etc.) can be handled.

Updates tests/util/pki so that it can respond with a context which
includes the SPIFFE ID of the client, used for operator authz unit
tests.

Signed-off-by: joshvanl me@joshvanl.dev


Part of #5756

@JoshVanL JoshVanL requested review from a team as code owners October 30, 2023 14:27
@JoshVanL JoshVanL marked this pull request as draft October 30, 2023 14:27
@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Attention: 23 lines in your changes are missing coverage. Please review.

Comparison is base (7471909) 64.45% compared to head (22b55da) 64.46%.
Report is 1 commits behind head on master.

Files Patch % Lines
pkg/health/server.go 0.00% 9 Missing ⚠️
pkg/operator/operator.go 0.00% 8 Missing ⚠️
pkg/operator/api/api.go 66.66% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7111      +/-   ##
==========================================
+ Coverage   64.45%   64.46%   +0.01%     
==========================================
  Files         236      237       +1     
  Lines       21669    21704      +35     
==========================================
+ Hits        13966    13991      +25     
- Misses       6504     6512       +8     
- Partials     1199     1201       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JoshVanL JoshVanL marked this pull request as ready for review November 18, 2023 17:04
@JoshVanL JoshVanL added this to the v1.13 milestone Nov 28, 2023
@JoshVanL JoshVanL added the autoupdate DaprBot will keep the Pull Request up to date with master branch label Nov 28, 2023
@JoshVanL
Copy link
Contributor Author

/test-version-skew

@dapr-bot
Copy link
Collaborator

dapr-bot commented Nov 29, 2023

Dapr Version Skew test (dapr-sidecar-master - 1.12.2)

🔗 Link to Action run

Commit ref: ff7bf61

❌ Version Skew tests failed

Please check the logs for details on the error.

@dapr-bot
Copy link
Collaborator

dapr-bot commented Nov 29, 2023

Dapr Version Skew test (control-plane-master - 1.12.2)

🔗 Link to Action run

Commit ref: ff7bf61

❌ Version Skew tests failed

Please check the logs for details on the error.

Today, the operator does no authorization on clients making requests for
resources. This means that it is currently possible for any
authenticated client to get any Component/HTTPEndpoint/Resiliency in any
namespace. This includes the ability for any client is able to get
Dapr secrets in any namespace.

PR updates the operator to add authorization to the operator API. The
API server will ensure that the client's identity (SPIFFE ID) resides in
the same namespace as the requested resource namespace. This is done by
parsing the clients SPIFFE SVID of the mTLS connection.

If the client does not reside in the same namespace, then the request is
rejected with a permission denied.

---

The health server has been updated so that a target number can be given
where the health server will only return healthy once the consumer has
given the target number of healthy calls. This is useful for the
operator so that the operator only reports healthy once all informers
and servers have started. Without this change, clients would attempt to
connect to the API server when it wasn't actually ready to serve
requests. This was surfaced in the integration tests.

The PR adds an authz operator integration test which proves that the API
server will only honour requests with clients in the appropriate
namespace.

The Kubernetes intergration process now has the ability to serve
HTTP/2.0 informer requests from the API server controller runtime
informers- added so that informer reliant functions (`ComponentUpdate`,
`HTTPEndpointUpdate`, etc.) can be handled.

Updates `tests/util/pki` so that it can respond with a context which
includes the SPIFFE ID of the client, used for operator authz unit
tests.

Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: joshvanl <me@joshvanl.dev>
list

Signed-off-by: joshvanl <me@joshvanl.dev>
@JoshVanL
Copy link
Contributor Author

/test-version-skew

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 10, 2024

Dapr Version Skew e2e test (control-plane-master - 1.12.3)

🔗 Link to Action run

Commit ref: e953fc8

✅ Version Skew tests passed

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 10, 2024

Dapr Version Skew e2e test (dapr-sidecar-master - 1.12.3)

🔗 Link to Action run

Commit ref: e953fc8

❌ Version Skew tests failed

Please check the logs for details on the error.

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 10, 2024

Dapr Version Skew integration test (control-plane-master - 1.12.3)

🔗 Link to Action run

Commit ref: e953fc8

❌ Version Skew tests failed

Please check the logs for details on the error.

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 10, 2024

Dapr Version Skew integration test (dapr-sidecar-master - 1.12.3)

🔗 Link to Action run

Commit ref: e953fc8

❌ Version Skew tests failed

Please check the logs for details on the error.

@yaron2
Copy link
Member

yaron2 commented Jan 10, 2024

LGTM but need to make sure this is backward compatible, ie. 1.12 sidecars connecting to edge/1.13 control plane.

@yaron2
Copy link
Member

yaron2 commented Jan 11, 2024

/test-version-skew

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 11, 2024

Dapr Version Skew e2e test (control-plane-master - 1.12.3)

🔗 Link to Action run

Commit ref: 22b55da

✅ Version Skew tests passed

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 11, 2024

Dapr Version Skew integration test (dapr-sidecar-master - 1.12.3)

🔗 Link to Action run

Commit ref: 22b55da

❌ Version Skew tests failed

Please check the logs for details on the error.

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 11, 2024

Dapr Version Skew integration test (control-plane-master - 1.12.3)

🔗 Link to Action run

Commit ref: 22b55da

❌ Version Skew tests failed

Please check the logs for details on the error.

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 11, 2024

Dapr Version Skew e2e test (dapr-sidecar-master - 1.12.3)

🔗 Link to Action run

Commit ref: 22b55da

✅ Version Skew tests passed

@yaron2 yaron2 merged commit 16c0dd5 into dapr:master Jan 11, 2024
19 of 22 checks passed
DeepanshuA pushed a commit to DeepanshuA/dapr that referenced this pull request Jan 11, 2024
* Operator: Adds authorization to the operator API

Today, the operator does no authorization on clients making requests for
resources. This means that it is currently possible for any
authenticated client to get any Component/HTTPEndpoint/Resiliency in any
namespace. This includes the ability for any client is able to get
Dapr secrets in any namespace.

PR updates the operator to add authorization to the operator API. The
API server will ensure that the client's identity (SPIFFE ID) resides in
the same namespace as the requested resource namespace. This is done by
parsing the clients SPIFFE SVID of the mTLS connection.

If the client does not reside in the same namespace, then the request is
rejected with a permission denied.

---

The health server has been updated so that a target number can be given
where the health server will only return healthy once the consumer has
given the target number of healthy calls. This is useful for the
operator so that the operator only reports healthy once all informers
and servers have started. Without this change, clients would attempt to
connect to the API server when it wasn't actually ready to serve
requests. This was surfaced in the integration tests.

The PR adds an authz operator integration test which proves that the API
server will only honour requests with clients in the appropriate
namespace.

The Kubernetes intergration process now has the ability to serve
HTTP/2.0 informer requests from the API server controller runtime
informers- added so that informer reliant functions (`ComponentUpdate`,
`HTTPEndpointUpdate`, etc.) can be handled.

Updates `tests/util/pki` so that it can respond with a context which
includes the SPIFFE ID of the client, used for operator authz unit
tests.

Signed-off-by: joshvanl <me@joshvanl.dev>

* Linting

Signed-off-by: joshvanl <me@joshvanl.dev>

* Fix util test PKI options

Signed-off-by: joshvanl <me@joshvanl.dev>

* Fixes util.GenPKI for e2e service_invocation

Signed-off-by: joshvanl <me@joshvanl.dev>

* Remove unused integration framework grpc processes

Signed-off-by: joshvanl <me@joshvanl.dev>

* Linting

Signed-off-by: joshvanl <me@joshvanl.dev>

* Fix integration test operator informer by returning empty resiliency
list

Signed-off-by: joshvanl <me@joshvanl.dev>

---------

Signed-off-by: joshvanl <me@joshvanl.dev>
Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autoupdate DaprBot will keep the Pull Request up to date with master branch P0
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants