Example #1
0
        private static void SetupPolicies(Microsoft.AspNetCore.Authorization.AuthorizationOptions options)
        {
            options.AddPolicy("Manage Customer", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageCustomer.Value));

            options.AddPolicy("Manage Employee", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageEmployee.Value));

            options.AddPolicy("Manage Report", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageReport.Value));

            options.AddPolicy("Manage State", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageState.Value));

            options.AddPolicy("Manage Region", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageRegion.Value));

            options.AddPolicy("Manage HireBooking", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageHireBooking.Value));

            options.AddPolicy("Manage Vehicle", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageVehicle.Value));

            options.AddPolicy("Manage Terminal", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageTerminal.Value));

            options.AddPolicy("Manage Route", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageRoute.Value));

            options.AddPolicy("Manage Trip", policy =>
                              policy.RequireClaim("Permission", PermissionClaimsProvider.ManageTrip.Value));
        }
Example #2
0
 private static void ConfigurePolicies(Microsoft.AspNetCore.Authorization.AuthorizationOptions options)
 {
     options.AddPolicy(MyPolicies.Admin, policy =>
     {
         //Aqui estou dizendo que apenas os usuarios com perfil admin (setado na criação do token) tem acesso a esta política
         policy.RequireClaim(MyClaims.Perfil, MyPolicies.Admin);
     });
     options.AddPolicy(MyPolicies.Vendedor, policy =>
     {
         //Aqui estou dizendo que para acessar a política de vendedor, o cara pode ser admin ou vendedor
         policy.RequireClaim(MyClaims.Perfil, MyPolicies.Admin, MyPolicies.Vendedor);
     });
 }
Example #3
0
 private static void NixAuthorizationOptions(Microsoft.AspNetCore.Authorization.AuthorizationOptions options)
 {
     options.AddPolicy("NixSuperUser", policy => policy.RequireClaim("GodMode", "true"));
 }