Backend/pkg/permissions/core.go
2024-12-06 21:53:09 +01:00

109 lines
3.2 KiB
Go
Executable file

package permissions
import (
"git.zervo.org/scheduletogether/backend/pkg/types"
)
const (
SignOut types.PermissionKey = iota
GetAllUsers
GetUserById
GetUserByUuid
GetOwnUser
DeleteUserById
DeleteOwnUser
UpdateUserById
UpdateOwnUser
SendFriendRequest
AcceptFriendRequest
GetOwnFriendRequests
GetFriendRequestsById
OverrideInteractionPreferences
)
var Permissions = map[types.PermissionKey]types.Permission{
SignOut: {
Key: "sign_out",
Name: "Sign Out",
Description: "Allows user to manually sign out",
Roles: []string{"admin", "user", "member"},
},
GetAllUsers: {
Key: "get_all_users",
Name: "Get All Users",
Description: "Allows retrieving all instance users",
Roles: []string{"admin"},
},
GetUserById: {
Key: "get_user_by_id",
Name: "Get User By ID",
Description: "Allows retrieving specific user by ID",
Roles: []string{"admin"},
},
GetUserByUuid: {
Key: "get_user_by_uuid",
Name: "Get User By UUID",
Description: "Allows retrieving simple specific user data by UUID",
Roles: []string{"admin", "user", "member"},
},
GetOwnUser: {
Key: "get_own_user",
Name: "Get Own User",
Description: "Allows retrieving own user by payload data",
Roles: []string{"admin", "user", "member"},
},
DeleteUserById: {
Key: "delete_user_by_id",
Name: "Delete User By ID",
Description: "Allows deleting specific user by ID",
Roles: []string{"admin"},
},
DeleteOwnUser: {
Key: "delete_own_user",
Name: "Delete Own User",
Description: "Allows deleting own user by payload data",
Roles: []string{"user", "member"},
},
UpdateUserById: {
Key: "update_user_by_id",
Name: "Update User By ID",
Description: "Allows updating specific user by ID",
Roles: []string{"admin"},
},
UpdateOwnUser: {
Key: "update_own_user",
Name: "Update Own User",
Description: "Allows updating own user by payload data",
Roles: []string{"admin", "user", "member"},
},
SendFriendRequest: {
Key: "send_friend_request",
Name: "Send Friend Request",
Description: "Allows user to send friend requests",
Roles: []string{"admin", "user", "member"},
},
AcceptFriendRequest: {
Key: "accept_friend_request",
Name: "Accept Friend Request",
Description: "Allows user to accept incoming friend requests",
Roles: []string{"admin", "user", "member"},
},
GetOwnFriendRequests: {
Key: "get_own_friend_requests",
Name: "Get Own Friend Requests",
Description: "Allows user to list their incoming friend requests",
Roles: []string{"admin", "user", "member"},
},
GetFriendRequestsById: {
Key: "get_friend_requests_by_id",
Name: "Get Friend Requests By ID",
Description: "Allows user to list others incoming friend requests",
Roles: []string{"admin"},
},
OverrideInteractionPreferences: {
Key: "override_interaction_preferences",
Name: "Override Interaction Preferences",
Description: "Allows user to interact with other users no matter their interaction preferences",
Roles: []string{"admin"},
},
}