| | | 1 | | using System.Reflection; |
| | | 2 | | |
| | | 3 | | namespace Syki.Back.Auth.Permissions; |
| | | 4 | | |
| | | 5 | | public static class SykiPermissions |
| | | 6 | | { |
| | | 7 | | // Identity |
| | 2 | 8 | | public static readonly SykiPermission ManageRoles = new( |
| | 2 | 9 | | PermissionGroup.Identity, |
| | 2 | 10 | | 000, |
| | 2 | 11 | | "Gerenciar perfis de acesso.", |
| | 2 | 12 | | "Criar, editar e deletar perfis de acesso." |
| | 2 | 13 | | ); |
| | 2 | 14 | | public static readonly SykiPermission ManageSso = new( |
| | 2 | 15 | | PermissionGroup.Identity, |
| | 2 | 16 | | 001, |
| | 2 | 17 | | "Gerenciar SSO.", |
| | 2 | 18 | | "Configurar Single Sign-On (SSO) para a instituição." |
| | 2 | 19 | | ); |
| | | 20 | | |
| | | 21 | | // Users |
| | 2 | 22 | | public static readonly SykiPermission ManageUsers = new( |
| | 2 | 23 | | PermissionGroup.Users, |
| | 2 | 24 | | 100, |
| | 2 | 25 | | "Gerenciar usuários.", |
| | 2 | 26 | | "Criar, editar e deletar usuários." |
| | 2 | 27 | | ); |
| | | 28 | | |
| | | 29 | | // Campi |
| | 2 | 30 | | public static readonly SykiPermission ManageCampi = new( |
| | 2 | 31 | | PermissionGroup.Campi, |
| | 2 | 32 | | 200, |
| | 2 | 33 | | "Gerenciar campus.", |
| | 2 | 34 | | "Criar e editar campus." |
| | 2 | 35 | | ); |
| | | 36 | | |
| | | 37 | | // Disciplines |
| | 2 | 38 | | public static readonly SykiPermission ManageDisciplines = new( |
| | 2 | 39 | | PermissionGroup.Disciplines, |
| | 2 | 40 | | 300, |
| | 2 | 41 | | "Gerenciar disciplinas.", |
| | 2 | 42 | | "Criar e editar disciplinas." |
| | 2 | 43 | | ); |
| | | 44 | | |
| | | 45 | | // Courses |
| | 2 | 46 | | public static readonly SykiPermission ManageCourses = new( |
| | 2 | 47 | | PermissionGroup.Courses, |
| | 2 | 48 | | 400, |
| | 2 | 49 | | "Gerenciar cursos.", |
| | 2 | 50 | | "Criar e editar cursos." |
| | 2 | 51 | | ); |
| | | 52 | | |
| | | 53 | | // Teachers |
| | 2 | 54 | | public static readonly SykiPermission ManageTeachers = new( |
| | 2 | 55 | | PermissionGroup.Teachers, |
| | 2 | 56 | | 500, |
| | 2 | 57 | | "Gerenciar professores.", |
| | 2 | 58 | | "Criar e editar professores." |
| | 2 | 59 | | ); |
| | | 60 | | |
| | | 61 | | // Students |
| | 2 | 62 | | public static readonly SykiPermission ManageStudents = new( |
| | 2 | 63 | | PermissionGroup.Students, |
| | 2 | 64 | | 600, |
| | 2 | 65 | | "Gerenciar alunos.", |
| | 2 | 66 | | "Criar e editar alunos." |
| | 2 | 67 | | ); |
| | | 68 | | |
| | | 69 | | // Periods |
| | 2 | 70 | | public static readonly SykiPermission ManagePeriods = new( |
| | 2 | 71 | | PermissionGroup.Periods, |
| | 2 | 72 | | 700, |
| | 2 | 73 | | "Gerenciar períodos acadêmicos.", |
| | 2 | 74 | | "Criar e editar períodos acadêmicos." |
| | 2 | 75 | | ); |
| | | 76 | | |
| | | 77 | | // CourseCurriculums |
| | 2 | 78 | | public static readonly SykiPermission ManageCourseCurriculums = new( |
| | 2 | 79 | | PermissionGroup.CourseCurriculums, |
| | 2 | 80 | | 800, |
| | 2 | 81 | | "Gerenciar grades curriculares.", |
| | 2 | 82 | | "Criar e editar grades curriculares." |
| | 2 | 83 | | ); |
| | | 84 | | |
| | | 85 | | // CourseOfferings |
| | 2 | 86 | | public static readonly SykiPermission ManageCourseOfferings = new( |
| | 2 | 87 | | PermissionGroup.CourseOfferings, |
| | 2 | 88 | | 900, |
| | 2 | 89 | | "Gerenciar ofertas de curso.", |
| | 2 | 90 | | "Criar e editar ofertas de curso." |
| | 2 | 91 | | ); |
| | | 92 | | |
| | 2 | 93 | | public static readonly List<PermissionGroup> Groups = []; |
| | 2 | 94 | | public static readonly List<SykiPermission> Permissions = []; |
| | | 95 | | static SykiPermissions() |
| | | 96 | | { |
| | 2 | 97 | | Groups = Enum.GetValues<PermissionGroup>().ToList(); |
| | | 98 | | |
| | 2 | 99 | | Permissions = typeof(SykiPermissions) |
| | 2 | 100 | | .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) |
| | 26 | 101 | | .Where(f => f.FieldType == typeof(SykiPermission)) |
| | 22 | 102 | | .Select(f => (SykiPermission)f.GetValue(null)!) |
| | 22 | 103 | | .OrderBy(f => f.Group) |
| | 22 | 104 | | .ThenBy(f => f.Id) |
| | 2 | 105 | | .ToList(); |
| | | 106 | | |
| | 24 | 107 | | if (!Permissions.Select(x => x.Id).IsAllDistinct()) throw new Exception("Duplicated permission ids!"); |
| | | 108 | | |
| | 24 | 109 | | if (!Permissions.Select(x => x.Name).IsAllDistinct()) throw new Exception("Duplicated permission names!"); |
| | 2 | 110 | | } |
| | | 111 | | } |