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

implement role-based RBAC for Talos API #3421

Closed
6 tasks done
smira opened this issue Apr 1, 2021 · 3 comments · Fixed by #3827
Closed
6 tasks done

implement role-based RBAC for Talos API #3421

smira opened this issue Apr 1, 2021 · 3 comments · Fixed by #3827
Assignees
Milestone

Comments

@smira
Copy link
Member

smira commented Apr 1, 2021

This is initial implementation which will be extended in the future versions of Talos.

tl;dr:

There are two roles: os:admin and os:reader. Role os:admin gives full access to the APIs. Role os:reader limits access to read-only APIs and doesn't allow calls which might expose secrets (resources in secrets namespace, machineconfiguration resource, read API, etc.). Roles are encoded in the Talos client certificate in the Organization field and used to verify access.

Flow

  1. User generates client certificate with some role in the Organization field.
  2. User access Talos API with that certificate as client certificate.
  3. apid receives the request, validates TLS cert and extracts Organization field as a list of roles.
  4. If request involves proxying to other nodes, apid uses its own special client certificate generated with role os:impersonate and encodes original roles in the gRPC metadata.
  5. If request is passed down to machined, roles are passed via gRPC metadata.
  6. Request hits machined with role encoded in the gRPC metadata. Each API verifies whether the role if sufficient to execute the call, otherwise AccessDenied is returned.

Implementation

talosctl gen config

Config generation code should be updated to output talosconfig with os:admin role by default always.

talosctl talosconfig command

This new command generates talosconfig on the server with given params and returns back a file in talosconfig format:

$ talosctl talosconfig --roles=os:admin [--lifetime=1h] [path]

apid

apid should extract roles from the Organization field and store them in gRPC metadata. apid should never accept roles passed in from the user in gRPC metadata as they can't be trusted. If role os:impersonate is in the certificate, actual roles are extracted from the gRPC metadata.

apid should generate its own client certificate used to proxy requests to other nodes with os:impersonate role.

apid should pass roles down to machined.

machined

We need a generic helper to verify roles in machined gRPC server. For example, ensureRoles(ctx, requiredRoles..) error which returns gRPC error if required role is missing.

Most of read-only APIs should be safe for os:reader with the exception of resources (secrets namespace + machienconfiguration resource), and read API which might read files which contain secrets.

All APIs which involve changes (reboot, reset, upgrade, ...) should require os:admin.

Transitioning to RBAC

Actual RBAC checks should be disabled in machined unless feature gate apiRBAC is enabled.

Feature gates should be implemented with the following format for the machine configuration:

machine:
   featureGates:
      apiRBAC:
         enable: true
         # additional configuration might go here

For new config generation, this feature gate should be enabled by default.

When upgrading from 0.9, feature gate is not enabled, so talosconfig without role works, but it can be enabled once new talosconfig is generated via talosctl talosconfig.

Misc TODO items

  • multiple roles per certificate
  • check problem with UNIX socket
  • enable RBAC by default for new configs
  • make RBAC in-method checks work when RBAC enforcement is disabled
  • move "sensitivity" to COSI resource definitions (as enum)
  • check and update authorisation rules
@smira smira added this to the 0.10 milestone Apr 1, 2021
@smira smira modified the milestones: 0.10, 0.11 Apr 12, 2021
@smira
Copy link
Member Author

smira commented May 18, 2021

os:admin - generate new certifcate = os:system ?

AlekSi added a commit to AlekSi/talos that referenced this issue May 25, 2021
Minimal change for backporting into 0.10.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue May 25, 2021
Minimal change for backporting into 0.10.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit that referenced this issue May 25, 2021
Minimal change for backporting into 0.10.

Refs #3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue May 25, 2021
Minimal change for backporting into 0.10.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit that referenced this issue May 25, 2021
Minimal change for backporting into 0.10.

Refs #3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
@sergelogvinov
Copy link
Sponsor Contributor

Can you add the role os:backup witch can make only etcd backups?

@smira
Copy link
Member Author

smira commented May 27, 2021

Can you add the role os:backup witch can make only etcd backups?

sounds good, probably we should make it more specific for now, like os:etcdbackup

AlekSi added a commit to AlekSi/talos that referenced this issue Jun 2, 2021
It is not enforced yet.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 3, 2021
It is not enforced yet.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 3, 2021
It is not enforced yet.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit to AlekSi/talos that referenced this issue Jun 4, 2021
It is not enforced yet.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 4, 2021
It is not enforced yet.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 4, 2021
It is not enforced yet.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 7, 2021
It is not enforced yet.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit to AlekSi/talos that referenced this issue Jun 7, 2021
It is not enforced yet.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit to AlekSi/talos that referenced this issue Jun 7, 2021
It is not enforced yet.

Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit that referenced this issue Jun 7, 2021
It is not enforced yet.

Refs #3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 7, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 8, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 8, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 8, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 16, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 16, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 16, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 16, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 16, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 16, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 17, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 17, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 17, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 17, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit that referenced this issue Jun 17, 2021
Refs #3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 18, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 18, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit that referenced this issue Jun 18, 2021
Refs #3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 21, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 21, 2021
Refs siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit that referenced this issue Jun 21, 2021
Refs #3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 24, 2021
* `talosctl config new` now sets endpoints in the generated config.
* Avoid duplication of roles in metadata.
* Remove method name prefix handling. All methods should be set explicitly.
* Add tests.

Closes siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 24, 2021
* `talosctl config new` now sets endpoints in the generated config.
* Avoid duplication of roles in metadata.
* Remove method name prefix handling. All methods should be set explicitly.
* Add tests.

Closes siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 25, 2021
* `talosctl config new` now sets endpoints in the generated config.
* Avoid duplication of roles in metadata.
* Remove method name prefix handling. All methods should be set explicitly.
* Add tests.

Closes siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
AlekSi added a commit to AlekSi/talos that referenced this issue Jun 25, 2021
* `talosctl config new` now sets endpoints in the generated config.
* Avoid duplication of roles in metadata.
* Remove method name prefix handling. All methods should be set explicitly.
* Add tests.

Closes siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
talos-bot pushed a commit that referenced this issue Jun 25, 2021
* `talosctl config new` now sets endpoints in the generated config.
* Avoid duplication of roles in metadata.
* Remove method name prefix handling. All methods should be set explicitly.
* Add tests.

Closes #3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
smira pushed a commit to smira/talos that referenced this issue Jun 28, 2021
* `talosctl config new` now sets endpoints in the generated config.
* Avoid duplication of roles in metadata.
* Remove method name prefix handling. All methods should be set explicitly.
* Add tests.

Closes siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
(cherry picked from commit ad047a7)
smira pushed a commit to smira/talos that referenced this issue Jun 28, 2021
* `talosctl config new` now sets endpoints in the generated config.
* Avoid duplication of roles in metadata.
* Remove method name prefix handling. All methods should be set explicitly.
* Add tests.

Closes siderolabs#3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
(cherry picked from commit ad047a7)
smira pushed a commit that referenced this issue Jun 28, 2021
* `talosctl config new` now sets endpoints in the generated config.
* Avoid duplication of roles in metadata.
* Remove method name prefix handling. All methods should be set explicitly.
* Add tests.

Closes #3421.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
(cherry picked from commit ad047a7)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants