24 lines
502 B
Go
24 lines
502 B
Go
package contexts
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.haelnorr.com/h/oslstats/internal/permissions"
|
|
"git.haelnorr.com/h/oslstats/internal/roles"
|
|
)
|
|
|
|
// Permissions retrieves the permission cache from context (type-safe)
|
|
func Permissions(ctx context.Context) *PermissionCache {
|
|
cache, ok := ctx.Value(PermissionCacheKey).(*PermissionCache)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
return cache
|
|
}
|
|
|
|
type PermissionCache struct {
|
|
Permissions map[permissions.Permission]bool
|
|
Roles map[roles.Role]bool
|
|
HasWildcard bool
|
|
}
|