I am trying to add a new role (ROLE_REPORTS) on a project generated using JHipster. I can see the tables that need to be updated (role, authority and role_authority mapping), but I am not sure how to go about the Java part of it.
There a few bits and pieces I can figure out, but I am concerned that my customisation may break some design philosophies (like the Swagger API, Spring Security, etc.,)
Has anyone already attempted it and if so any help in the right direction will be highly appreciated.
Add it to security/AuthoritiesConstants.java. and webapps/scripts/contstants.js. In the example below, an authority/role of MANAGER was added.
public final class AuthoritiesConstants {
private AuthoritiesConstants() {
}
public static final String ADMIN = "ROLE_ADMIN";
public static final String USER = "ROLE_USER";
public static final String MANAGER = "ROLE_MANAGER";
public static final String ANONYMOUS = "ROLE_ANONYMOUS";
}
And in constants.js:
myApp.constant('USER_ROLES', {
'all': '*',
'admin': 'ROLE_ADMIN',
'user': 'ROLE_USER',
'manager', 'ROLE_MANAGER'
});
The new role must be added to the database. For example, the authorities.csv:
name
ROLE_ADMIN
ROLE_USER
ROLE_MANAGER