• v1.0.0 18fcd2bee3

    Rene Nochebuena released this 2026-05-07 22:51:01 -06:00 | 1 commits to main since this release

    v1.0.0

    code.nochebuena.dev/go/rbac

    Overview

    rbac v1.0.0 commits the foundational identity and permission API as stable.
    The Identity value type, PermissionMask bit-set, context helpers, and
    PermissionProvider interface are unchanged from v0.9.0 and are now
    production-validated across httpauth, httpauth-firebase, and httpauth-jwt.

    What Changed Since v0.9.0

    New: MaxPermission constant

    const MaxPermission Permission = 62
    

    Makes the valid bit range explicit. Applications can use it in validation and
    the constant is now referenced in the Permission type godoc alongside the
    boundary behavior of Has and Grant.

    Documentation: audit logging policy

    PermissionProvider godoc now documents that audit logging of permission checks
    is out of scope for this package. Log denials and grants inside PermissionProvider
    implementations or in the middleware layer that calls them.

    Full API (stable)

    Permission int64 — bit position (0–MaxPermission). Applications define their
    own constants. Has and Grant silently ignore values outside the valid range.

    MaxPermission Permission = 62 — highest valid bit position.

    PermissionMask int64 — resolved bit-set for a user on a resource.

    • Has(p Permission) bool — O(1) check; returns false for out-of-range p
    • Grant(p Permission) PermissionMask — returns a new mask with bit set; receiver unchanged

    Identity — value type carrying UID, TenantID, DisplayName, Email.

    • NewIdentity(uid, displayName, email string) Identity
    • (Identity).WithTenant(id string) Identity — returns copy; receiver unchanged

    SetInContext(ctx, Identity) context.Context

    FromContext(ctx) (Identity, bool)

    PermissionProvider interfaceResolveMask(ctx, uid, resource string) (PermissionMask, error)

    Migration from v0.9.0

    No breaking changes. The only addition is the MaxPermission constant.

    go get code.nochebuena.dev/go/rbac@v1.0.0
    
    Downloads