Skip to content

v1.0.0

Choose a tag to compare

@MichaelAndish MichaelAndish released this 05 Jun 23:08

Viewed middleware.go:53-93

Here is a professional release description for wpd-gogate v1.0.0 (First Release):


Release v1.0.0 — Initial Stable Release

wpd-gogate is a clean, framework-agnostic, and high-performance Role-Based Access Control (RBAC) library for Go. It features a polymorphic, multi-tenant database schema, synchronized in-memory policy caching, and a single-query evaluation path for sub-microsecond authorization checks.

Key Features

  • Sub-microsecond Evaluations: Role-permission relationships are cached in a thread-safe synchronized map on startup, enabling in-memory lookups in nanoseconds.
  • Relational Database Schema: Uses a standard 5-table polymorphic relational database schema supporting:
    • roles and permissions
    • role_has_permissions (role-permission mapping)
    • model_has_roles (role assignments to entities)
    • model_has_permissions (direct permission overrides for specific models)
  • Multi-Tenant Team / Workspace Scoping: Roles and permissions can be optionally scoped to specific workspaces, groups, or teams using a nullable team_id.
  • Single-Query Check Optimization: Combines direct permission assignments and inherited role permissions into a single database round-trip using an optimized SQL UNION ALL query. Nullable team_id checks leverage IS NOT DISTINCT FROM to ensure precise isolation.
  • Fluent Go API: Ergonomic, builder-style chaining interface:
    user := gate.Model("users", userID, teamID)
    err := user.AssignRole(ctx, "writer")
    allowed, err := user.Can(ctx, "articles.create")
  • Zero-DB Fast Path: Perform immediate, in-memory checks if user roles are pre-resolved (e.g., from JWT claims):
    if gate.HasRolePermission("admin", "articles.create") { ... }
  • Echo Middleware Integration: Out-of-the-box routing middleware supporting customizable model and team ID extraction hook functions.

Database & Tooling

  • PostgreSQL 17 Ready: Optimized and tested against PostgreSQL 17.
  • Migration & Seeding: Includes complete UP/DOWN migration files (migrations/) and an organized, dynamic SQL seeding script (seeds/seed_roles_permissions.sql).

Quality & Code Health

  • 100% Go Standard Format: Formatted entirely with gofmt.
  • Robust Test Suite:
    • Mock unit tests covering direct matching, cache routing, and edge cases.
    • E2E integration test suite validating real PostgreSQL connection flows.
    • Strict isolation testing confirming a user can act as a writer in Workspace A and a viewer in Workspace B without leakage.
  • Linter & Race Checked: Verified under golangci-lint (0 findings) and Go's race detector.