Help us shape the future of Go! Take the 2026 Go Developer Survey

hub

module
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: Apache-2.0

README

hub

日本語版 (Japanese) | 简体中文 (Chinese)

hub is an open-source identity and access management platform built with a Go backend, React frontend, Keycloak authentication, and Kubernetes-ready infrastructure.

Screenshots

Login Dashboard
Login Dashboard
Users Users — Filters & Bulk Actions
Users Users Filters
Groups Roles
Groups Roles

What hub does

  • User management — create, update, deactivate users; bulk status change and CSV export
  • Group management — organize users into groups; assign roles via dual-panel UI
  • Role-based access control (RBAC) — fine-grained permissions derived from Protobuf definitions; no permission is hand-coded twice
  • Keycloak SSO — browser login, device flow (RFC 8628), and client-credentials for CI
  • CLI (hub) — every API operation is available as a typed command; hub api describe <rpc> shows the RBAC rule the server enforces

Architecture

graph TD
    Client[Web Browser] -->|HTTPS| Gateway[gRPC-Gateway / REST API]
    Gateway -->|gRPC| Server[Go Backend API]
    Server -->|SQL| DB[(PostgreSQL)]
    Server -->|OIDC| Auth[Keycloak]
    Client -->|OIDC| Auth
    Infra[Terraform / K8s] -.->|Manages| Server
    Infra -.->|Manages| Auth
    Infra -.->|Manages| DB
Layer What it does
Backend API (/server) Go · DDD · Clean Architecture · gRPC + gRPC-Gateway
Frontend (/ui/web) React 19 · Vite · TypeScript · Tailwind CSS 4 · TanStack Query v5
Auth (/ui/keycloak-theme) Keycloak · custom FreeMarker login theme
Infrastructure (/infra) Terraform (cloud resources) · Kubernetes + Kustomize (manifests)

Tech Stack

Layer Technology / Tool
Backend Go 1.26, gRPC, gRPC-Gateway, Protocol Buffers, sqlc, golangci-lint
Frontend React 19, Vite, TypeScript, Tailwind CSS 4, Shadcn UI, TanStack Query v5, Keycloak JS
Auth Keycloak, FreeMarker Templates
Infra Terraform, Kubernetes, Kustomize
Database PostgreSQL

Directory Structure

.
├── server/             # Go backend
│   ├── cmd/            # Entry points (server, CLI, generators)
│   ├── internal/       # Business logic (Clean Architecture)
│   └── proto/          # API definitions — single source of truth
├── ui/
│   ├── web/            # React SPA
│   └── keycloak-theme/ # Custom Keycloak login theme
├── infra/
│   ├── tf/             # Terraform (IaC)
│   └── k8s/            # Kubernetes manifests
├── go.mod
└── Makefile            # Common tasks

Each directory contains a detailed AGENTS.md development guide.


Getting Started

Prerequisites
  • Docker + Docker Compose
  • Go 1.26+
  • Node.js + pnpm
  • kubectl + minikube (for Kubernetes deployment)
1. Install dependencies
# Backend tools (buf, sqlc, protoc plugins, …)
make init

# Frontend packages
cd ui/web && pnpm install
2. Start local environment
# Starts PostgreSQL, Keycloak, and the API server via Docker Compose
make dev

The web UI is served by the Vite dev server:

cd ui/web && pnpm dev   # http://localhost:3000
3. Seed initial data
make dev-seed
4. Regenerate code (after proto / SQL changes)
make gen
Deploy to Kubernetes (MiniKube)
# Preview manifests
kubectl kustomize infra/k8s/overlays/minikube

# Apply
kubectl apply -k infra/k8s/overlays/minikube

Build the hub image inside MiniKube first: eval $(minikube docker-env) && docker build -t hub .


CLI (hub auth login)

The hub CLI authenticates via OAuth 2.0 Device Authorization Grant (RFC 8628) — no client secret required for interactive use.

Install
make cli
Interactive (browser) login
HUB_OIDC_ISSUER=http://localhost:8080/realms/hub \
HUB_OIDC_CLIENT_ID=hub-web \
hub auth login
  1. A one-time code is printed; your browser opens automatically.
  2. Enter the code and sign in with your Keycloak account.
  3. The CLI prints ✓ Authentication successful and saves the token.

Use --web to force the device flow even when a client secret is configured.

Non-interactive (service accounts / CI)
HUB_OIDC_ISSUER=http://localhost:8080/realms/hub \
HUB_OIDC_CLIENT_ID=hub-api \
HUB_OIDC_CLIENT_SECRET=<secret> \
hub auth login

With a client secret and no --username, the client credentials grant is used.

Password grant
hub auth login --username admin
# Prompted securely, or set HUB_PASSWORD
Verify
hub auth whoami
hub auth token

Development Guidelines

Directories

Path Synopsis
server
cmd/cli command
cmd/gen-adapter command
cmd/gen-web-client command
Command gen-web-client writes the web client's operation table from the API catalog.
Command gen-web-client writes the web client's operation table from the API catalog.
cmd/hub command
Command hub is the command line client for the hub API.
Command hub is the command line client for the hub API.
cmd/openapi223 command
cmd/server command
di
internal/infrastructure/persistence
Code generated by gen-adapter.
Code generated by gen-adapter.
internal/usecase/pagination
Package pagination bounds how much a list endpoint will return.
Package pagination bounds how much a list endpoint will return.
pb/ai/chat/v1
Package v1 is a reverse proxy.
Package v1 is a reverse proxy.
pb/system/group/v1
Package v1 is a reverse proxy.
Package v1 is a reverse proxy.
pb/system/permission/v1
Package v1 is a reverse proxy.
Package v1 is a reverse proxy.
pb/system/resource/v1
Package v1 is a reverse proxy.
Package v1 is a reverse proxy.
pb/system/role/v1
Package v1 is a reverse proxy.
Package v1 is a reverse proxy.
pb/user/v1
Package v1 is a reverse proxy.
Package v1 is a reverse proxy.
pkg/apicatalog
Package apicatalog turns the compiled protobuf descriptors into a single description of the HTTP/gRPC surface: what every rpc is called, how it is reached over REST, which fields it takes, and what RBAC demands of it.
Package apicatalog turns the compiled protobuf descriptors into a single description of the HTTP/gRPC surface: what every rpc is called, how it is reached over REST, which fields it takes, and what RBAC demands of it.
pkg/hubcli
Package hubcli implements `hub`, the command line client for the hub API.
Package hubcli implements `hub`, the command line client for the hub API.
ui
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL