security

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package security provides an in-memory, zero-dependency Authorizer provider for gorp framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryAuthorizer

type MemoryAuthorizer struct {
	// contains filtered or unexported fields
}

MemoryAuthorizer is a lightweight in-memory Authorizer implementation. Maps role/subject names to allowed action:object patterns.

func NewMemoryAuthorizer

func NewMemoryAuthorizer(initialRules ...map[string][]string) *MemoryAuthorizer

NewMemoryAuthorizer creates a MemoryAuthorizer with optional initial rules.

func (*MemoryAuthorizer) AddRule

func (m *MemoryAuthorizer) AddRule(role, pattern string)

AddRule adds a permission pattern for a role/subject.

func (*MemoryAuthorizer) Enforce

func (m *MemoryAuthorizer) Enforce(ctx context.Context, sub, obj, act string) (bool, error)

Enforce checks if sub (subject/role) is permitted to access obj with act.

type Provider

type Provider struct {
	Authorizer securitycontract.Authorizer
}

Provider is the DI provider for security Authorizer.

func NewProvider

func NewProvider(authorizer ...securitycontract.Authorizer) *Provider

NewProvider creates a new security Provider.

func (*Provider) Boot

Boot initializes provider.

func (*Provider) Register

func (p *Provider) Register(c runtimecontract.Container) error

Register binds AuthorizerKey in container.

Jump to

Keyboard shortcuts

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