journal

command
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 18 Imported by: 0

README

Transactional journal example

The example exposes a local HTTP endpoint backed by JournalReader. Each request performs a strict authorization check. Run maintains the listener and journal retention; cancellation stops it before the database connection closes.

PostgreSQL 15+ is required for the example's unique constraint. The database and a separate application login role must exist. From the repository root, initialize the example schemas once as their owner:

DATABASE_DSN='postgres://owner:password@localhost/casbin_test?sslmode=disable' go run ./examples/journal -init -reader-role app_user

Start the application with the reader's credentials:

DATABASE_DSN='postgres://app_user:password@localhost/casbin_test?sslmode=disable' go run ./examples/journal
curl -i 'http://127.0.0.1:8080/check?sub=alice&obj=data1&act=read'

The request supplies the subject for this demonstration. Application authentication supplies the subject in an actual authorization handler. Responses are 200 for permission granted, 403 for permission denied and 503 for an authorization error.

To revoke the grant, execute as the policy table owner:

DELETE FROM journal_example.policies
WHERE ptype = 'g' AND v0 = 'alice' AND v1 = 'readers';

The next request returns 403 after this transaction commits. Restore the same grouping rule to grant access again. Ctrl+C stops the example.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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