Angular2 routing canActivate and AuthGuard (JWT) with user role parameter

You can set the data parameter of the route with the role like this const appRoutes: Routes = [ { path: ‘account/super-secure’, component: SuperSecureComponent, canActivate: [RoleGuard], data: { roles: [‘super-admin’, ‘admin’] } }]; and then have this in canActivate of RoleGuard: canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { let roles = route.data[“roles”] as Array<string>; return (roles … Read more

Best Role-Based Access Control (RBAC) database model [closed]

To my rather basic knowledge in that area, the basic actors of an RBAC are: Resources. Permissions. Users. Roles (i.e. Groups). Resources <- require -> (one or many) Permissions. Roles <- are collections of -> (one or many) Permissions. Users <- can have -> (one or many) Roles. The tables for such a model would … Read more

Role based authentication in the new MVC 4 Internet template using simplemembership

Found an answer here by Mehdi Golchin which seems to take care of: [Authorize(Roles=”admin,editor,publisher”)] If I also add this to the home controller: [InitializeSimpleMembership] Because this attribute is on the Accounts controller, SimpleMembership database gets initialize only after the first use of the accounts controller like login/register. Even when the current user gets logged in … Read more

Is setting Roles in JWT a best practice?

The official JWT site explicitly mentions “authorization” (in contrast to “authentication”) as a usecase for JWTs: When should you use JSON Web Tokens? Authorization: This is the most common scenario for using JWT. Once the user is logged in, each subsequent request will include the JWT, allowing the user to access routes, services, and resources … Read more

asp.net identity get all roles of logged in user

Controller.User.Identity is a ClaimsIdentity. You can get a list of roles by inspecting the claims… var roles = ((ClaimsIdentity)User.Identity).Claims .Where(c => c.Type == ClaimTypes.Role) .Select(c => c.Value); — update — Breaking it down a bit more… using System.Security.Claims; // …….. var userIdentity = (ClaimsIdentity)User.Identity; var claims = userIdentity.Claims; var roleClaimType = userIdentity.RoleClaimType; var roles = … Read more

Cannot drop PostgreSQL role. Error: `cannot be dropped because some objects depend on it`

DROP USER (or DROP ROLE, same thing) cannot proceed while the role still owns anything or has any granted privileges on other objects. Get rid of all privileges with DROP OWNED (which isn’t too obvious from the wording). The manual: […] Any privileges granted to the given roles on objects in the current database and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)