我怎样才能管理jhipster权限的权限?

时间:2017-06-19 12:43:09

标签: javascript java spring angular jhipster

我正在使用JHipster代码生成器编写webapp。 我创建了2个额外的角色,现在我总共有5个角色:

ROLE_USER, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_PRESIDENT, ROLE_VICE_PRESIDENT

我想知道如何管理他们显示 REST 的权限。

例如,我想让 PRESIDENT 将新用户添加到数据库,其他简单用户不应该看到执行此工作的Web服务。

是否有一个我错误地忽略的文件可以帮助我使用此功能?

感谢你宝贵的时间,

曼努埃尔

1 个答案:

答案 0 :(得分:0)

需要在2个地方添加向JHipster添加新角色。

显而易见的是AngularJS前端。要将新角色添加到用户编辑视图,请将其添加到“{1}}

”中“user-management.controller.js”中的选择选项

要在UI中的不同位置强制执行角色,您可以将角色添加到状态JS文件中。只需将它们添加到06-19 10:26:50.382 E/EGL_emulation( 5282): tid 5308: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH) 06-19 10:26:50.382 W/OpenGLRenderer( 5282): Failed to set EGL_SWAP_BEHAVIOR on surface 0x9a966180, error=EGL_BAD_MATCH 06-19 10:26:50.433 E/EGL_emulation( 5282): tid 5308: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH) 06-19 10:26:50.433 W/OpenGLRenderer( 5282): Failed to set EGL_SWAP_BEHAVIOR on surface 0x9a966060, error=EGL_BAD_MATCH 06-19 10:26:50.663 E/EGL_emulation( 5282): tid 5308: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH) 06-19 10:26:50.663 W/OpenGLRenderer( 5282): Failed to set EGL_SWAP_BEHAVIOR on surface 0x9a7a0aa0, error=EGL_BAD_MATCH 06-19 10:26:51.898 D/Mono ( 5282): Assembly Ref addref LoginSystem[0x9dfec2a0] -> SQLite-net[0xad9e9dc0]: 2 06-19 10:26:51.916 D/Mono ( 5282): Unloading image System.Threading.Tasks.dll [0x9a853f00]. 06-19 10:26:51.916 D/Mono ( 5282): Image addref System.Threading.Tasks[0x9a864300] -> System.Threading.Tasks.dll[0x9cc96000]: 6 06-19 10:26:51.916 D/Mono ( 5282): Config attempting to parse: 'System.Threading.Tasks.dll.config'. 06-19 10:26:51.916 D/Mono ( 5282): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Threading.Tasks/System.Threading.Tasks.config'. 06-19 10:26:51.916 D/Mono ( 5282): Assembly Ref addref SQLite-net[0xad9e9dc0] -> System.Threading.Tasks[0x9dfed020]: 4 06-19 10:26:51.962 D/Mono ( 5282): Unloading image System.Collections.dll [0xab2f7400]. 06-19 10:26:51.962 D/Mono ( 5282): Image addref System.Collections[0xaec94f60] -> System.Collections.dll[0x9d004f00]: 7 06-19 10:26:51.962 D/Mono ( 5282): Config attempting to parse: 'System.Collections.dll.config'. 06-19 10:26:51.962 D/Mono ( 5282): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Collections/System.Collections.config'. 06-19 10:26:51.962 D/Mono ( 5282): Assembly Ref addref SQLite-net[0xad9e9dc0] -> System.Collections[0x9dfec4e0]: 5 06-19 10:26:51.965 D/Mono ( 5282): Unloading image System.Runtime.Extensions.dll [0xab2f7400]. 06-19 10:26:51.965 D/Mono ( 5282): Image addref System.Runtime.Extensions[0xaec94f60] -> System.Runtime.Extensions.dll[0x9d007c00]: 6 06-19 10:26:51.965 D/Mono ( 5282): Config attempting to parse: 'System.Runtime.Extensions.dll.config'. 06-19 10:26:51.965 D/Mono ( 5282): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Runtime.Extensions/System.Runtime.Extensions.config'. 06-19 10:26:51.965 D/Mono ( 5282): Assembly Ref addref SQLite-net[0xad9e9dc0] -> System.Runtime.Extensions[0x9dfecb40]: 4 06-19 10:26:51.965 D/Mono ( 5282): Assembly Ref addref SQLite-net[0xad9e9dc0] -> SQLitePCLRaw.core[0xad9e9f40]: 2 06-19 10:26:51.975 D/Mono ( 5282): Unloading image System.Threading.dll [0xab2f7400]. 06-19 10:26:51.975 D/Mono ( 5282): Image addref System.Threading[0xaec949c0] -> System.Threading.dll[0xb2facb00]: 7 06-19 10:26:51.975 D/Mono ( 5282): Config attempting to parse: 'System.Threading.dll.config'. 06-19 10:26:51.975 D/Mono ( 5282): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Threading/System.Threading.config'. 06-19 10:26:51.975 D/Mono ( 5282): Assembly Ref addref SQLite-net[0xad9e9dc0] -> System.Threading[0x9dfec5a0]: 5 06-19 10:26:51.983 D/Mono ( 5282): Assembly Ref addref SQLite-net[0xad9e9dc0] -> SQLitePCLRaw.batteries_v2[0xad9e9d00]: 2 06-19 10:26:51.984 D/Mono ( 5282): Assembly Ref addref SQLitePCLRaw.batteries_v2[0xad9e9d00] -> SQLitePCLRaw.provider.e_sqlite3[0xad9e9e20]: 2 06-19 10:26:51.984 D/Mono ( 5282): Assembly Ref addref SQLitePCLRaw.provider.e_sqlite3[0xad9e9e20] -> SQLitePCLRaw.core[0xad9e9f40]: 3 06-19 10:26:51.985 D/Mono ( 5282): Assembly Ref addref SQLitePCLRaw.batteries_v2[0xad9e9d00] -> SQLitePCLRaw.core[0xad9e9f40]: 4 06-19 10:26:51.992 D/Mono ( 5282): DllImport attempting to load: 'e_sqlite3'. 06-19 10:26:51.994 D/Mono ( 5282): DllImport error loading library '/storage/emulated/0/Android/data/LoginSystem.Android/files/.__override__/libe_sqlite3': 'dlopen failed: library "/data/app/LoginSystem.Android-1/lib/x86//storage/emulated/0/Android/data/LoginSystem.Android/files/.__override__/libe_sqlite3" not found'. 06-19 10:26:51.995 D/Mono ( 5282): DllImport error loading library '/storage/emulated/0/Android/data/LoginSystem.Android/files/.__override__/libe_sqlite3.so': 'dlopen failed: library "/data/app/LoginSystem.Android-1/lib/x86//storage/emulated/0/Android/data/LoginSystem.Android/files/.__override__/libe_sqlite3.so" not found'. 06-19 10:26:51.995 D/Mono ( 5282): DllImport error loading library '/system/lib/libe_sqlite3': 'dlopen failed: library "/data/app/LoginSystem.Android-1/lib/x86//system/lib/libe_sqlite3" not found'. 06-19 10:26:51.996 D/Mono ( 5282): DllImport error loading library '/system/lib/libe_sqlite3.so': 'dlopen failed: library "/data/app/LoginSystem.Android-1/lib/x86//system/lib/libe_sqlite3.so" not found'. 06-19 10:26:51.996 D/Mono ( 5282): DllImport error loading library 'libe_sqlite3': 'dlopen failed: library "/data/app/LoginSystem.Android-1/lib/x86/libe_sqlite3" not found'. 06-19 10:26:51.999 D/Mono ( 5282): DllImport loaded library 'libe_sqlite3.so'. 06-19 10:26:52.000 D/Mono ( 5282): DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so'). 06-19 10:26:52.000 D/Mono ( 5282): Searching for 'sqlite3_libversion_number'. 06-19 10:26:52.007 D/Mono ( 5282): DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so'). 06-19 10:26:52.007 D/Mono ( 5282): Searching for 'sqlite3_open_v2'. 06-19 10:26:52.028 D/Mono ( 5282): DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so'). 06-19 10:26:52.028 D/Mono ( 5282): Searching for 'sqlite3_busy_timeout'. 06-19 10:26:52.036 D/Mono ( 5282): Unloading image System.Reflection.dll [0xab2fab00]. 06-19 10:26:52.036 D/Mono ( 5282): Image addref System.Reflection[0xaec950e0] -> System.Reflection.dll[0x9d005400]: 8 06-19 10:26:52.036 D/Mono ( 5282): Config attempting to parse: 'System.Reflection.dll.config'. 06-19 10:26:52.036 D/Mono ( 5282): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Reflection/System.Reflection.config'. 06-19 10:26:52.036 D/Mono ( 5282): Assembly Ref addref SQLite-net[0xad9e9dc0] -> System.Reflection[0x9dfec600]: 6 06-19 10:26:52.037 D/Mono ( 5282): Unloading image System.Linq.dll [0xab2fab00]. 06-19 10:26:52.038 D/Mono ( 5282): Image addref System.Linq[0xaec950e0] -> System.Linq.dll[0x9d007200]: 7 06-19 10:26:52.038 D/Mono ( 5282): Config attempting to parse: 'System.Linq.dll.config'. 06-19 10:26:52.038 D/Mono ( 5282): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Linq/System.Linq.config'. 06-19 10:26:52.038 D/Mono ( 5282): Assembly Ref addref SQLite-net[0xad9e9dc0] -> System.Linq[0x9dfec900]: 5 06-19 10:26:52.169 E/Surface ( 5282): getSlotFromBufferLocked: unknown buffer: 0x9bd87280 InspectorDebugSession(9): HandleTargetEvent: UnhandledException 06-19 10:27:04.139 I/art ( 5282): Thread[2,tid=5287,WaitingInMainSignalCatcherLoop,Thread*=0xab32c500,peer=0x12c770a0,"Signal Catcher"]: reacting to signal 3 06-19 10:27:04.224 I/art ( 5282): Wrote stack traces to '/data/anr/traces.txt' (检查user-management.state.js)

即可

如果您希望仅在用户具有适当角色时才能看到模板块,请查看vm.authorities = ['ROLE_USER', 'ROLE_ADMIN']指令。

另一部分是为了保护后端。如果使用当前的JHipster版本和SQL数据库,则权限存储在数据库中。将自定义角色添加到liquibase迁移的data.authorities

最后但并非最不重要的是,您可以在hasAnyAuthorityauthorities.csv中强制执行角色(只需查看现有的antMatchers)