b16e9f0bd1
Plan 0 (workspaces): add workspaces + workspace_memberships schema, extend JWT/Actor/claims with primary_workspace_id, seed default workspace per tenant, thread workspace_id through tenant monitoring quota. Plan A (desktop skeleton): new Electron app (apps/desktop-client) with main/ preload/renderer, shared Vue component package (packages/ui-shared), and server surface — desktop client registration + token rotation + heartbeat, SSE task event stream, desktop accounts/tasks/content handlers, publish job endpoint, and supporting repositories, services, sqlc queries, and migrations. Hard cutover per plan: remove browser-extension monitoring callback endpoints, stub legacy media API in admin-web, and delete monitoring_callback_handler.go.
30 lines
567 B
Go
30 lines
567 B
Go
package auth
|
|
|
|
import "context"
|
|
|
|
type Actor struct {
|
|
UserID int64
|
|
TenantID int64
|
|
PrimaryWorkspaceID int64
|
|
Role string
|
|
}
|
|
|
|
type actorKey struct{}
|
|
|
|
func WithActor(ctx context.Context, actor Actor) context.Context {
|
|
return context.WithValue(ctx, actorKey{}, actor)
|
|
}
|
|
|
|
func ActorFromCtx(ctx context.Context) (Actor, bool) {
|
|
actor, ok := ctx.Value(actorKey{}).(Actor)
|
|
return actor, ok
|
|
}
|
|
|
|
func MustActor(ctx context.Context) Actor {
|
|
actor, ok := ActorFromCtx(ctx)
|
|
if !ok {
|
|
panic("auth: actor not in context")
|
|
}
|
|
return actor
|
|
}
|