Skip to content

RedHatInsights/insights-rbac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7,555 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

insights-rbac

Role-Based Access Control (RBAC) service for console.redhat.com. Manages roles, permissions, groups, and workspaces that control user access across the Hybrid Cloud Console platform.

Overview

insights-rbac is a Django REST Framework microservice that provides two API versions:

  • V1 API -- stable, widely consumed REST API for managing roles, groups, policies, and permissions
  • V2 API -- next-generation API with workspace-based access control, RFC 7807 error responses, and Kessel integration for authorization

The service is multi-tenant: every request is scoped to an organization (tenant) via identity headers injected by the platform's authentication gateway.

Tech Stack

  • Language: Python 3.12
  • Framework: Django 5.2 / Django REST Framework
  • Database: PostgreSQL 16
  • Cache: Redis
  • Task Queue: Celery (Redis broker)
  • Authorization: Kessel Relations (SpiceDB-based, gRPC)
  • Messaging: Kafka (Debezium CDC outbox pattern)
  • Metrics: Prometheus

Quick Start

Prerequisites

  • Python 3.12
  • Pipenv
  • Docker / Podman (for PostgreSQL and Redis)

Option 1: Docker Compose (full stack)

Starts the RBAC server, PostgreSQL, Redis, Celery worker, and Celery beat scheduler:

make docker-up       # App available at http://localhost:9080
make docker-logs     # Tail all container logs
make docker-down     # Stop and remove containers

Option 2: Local Python (app only)

Run the Django server locally, using Docker only for PostgreSQL:

pipenv install --dev     # Install dependencies
make start-db            # Start Postgres on port 15432
make run-migrations      # Apply database migrations
make serve               # App available at http://localhost:8000

Testing

Tests require a running PostgreSQL instance (SQLite is not supported):

make start-db                                      # Ensure Postgres is running

# Full test suite with coverage
pipenv run tox -e py312

# Fast test suite (no coverage)
pipenv run tox -e py312-fast

# Single test module (dotted path, not file path)
pipenv run tox -e py312-fast -- tests.management.role.test_view

See docs/testing-guidelines.md for base classes, v2 test setup, and mocking patterns.

Linting and Formatting

pipenv run tox -e lint                          # flake8 + black --check
pipenv run black -t py312 -l 119 rbac tests     # Auto-format
pipenv run pre-commit run --all-files            # Run all pre-commit hooks

Database

make make-migrations     # Generate migration files
make run-migrations      # Apply migrations
make reinitdb            # Drop, recreate, and migrate

Direct access: psql postgres -U postgres -h localhost -p 15432

API Documentation

Regenerate the v2 spec from TypeSpec:

make generate_v2_spec

Environment Variables

Key environment variables (see docker-compose.yml for a full reference):

Variable Description Default
DATABASE_HOST PostgreSQL host localhost
DATABASE_PORT PostgreSQL port 15432
DATABASE_NAME Database name postgres
REDIS_HOST Redis host rbac_redis
API_PATH_PREFIX API URL prefix /api/rbac
V2_APIS_ENABLED Enable v2 API routes False
KAFKA_ENABLED Enable Kafka producer/consumer False
DEVELOPMENT Development mode flag False

Project Structure

rbac/
  api/            # V1 API views, serializers, URLs
  management/     # Core business logic (models, services, views per domain)
  internal/       # Internal/service-to-service API
  core/           # Shared utilities, middleware, error handling
  rbac/           # Django project settings, WSGI, Celery config
  migration_tool/ # V1-to-V2 migration utilities
tests/            # Test suite (mirrors rbac/ structure)
docs/             # Architecture and domain guideline docs

Further Reading

License

This project is licensed under the GNU AGPL v3. See LICENSE for details.

About

Role based access control API service

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages