feat(store): add roles, role assignments, api tokens and invitations
Built-in roles are seeded with fixed ids and are read-only for every org. Existing non-owner members receive the Viewer role. Refs #6, #7, #8, #9 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
15932db98a
commit
ee09c497de
15 files changed
+1063
-13
No files matched your search
@@ -10,6 +10,31 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type ApiToken struct {
|
||||
ID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
Name string
|
||||
TokenHash []byte
|
||||
Prefix string
|
||||
Permissions []string
|
||||
ExpiresAt *time.Time
|
||||
LastUsedAt *time.Time
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Invitation struct {
|
||||
ID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
Email string
|
||||
RoleID uuid.UUID
|
||||
TokenHash []byte
|
||||
InvitedBy *uuid.UUID
|
||||
ExpiresAt time.Time
|
||||
AcceptedAt *time.Time
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Membership struct {
|
||||
OrgID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
@@ -24,6 +49,7 @@ type Org struct {
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
RequireTotp bool
|
||||
RequireSso bool
|
||||
}
|
||||
|
||||
type RecoveryCode struct {
|
||||
@@ -33,6 +59,26 @@ type RecoveryCode struct {
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
ID uuid.UUID
|
||||
OrgID *uuid.UUID
|
||||
Key *string
|
||||
Name string
|
||||
Permissions []string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type RoleAssignment struct {
|
||||
ID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
RoleID uuid.UUID
|
||||
ResourceType *string
|
||||
ResourceID *uuid.UUID
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type SsoProvider struct {
|
||||
ID uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
@@ -46,6 +92,7 @@ type SsoProvider struct {
|
||||
Enabled bool
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DefaultRoleID *uuid.UUID
|
||||
}
|
||||
|
||||
type User struct {
|
||||
|
||||
Reference in new issue
Block a user