Track and monitor authorization attempts with the auth-log package.
@repo/auth-log
package provides a simple yet powerful way to log and monitor authorization attempts in your application. It integrates seamlessly with the authorization packages to create an audit trail of access control decisions.
@repo/auth-log
package allows you to:
zopio
stack. If you need to install it separately:
AUTH_LOG_TARGET
environment variable:
./logs/access.log
by default.
When using BetterStack, you’ll need to provide your source token via the BETTERSTACK_SOURCE_TOKEN
environment variable.
timestamp
: When the authorization attempt occurredresource
: The resource being accessed (e.g., ‘article’, ‘user’)action
: The action being performed (e.g., ‘read’, ‘update’)context
: User context information (userId, role, tenantId)recordId
: Optional ID of the specific record being accessedfield
: Optional field name for field-level permissionscan
: Boolean indicating whether access was grantedreason
: Optional explanation for why access was denied