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

Update authorization to use the Target Reference API #7709

Closed
olix0r opened this issue Jan 26, 2022 · 2 comments
Closed

Update authorization to use the Target Reference API #7709

olix0r opened this issue Jan 26, 2022 · 2 comments

Comments

@olix0r
Copy link
Member

olix0r commented Jan 26, 2022

The new networking.k8s.io APIs provide a pattern called policy
attachment
. This pattern allows for policies to be generic over the types
to which they are attached, with the specific supported types becoming an
implementation detail of Linkerd's policy controller.

We should anticipate this pattern stabilizing as the Kubernetes way and ensure
that our new routing/policy behavior leverages this pattern. This will help us
take advantage of standardized policies as they become available, and generally
ease cognitive burden.

Unfortunately, this probable means that we should replace the recently
introduced ServerAuthorization resource with a new resource type that more
closely adheres to this pattern. Specifically:

Each Policy resource MUST include a single targetRef field. It MUST not
target more than one resource at a time, but it can be used to target larger
resources such as Gateways or Namespaces that may apply to multiple child
resources.

Proposed changes

AuthorizationPolicy

We deprecate the ServerAuthorization resource, replacing it with the more
generic AuthorizationPolicy. An AuthorizationPolicy uses the targetRef API
to bind an authorization policy to a single (server-side) resource. A given
authorization also references a set of required authentication resources. In
order for an authorization to apply, all authorizations must be satisfied.

apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: ...
  name: ...
spec:

  # References a single resource in the same namespace to which the
  # authorization policy applies.
  targetRef:
    group: ...
    kind: ...
    name: ...

  # Lists a set of _required_ authentication resources.
  requiredAuthenticationRefs:
    - group: ...
      kind: ...
      namespace: ...
      name: ...

targetRef

An AuthorizationPolicy's targetRef may reference a variety of resources
representing the server-side of a connection (where authorization is enforced).
The policy controller provides a validating admission controller that prevents
resources from being created with unsupported targetRef kinds.

To accomplish the same functionality as the ServerAuthorization resource, we
can target a Server resource:

  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: emoji-grpc

To apply to all servers in a namespace, we can reference a Namespace resource:

  targetRef:
    kind: Namespace
    name: emojivoto

Similarly, we can target a ServiceAccount to apply to all pods with a given ServiceAccount:

  targetRef:
    kind: ServiceAccount
    name: emoji

It can even reference pods by a Deployment/StatefulSet/etc.

  targetRef:
    group: apps
    kind: Deployment
    name: emoji

An AuthorizationPolicy may not target a Service, which is a distinctly
client-centric concept. (I.e. a server cannot necessarily know whether a given
connection targetted servicea or serviceb).

Initially, Servers would be the only supported target type (and the web hook
should reject policies that use other targets). We would incrementally add
supported resources after the initial change is introduced straightforward, This
will also allow attachment to HTTP routes/request classes as those primitives
are fleshed out.

Note that this removes support for label-based matching of targets. This will at
the very least simplify our matching code, at the cost of requiring users to
create more resources. This is probably a reasonable tradeoff.

requiredAuthenticationRefs

A policy binds a target to a set of required authentication resources. All
authentications must be provided for traffic to be authorized.

  requiredAuthenticationRefs:
    - group: ...
      kind: ...
      namespace: ...
      name: ...

Note that an authorization may reference authentication types in other
namespaces! This should be used with care, as anyone with write access to this
resource can alter the authentication requirement. This allows us to define
common authentication types (for instance, in the linkerd namespace) that may
be reused by policies.

NetworkAuthentication

  requiredAuthenticationRefs:
    - group: policy.linkerd.io
      kind: NetworkAuthentication
      namespace: linkerd
      name: all-networks
---
apiVersion: policy.linkerd.io/v1alpha1
kind: NetworkAuthentication
metadata:
  namespace: linkerd
  name: all-networks
spec:
 networks:
   - cidr: 0.0.0.0/0
   - cidr: ::/0

MeshTLSAuthentication

If we want to require communication is authenticated via mesh TLS, we can use a
MeshTLSAuthentication resource to describe acceptable clients.

Client identities can be referenced by ServiceAccount:

---
apiVersion: policy.linkerd.io/v1alpha1
kind: MeshTLSAuthentication
metadata:...
spec:
 identityRefs:
   - kind: ServiceAccount
     name: web

Or by Namespace:

spec:
 identityRefs:
   - kind: Namespace
     name: emojivoto

And we don't have to reference an in-cluster resource. We can also match
identity strings by suffix (especially relevant for multi-cluster gateways):

spec:
 identities:
   - "*.west.example.com"

Or we can match any authenticated client with a wildcard identity

spec:
 identities: ["*"]

Questions

  • Does this require changing the protobuf API? I don't think so?
  • How should this be exposed in metric labels?
@olix0r
Copy link
Member Author

olix0r commented Jan 26, 2022

Draft CRDs on the ver/authz-crd branch (e.g., c0e04d0)

@olix0r olix0r added the priority/P0 Release Blocker label Jan 26, 2022
@olix0r
Copy link
Member Author

olix0r commented Jan 27, 2022

We probably want to namespace these resources somehow to reflect that they only apply on the inbound side of the proxy--either in the group name: inbound.policy.linkerd.io or by explicitly naming the resource, e.g. InboundAuthorizationPolicy. I could easily see confusion/collision as we try to introduce policies that enforce, for instance, that outbound traffic uses TLS.

olix0r added a commit that referenced this issue Mar 4, 2022
Issue #7709 proposes new Custom Resource types to support generalized
authorization policies:

- `AuthorizationPolicy`
- `MeshTLSAuthentication`
- `NetworkAuthentication`

This change introduces these CRDs to the default linkerd installation
(via the `linkerd-crds` chart) and updates the policy controller's
admission webhook to validate these resource types.

This change does NOT update the policy controller to actually honor
these resources when serving policy configuration to proxies.

Signed-off-by: Oliver Gould <ver@buoyant.io>
olix0r added a commit that referenced this issue Mar 5, 2022
Issue #7709 proposes new Custom Resource types to support generalized
authorization policies:

- `AuthorizationPolicy`
- `MeshTLSAuthentication`
- `NetworkAuthentication`

This change introduces these CRDs to the default linkerd installation
(via the `linkerd-crds` chart) and updates the policy controller's
admission webhook to validate these resource types.

This change does NOT update the policy controller to actually honor
these resources when serving policy configuration to proxies.

This change adds policy-controller integration tests to exercise the
admission controller & CRD validation logic. These tests are implemented
in the `policy-test` crate.

Signed-off-by: Oliver Gould <ver@buoyant.io>
olix0r added a commit that referenced this issue Mar 5, 2022
Issue #7709 proposes new Custom Resource types to support generalized
authorization policies:

- `AuthorizationPolicy`
- `MeshTLSAuthentication`
- `NetworkAuthentication`

This change introduces these CRDs to the default linkerd installation
(via the `linkerd-crds` chart) and updates the policy controller's
admission webhook to validate these resource types.

This change does NOT update the policy controller to actually honor
these resources when serving policy configuration to proxies.

This change adds policy-controller integration tests to exercise the
admission controller & CRD validation logic. These tests are implemented
in the `policy-test` crate.

Signed-off-by: Oliver Gould <ver@buoyant.io>
olix0r added a commit that referenced this issue Mar 6, 2022
Issue #7709 proposes new Custom Resource types to support generalized
authorization policies:

- `AuthorizationPolicy`
- `MeshTLSAuthentication`
- `NetworkAuthentication`

This change introduces these CRDs to the default linkerd installation
(via the `linkerd-crds` chart) and updates the policy controller's
admission webhook to validate these resource types.

This change does NOT update the policy controller to actually honor
these resources when serving policy configuration to proxies.

This change adds policy-controller integration tests to exercise the
admission controller & CRD validation logic. These tests are implemented
in the `policy-test` crate.

Signed-off-by: Oliver Gould <ver@buoyant.io>
olix0r added a commit that referenced this issue Mar 29, 2022
Issue #7709 proposes new Custom Resource types to support generalized
authorization policies:

- `AuthorizationPolicy`
- `MeshTLSAuthentication`
- `NetworkAuthentication`

This change introduces these CRDs to the default linkerd installation
(via the `linkerd-crds` chart) and updates the policy controller's
to handle these resource types. The policy admission controller
validates that these resource reference only suppported types.

This new functionality is tested at multiple levels:

* `linkerd-policy-controller-k8s-index` includes unit tests for the
  indexer to test how events update the index;
* `linkerd-policy-test` includes integration tests that run in-cluster
  to validate that the gRPC API updates as resources are manipulated;
* `linkerd-policy-test` includes integration tests that exercise the
  admission controller's resource validation; and
* `linkerd-policy-test` includes integration tests that ensure that
  proxies honor authorization resources.

This change does NOT update Linkerd's control plane and extensions to
use these new authorization primitives. Furthermore, the `linkerd` CLI
does not yet support inspecting these new resource types. These
enhancements will be made in followup changes.

Signed-off-by: Oliver Gould <ver@buoyant.io>
olix0r added a commit that referenced this issue Mar 29, 2022
Issue #7709 proposes new Custom Resource types to support generalized
authorization policies:

- `AuthorizationPolicy`
- `MeshTLSAuthentication`
- `NetworkAuthentication`

This change introduces these CRDs to the default linkerd installation
(via the `linkerd-crds` chart) and updates the policy controller's
to handle these resource types. The policy admission controller
validates that these resource reference only suppported types.

This new functionality is tested at multiple levels:

* `linkerd-policy-controller-k8s-index` includes unit tests for the
  indexer to test how events update the index;
* `linkerd-policy-test` includes integration tests that run in-cluster
  to validate that the gRPC API updates as resources are manipulated;
* `linkerd-policy-test` includes integration tests that exercise the
  admission controller's resource validation; and
* `linkerd-policy-test` includes integration tests that ensure that
  proxies honor authorization resources.

This change does NOT update Linkerd's control plane and extensions to
use these new authorization primitives. Furthermore, the `linkerd` CLI
does not yet support inspecting these new resource types. These
enhancements will be made in followup changes.

Signed-off-by: Oliver Gould <ver@buoyant.io>
olix0r added a commit that referenced this issue Mar 30, 2022
Issue #7709 proposes new Custom Resource types to support generalized
authorization policies:

- `AuthorizationPolicy`
- `MeshTLSAuthentication`
- `NetworkAuthentication`

This change introduces these CRDs to the default linkerd installation
(via the `linkerd-crds` chart) and updates the policy controller's
to handle these resource types. The policy admission controller
validates that these resource reference only suppported types.

This new functionality is tested at multiple levels:

* `linkerd-policy-controller-k8s-index` includes unit tests for the
  indexer to test how events update the index;
* `linkerd-policy-test` includes integration tests that run in-cluster
  to validate that the gRPC API updates as resources are manipulated;
* `linkerd-policy-test` includes integration tests that exercise the
  admission controller's resource validation; and
* `linkerd-policy-test` includes integration tests that ensure that
  proxies honor authorization resources.

This change does NOT update Linkerd's control plane and extensions to
use these new authorization primitives. Furthermore, the `linkerd` CLI
does not yet support inspecting these new resource types. These
enhancements will be made in followup changes.

Signed-off-by: Oliver Gould <ver@buoyant.io>
zaharidichev added a commit to BuoyantIO/linkerd-buoyant that referenced this issue Apr 20, 2022
This PR enables the ingestion of the new Linkerd policy types that are outlined in linkerd/linkerd2#7709

Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
@adleong adleong closed this as completed Jun 7, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants