user-roles

Defining Roles with Rolify

萝らか妹 提交于 2019-11-27 04:39:40
问题 I am trying to make an app with Rails 4. I am looking at role management and want to use Rolify because it supports instance level role assignment. For others looking at the same problem, there are 2 really good answers below (I can only tick one but I used both). Check out lorefnon & Cyb3rDud3 answers below). I'm still figuring it out, but have made a migration with an array (as lorefnon shows) and the controller/routes functions (as Cyb3rDud3 shows). What is completely baffling me is that

How to check “hasRole” in Java Code with Spring Security?

两盒软妹~` 提交于 2019-11-26 23:51:58
How to check user authority or permission in Java Code ? For example - I want to show or hide button for user depending on role. There are annotations like: @PreAuthorize("hasRole('ROLE_USER')") How to make it in Java code? Something like : if(somethingHere.hasRole("ROLE_MANAGER")) { layout.addComponent(new Button("Edit users")); } JoseK Spring Security 3.0 has this API SecurityContextHolderAwareRequestWrapper.isUserInRole(String role) You'll have to inject the wrapper, before you use it. SecurityContextHolderAwareRequestWrapper you can use the isUserInRole method of the HttpServletRequest

T-SQL to list all the user mappings with database roles/permissions for a Login

时光总嘲笑我的痴心妄想 提交于 2019-11-26 21:15:47
问题 I am looking for a t-sql script which can list the databases and and the respective roles/privileges mapped for a particular user. Using SQL Server 2008 R2. 回答1: CREATE TABLE #tempww ( LoginName nvarchar(max), DBname nvarchar(max), Username nvarchar(max), AliasName nvarchar(max) ) INSERT INTO #tempww EXEC master..sp_msloginmappings -- display results SELECT * FROM #tempww ORDER BY dbname, username -- cleanup DROP TABLE #tempww 回答2: CREATE TABLE #tempww ( LoginName nvarchar(max), DBname

How to check “hasRole” in Java Code with Spring Security?

こ雲淡風輕ζ 提交于 2019-11-26 12:20:35
问题 How to check user authority or permission in Java Code ? For example - I want to show or hide button for user depending on role. There are annotations like: @PreAuthorize(\"hasRole(\'ROLE_USER\')\") How to make it in Java code? Something like : if(somethingHere.hasRole(\"ROLE_MANAGER\")) { layout.addComponent(new Button(\"Edit users\")); } 回答1: Spring Security 3.0 has this API SecurityContextHolderAwareRequestWrapper.isUserInRole(String role) You'll have to inject the wrapper, before you use