auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// MaxJWTExpiryMinutes caps the normal JWT expiry to 12 hours.
	MaxJWTExpiryMinutes = 720
	// MaxRememberMeDays caps the remember-me JWT expiry to 90 days.
	MaxRememberMeDays = 90
)

Variables

This section is empty.

Functions

func GenerateAPIKey

func GenerateAPIKey() string

func GenerateJWTToken

func GenerateJWTToken(expiresMin int, userID uint, role string) (string, string, error)

func HasPermission

func HasPermission(role string, perm Permission) bool

HasPermission checks if the given role has the specified permission.

func VerifyJWTToken

func VerifyJWTToken(token string) (bool, uint, string)

VerifyJWTToken validates the JWT and returns the user identity in claims.

Types

type Permission

type Permission string

Permission represents a fine-grained access right.

const (
	PermChannelsRead       Permission = "channels:read"
	PermChannelsWrite      Permission = "channels:write"
	PermGroupsRead         Permission = "groups:read"
	PermGroupsWrite        Permission = "groups:write"
	PermAPIKeysRead        Permission = "apikeys:read"
	PermAPIKeysWrite       Permission = "apikeys:write"
	PermSettingsRead       Permission = "settings:read"
	PermSettingsWrite      Permission = "settings:write"
	PermLogsRead           Permission = "logs:read"
	PermLogsWrite          Permission = "logs:write"
	PermStatsRead          Permission = "stats:read"
	PermUsersRead          Permission = "users:read"
	PermUsersWrite         Permission = "users:write"
	PermSitesRead          Permission = "sites:read"
	PermSitesWrite         Permission = "sites:write"
	PermSubscriptionsRead  Permission = "subscriptions:read"
	PermSubscriptionsWrite Permission = "subscriptions:write"
)

Jump to

Keyboard shortcuts

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