How to create a new Authority

Tip submitted by @Tonterias

Let’s say that you need a new authority besides the given ones of ADMIN and USER.

Modify file to include your new authorities:

 * Constants for Spring Security authorities.
public final class AuthoritiesConstants {

    public static final String ADMIN = "ROLE_ADMIN";

    public static final String USER = "ROLE_USER";

    public static final String ANONYMOUS = "ROLE_ANONYMOUS";

    private AuthoritiesConstants() {

Do not forget to include your new role in your authorities.csv:


With that, you will be able to use it in your or in (, for example:

public ResponseEntity<Void> deleteOrderItem(@PathVariable Long id) {

and/or Angular files: jhiHasAnyAuthority=[‘ROLE_ADMIN’. ‘ROLE_X’ ……] or even consider to use it in the routes:

export const messageRoute: Routes = [
        path: 'message',
        component: MessageComponent,
        data: {
            authorities: ['ROLE_USER'],
            pageTitle: 'Messages'
        canActivate: [UserRouteAccessService]

The open-source example is at JhipsterPress: