Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jhipster: hide entities from non-admin

Greetings java hipsters!

I just generated a jhipster project and created some entities. I'd like to hide some entities by restricting them to only the admin user. How do I achieve this ?

Thanks!

like image 921
Emmanuel Osimosu Avatar asked Dec 08 '22 21:12

Emmanuel Osimosu


1 Answers

First read Spring Security doc then look at your project source code that was generated by JHipster: it's full of such examples, pay attention to:

  • SecurityConfiguration.java
  • @Secured(AuthoritiesConstants.ADMIN) in UserResource.java

Then for the angular part, you can add a requirement for admin role in a state's definition like in src/main/webapp/app/admin/configuration/configuration.state.js (search for authorities: ['ROLE_ADMIN']). So for a bank-account entity, main state would be defined in src/main/webapp/app/entities/bank-account/bank-account.state.js.

This is for JHipster 3.x

like image 77
Gaël Marziou Avatar answered Mar 08 '23 02:03

Gaël Marziou