Restrict team invite permissions to Super Admin only.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
ad3f4410e9
commit
cdc473df80
8
db/migrations/000104_admin_revoke_team_invite.down.sql
Normal file
8
db/migrations/000104_admin_revoke_team_invite.down.sql
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
-- Restore invite/resend on ADMIN (previous temporary grant).
|
||||
INSERT INTO role_permissions (role_id, permission_id)
|
||||
SELECT r.id, p.id
|
||||
FROM roles r
|
||||
CROSS JOIN permissions p
|
||||
WHERE r.name = 'ADMIN'
|
||||
AND p.key IN ('team.members.invite', 'team.invitations.resend')
|
||||
ON CONFLICT DO NOTHING;
|
||||
7
db/migrations/000104_admin_revoke_team_invite.up.sql
Normal file
7
db/migrations/000104_admin_revoke_team_invite.up.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- Team invite/resend are Super Admin only; revoke if previously granted to ADMIN.
|
||||
DELETE FROM role_permissions
|
||||
WHERE role_id = (SELECT id FROM roles WHERE name = 'ADMIN')
|
||||
AND permission_id IN (
|
||||
SELECT id FROM permissions
|
||||
WHERE key IN ('team.members.invite', 'team.invitations.resend')
|
||||
);
|
||||
|
|
@ -414,7 +414,7 @@ var defaultStudentLearnerPermissions = []string{
|
|||
|
||||
// DefaultRolePermissions maps each system role to the permission keys it should
|
||||
// have by default. This preserves the previous middleware behavior:
|
||||
// - SUPER_ADMIN: same defaults as ADMIN (full panel including team invitations)
|
||||
// - SUPER_ADMIN: ADMIN defaults plus team email invitation permissions
|
||||
// - ADMIN: everything that was previously OnlyAdminAndAbove + SuperAdminOnly + all authenticated routes
|
||||
// - STUDENT/OPEN_LEARNER/INSTRUCTOR/SUPPORT: only self-service endpoints (profile, courses, progress, etc.)
|
||||
var DefaultRolePermissions = map[string][]string{
|
||||
|
|
@ -507,10 +507,10 @@ var DefaultRolePermissions = map[string][]string{
|
|||
"vimeo.videos.list", "vimeo.videos.get", "vimeo.videos.embed", "vimeo.videos.status", "vimeo.videos.delete",
|
||||
"vimeo.uploads.pull", "vimeo.uploads.tus",
|
||||
|
||||
// Team (full access including email invitations)
|
||||
// Team (full access except email invitations — Super Admin only)
|
||||
"team.profile.get_mine", "team.profile.update_mine", "team.stats", "team.members.list", "team.members.export", "team.members.create",
|
||||
"team.members.get", "team.members.update", "team.members.update_status", "team.members.delete", "team.members.change_password",
|
||||
"team.members.invite", "team.invitations.list", "team.invitations.resend", "team.invitations.revoke",
|
||||
"team.invitations.list", "team.invitations.revoke",
|
||||
|
||||
// Sub-course Prerequisites
|
||||
"subcourse_prerequisites.add", "subcourse_prerequisites.list", "subcourse_prerequisites.remove",
|
||||
|
|
@ -701,9 +701,9 @@ var DefaultRolePermissions = map[string][]string{
|
|||
}
|
||||
|
||||
func init() {
|
||||
// SUPER_ADMIN inherits the full ADMIN permission set.
|
||||
adminKeys := DefaultRolePermissions["ADMIN"]
|
||||
superKeys := make([]string, len(adminKeys))
|
||||
superKeys := make([]string, len(adminKeys), len(adminKeys)+2)
|
||||
copy(superKeys, adminKeys)
|
||||
superKeys = append(superKeys, "team.members.invite", "team.invitations.resend")
|
||||
DefaultRolePermissions["SUPER_ADMIN"] = superKeys
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user