Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // PlatformJWTKey is the HMAC secret for platform multi-tenant JWT tokens. // Loaded from PLATFORM_JWT_SECRET env var, or randomly generated. PlatformJWTKey []byte // PlatformJWTExpiry is the platform JWT token expiry (24 hours). // Loaded from PLATFORM_JWT_EXPIRY env var, or defaults to 24 hours. PlatformJWTExpiry = 24 * time.Hour )
Functions ¶
func SignPlatformJWT ¶
SignPlatformJWT creates a signed platform JWT token using the given HMAC key and expiry. If key is empty, returns error.
Types ¶
type InvitationService ¶
type InvitationService interface {
CreateInvitation(teamID string, orgID *string, email, role, inviterName, teamName, orgName string) error
AcceptInvitation(token, userID, userEmail string) error
}
InvitationService handles invitation creation and acceptance logic.
func NewInvitationService ¶
func NewInvitationService(db *gorm.DB, messageSender messenger.Sender, platformURL string, logger schemas.Logger) InvitationService
NewInvitationService creates a new InvitationService.
type InvitationServiceImpl ¶
type InvitationServiceImpl struct {
// contains filtered or unexported fields
}
func (*InvitationServiceImpl) AcceptInvitation ¶
func (s *InvitationServiceImpl) AcceptInvitation(token, userID, userEmail string) error
AcceptInvitation adds the user to the team/org described by the invitation. It verifies that the invitation's email matches the provided userEmail.
func (*InvitationServiceImpl) CreateInvitation ¶
func (s *InvitationServiceImpl) CreateInvitation(teamID string, orgID *string, email, role, inviterName, teamName, orgName string) error
CreateInvitation creates a pending invitation for a user to join a team. teamID is required; orgID may be nil if the team has no parent org.
type PlatformClaims ¶
type PlatformClaims struct {
UserID string `json:"sub"`
IsAdmin bool `json:"is_admin"`
Orgs []OrgClaim `json:"orgs"`
Teams []TeamClaim `json:"teams"`
AuthToken string `json:"auth_token"`
Email string `json:"email"`
UserName string `json:"user_name"`
Exp int64 `json:"exp"`
Iat int64 `json:"iat"`
Jti string `json:"jti"`
}
PlatformClaims represents the claims in a platform multi-tenant JWT.
func VerifyPlatformJWT ¶
func VerifyPlatformJWT(tokenString string, key []byte) (*PlatformClaims, error)
VerifyPlatformJWT parses and validates a platform JWT using the given HMAC key, returning the claims. Returns error if key is empty or token is invalid.
func (*PlatformClaims) IsOrgAdmin ¶
func (c *PlatformClaims) IsOrgAdmin(orgID string) bool
IsOrgAdmin returns true if the user has admin role in the given organization. System admins (is_admin=true) are implicitly org admins for any org.
func (*PlatformClaims) IsOrgMember ¶
func (c *PlatformClaims) IsOrgMember(orgID string) bool
IsOrgMember returns true if the user is a member of the given organization. System admins (is_admin=true) are implicitly members of any org.
func (*PlatformClaims) IsTeamAdmin ¶
func (c *PlatformClaims) IsTeamAdmin(teamID string) bool
IsTeamAdmin returns true if the user has admin role in the given team.