Jhipster:对非管理员隐藏实体 [英] Jhipster: hide entities from non-admin

查看:66
本文介绍了Jhipster:对非管理员隐藏实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候Java赶时髦的人!

Greetings java hipsters!

我刚刚生成了一个jhipster项目并创建了一些实体.我想通过将某些实体限制为仅管理员用户来隐藏它们.我该如何实现?

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 ?

谢谢!

推荐答案

首先阅读 Spring Security文档,然后查看由JHipster生成的项目源代码:其中包含许多此类示例,请注意:

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
  • UserResource.java 中的
  • @Secured(AuthoritiesConstants.ADMIN)

然后为角形部分,您可以在状态定义中添加对管理员角色的要求,如src/main/webapp/app/admin/configuration/configuration.state.js(搜索for authorities: ['ROLE_ADMIN']).因此,对于bank-account实体,主要状态将在src/main/webapp/app/entities/bank-account/bank-account.state.js中定义.

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.

这是针对JHipster 3.x

This is for JHipster 3.x

这篇关于Jhipster:对非管理员隐藏实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆