Skip to content

linuxfoundation/lfx-v2-access-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LFX v2 Access Check Service

Build Status License Go Version

A access check service for the LFX v2 platform, providing centralized authorization and permission management across LFX services.

✨ Key Features

  • πŸš€ Bulk Access Checks: Process multiple resource-action permission checks in a single HTTP request
  • πŸ” JWT Authentication: Secure authentication using Heimdall-issued JWT tokens
  • πŸ”„ Real-time Processing: Asynchronous message processing via NATS queue
  • 🚒 Cloud Native: Kubernetes-ready with Helm charts for easy deployment

πŸ—οΈ Architecture Overview

graph TB
    subgraph "LFX v2 Platform Gateway"
        T[Traefik<br/>API Gateway]
        H[Heimdall<br/>Access Decision Service]
    end

    subgraph "Access Check Service"
        AC[HTTP Server<br/>:8080]
        AS[Access Service<br/>Core Logic]
        HE[Health Endpoints<br/>/livez /readyz]
    end

    subgraph "Platform Infrastructure"
        N[NATS<br/>Message Queue]
    end

    T --> H
    H --> AC
    AC --> AS
    AC --> HE
    
    AS <-->|bulk access checks<br/>access-check subject| N
Loading

πŸ”„ Access Check Flow

sequenceDiagram
    participant Client as API Consumer
    participant Traefik as Traefik Gateway
    participant Heimdall as Heimdall Access Decision
    participant AccessCheck as Access Check Service
    participant NATS as NATS Queue

    Client->>Traefik: POST /access-check<br/>Bearer: JWT + resource list
    Traefik->>Heimdall: Validate JWT & authorize
    Heimdall-->>Traefik: Auth success
    Traefik->>AccessCheck: Forward authenticated request
    
    AccessCheck->>AccessCheck: Extract principal from JWT
    AccessCheck->>AccessCheck: Build resource-action pairs
    AccessCheck->>NATS: Publish bulk access check<br/>Subject: access-check
    
    NATS-->>AccessCheck: Return authorization results
    AccessCheck-->>Traefik: JSON response with decisions
    Traefik-->>Client: Access check results

    Note over AccessCheck: Optimized for bulk operations<br/>with comprehensive logging
Loading

πŸš€ Quick Start

Prerequisites

  • Go: 1.24.0
  • Docker: For containerized deployment
  • NATS: Message queue for service communication
  • Heimdall: JWT authentication provider

Local Development

  1. Clone the repository

    git clone https://github.com/linuxfoundation/lfx-v2-access-check.git
    cd lfx-v2-access-check
  2. Install dependencies

    make deps
  3. Generate API code (if needed)

    make apigen
  4. Build the service

    make build
  5. Run tests

    make test
  6. Start the service

    ./bin/lfx-access-check

Configuration

The service is configured via environment variables:

Variable Description Default
HOST Server host address 0.0.0.0
PORT Server port 8080
DEBUG Enable debug logging false
JWKS_URL Heimdall JWKS endpoint http://heimdall:4457/.well-known/jwks
AUDIENCE JWT audience access-check
ISSUER JWT issuer heimdall
NATS_URL NATS server URL nats://nats:4222

Docker Deployment

# Build image
make docker-build

# Run container
docker run -p 8080:8080 \
  -e JWKS_URL=http://heimdall:4457/.well-known/jwks \
  -e NATS_URL=nats://nats:4222 \
  linuxfoundation/lfx-access-check:latest

Health Endpoints

  • Liveness: GET /livez - Basic service health
  • Readiness: GET /readyz - Service + dependencies health

πŸ›οΈ Architecture Details

Core Components

  1. HTTP Server (cmd/lfx-access-check/)

    • Goa-based REST API server
    • JWT authentication middleware
    • Request ID tracking
    • Structured logging
  2. Access Service (internal/service/)

    • Core business logic
    • JWT token validation
    • NATS message publishing
    • Response aggregation
  3. Infrastructure Layer (internal/infrastructure/)

    • Auth Repository: Heimdall JWT validation
    • Messaging Repository: NATS communication
    • Config: Environment-based configuration
  4. Domain Contracts (internal/domain/contracts/)

    • Shared data structures
    • JWT claims modeling
    • Service interfaces

Project Structure

β”œβ”€β”€ cmd/lfx-access-check/    # Application entry point
β”œβ”€β”€ design/                  # Goa API design definitions
β”œβ”€β”€ gen/                     # Generated API code (Goa)
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ container/          # Dependency injection
β”‚   β”œβ”€β”€ domain/contracts/   # Domain models & interfaces
β”‚   β”œβ”€β”€ infrastructure/     # External service adapters
β”‚   β”œβ”€β”€ middleware/         # HTTP middleware
β”‚   β”œβ”€β”€ service/           # Core business logic
β”‚   └── mocks/             # Test mocks
β”œβ”€β”€ pkg/
β”‚   β”œβ”€β”€ constants/         # Application constants
β”‚   └── log/              # Structured logging utilities
β”œβ”€β”€ test/integration/      # Integration tests
└── charts/               # Helm deployment charts

🚒 Deployment

Kubernetes with Helm

# Install/upgrade with Helm
helm upgrade --install lfx-v2-access-check ./charts/lfx-v2-access-check \
  --set image.tag=latest \
  --set config.jwksUrl=http://heimdall:4457/.well-known/jwks \
  --set config.natsUrl=nats://nats:4222

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

LFX v2 Platform Access Check

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-docs

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages