Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Add IAM policies #497

Closed
wants to merge 23 commits into from
Closed

Add IAM policies #497

wants to merge 23 commits into from

Conversation

ramizpolic
Copy link
Member

@ramizpolic ramizpolic commented Jul 25, 2023

Description

Addresses openclarity/openclarity#726

All changes summarised in https://github.com/openclarity/vmclarity/tree/feature/rbac/pkg/apiserver/iam#readme

High level architecture

https://github.com/openclarity/vmclarity/tree/feature/rbac/pkg/apiserver/iam/testdata/architecture.png

Server-side stack

  • Authenticator - Interacts with IDP to authenticate request and obtain user identity data. Part of API middleware.
  • RoleSyncer - Interacts with some kind of store (e.g. database or from JWT token claim) to fetch and sync user role data. Used in API middleware.
  • Authorizer - Decides if a User can perform a given action on an asset based on provided rules.
    Separate component that is used to check user-action permissions.
    Used in API middleware for API asset-action (e.g. api:put) authorization.

Test environment

Requires Docker to run. This will create a Zitadel instance with bootstrapped data which you can use
out-of-the-box to enable IAM for VMClarity.

# Create Zitadel
cd pkg/apiserver/iam/testdata/zitadel
chmod +x ./create-zitadel
RECREATE=true ./create-zitadel

# Get autogenerated file and obtain VMClarity config data.
# Update if required.
cat bootstrap/generated/vmclarity-data.env

Config parameters

# IAM global config
IAM_ENABLED=true

# Authentication config
AUTH_OIDC_ISSUER=http://localhost:8080
AUTH_OIDC_CLIENT_ID=app_client_id
AUTH_OIDC_CLIENT_SECRET=app_client_secret

# RoleSynchronization config
ROLESYNCER_JWT_ROLE_CLAIM=roles-claim-key

# Authorization config
AUTHZ_LOCAL_RBAC_RULE_FILEPATH=path-to/rbac_rule_policy_example.csv

# Injection - Client service account
APISERVER_TOKEN=Service Account PAM

TODO (next iterations)

  • Add Zitadel component into VMClarity stack. Use Zitadel bootstrapping without using Terraform.
  • Add support for injecting auth data into different parts of request (e.g. cookies).
  • Handle http response codes properly (currently only 403 is returned on Auth/Z failure)
  • Add Authorizer that uses database as Role permission source. Also add bootstrapping for the Role and Rule data.
  • Add RoleSyncer that uses database as User Role source to avoid using non-intuitive JWT Claim Role Source.
  • Add support for different IAM components (Authenticator and RoleSyncer) to avoid relying only on Zitadel.
  • Add support to dynamically add/remove (CRUD) multiple Authenticators in IAM stack.
  • Add tests

More resources

Type of Change

[ ] Bug Fix
[x] New Feature
[x] Breaking Change
[ ] Refactor
[ ] Documentation
[ ] Other (please describe)

Checklist

  • I have read the contributing guidelines
  • Existing issues have been referenced (where applicable)
  • I have verified this change is not present in other open pull requests
  • Functionality is documented
  • All code style checks pass
  • New code contribution is covered by automated tests
  • All new and existing tests pass

@ramizpolic ramizpolic requested a review from a team as a code owner July 25, 2023 16:57
@ramizpolic ramizpolic self-assigned this Jul 25, 2023
@ramizpolic ramizpolic marked this pull request as draft July 25, 2023 16:57
@ramizpolic ramizpolic force-pushed the feature/rbac branch 6 times, most recently from c5a1368 to 6428fb0 Compare July 26, 2023 15:30
@ramizpolic ramizpolic marked this pull request as ready for review July 26, 2023 15:32
@ramizpolic ramizpolic force-pushed the feature/rbac branch 3 times, most recently from 238448e to 393921b Compare July 28, 2023 16:13
api/openapi.yaml Outdated Show resolved Hide resolved
@ramizpolic ramizpolic force-pushed the feature/rbac branch 3 times, most recently from c1e8640 to 04429d1 Compare July 28, 2023 17:30
@ramizpolic ramizpolic added enhancement New feature or request infrastructure Issues related to VMClarity control plane infrastructure labels Jul 28, 2023
api/openapi.yaml Outdated Show resolved Hide resolved
pkg/backend/config/config.go Outdated Show resolved Hide resolved
pkg/backend/config/config.go Outdated Show resolved Hide resolved
pkg/backend/iam/provider/oidc.go Outdated Show resolved Hide resolved
pkg/backend/iam/rolesyncer/jwt.go Outdated Show resolved Hide resolved
pkg/backend/iam/testdata/architecture.drawio Outdated Show resolved Hide resolved
pkg/backend/rest/server.go Outdated Show resolved Hide resolved
@ramizpolic ramizpolic force-pushed the feature/rbac branch 4 times, most recently from 7906d2a to b760a7b Compare August 7, 2023 15:34
@ramizpolic ramizpolic force-pushed the feature/rbac branch 2 times, most recently from f2e2ec3 to 5ec0805 Compare August 8, 2023 08:42
@ramizpolic ramizpolic force-pushed the feature/rbac branch 3 times, most recently from 23b6f2c to 6f16279 Compare October 2, 2023 13:16
@ramizpolic ramizpolic closed this Dec 8, 2023
@ramizpolic ramizpolic removed this from the v0.7.0 milestone May 14, 2024
Copy link

github-actions bot commented Aug 8, 2024

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Add IAM policies". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - BREAKING
 - build
 - chore
 - ci
 - docs
 - feat
 - fix
 - perf
 - refactor
 - revert
 - style
 - test
 - release

@ramizpolic ramizpolic deleted the feature/rbac branch August 8, 2024 19:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request epic infrastructure Issues related to VMClarity control plane infrastructure roadmap Items that are high-level, for making them visible on the roadmap.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Identity and access management
4 participants