我正在一个具有树状数据库模式的站点上工作.从上到下我有:
用户权限系统必须是灵活的,因为有人可以在树的任何级别获得或限制访问.例如,管理位置x的人将默认具有对位置x下方的所有车队和位置x下方的所有车辆的完全访问权.但我也应该能够限制用户访问位置x下面的任何节点.
为这样的权限系统开发模式的正确方法是什么?存储用户有权访问的每个节点是否现实,即使它是多余的?我的目标是能够轻松运行查询,例如获取用户有权访问的所有位置.
与所有业务线应用程序一样,应用程序可能具有多个Users
,其中一些应用程序已Roles
分配给它们.我们最近转向WPF MVVM架构,并寻找为每个登录用户分配角色的最佳方法.互联网上有许多术语,例如Authentication,RoleManager,LoginService等,但我不确定要解决哪些问题.
这是我们拥有的:
在单个项目中开发的小型企业应用程序(具有20个表单).我们使用MVVM
架构,LINQ-to-SQL
作为DataAccess Model
,使用Repository pattern
和Unit Of Work
.
我们想要什么:
有不同的形式,每个表单都有插入,更新,删除,打印等操作.我们想要的是根据他的角色限制登录用户 - 他可以执行的任务.即,例如,Admin可以随意对应用程序执行" 任何操作 ",而某些其他用户可能不被允许查看某些表单或执行某些操作(即更新或删除).
那么我们怎样才能做到这一点; 在桌面LOB应用程序中使用MVVM体系结构可以使用何种服务来执行此完整机制.技术术语或教程链接将很有帮助.
我希望我很清楚,非常感谢你.
编辑: 我经历了很多论坛和文章,但他们都专注于ASP.NET.仍无法找到WPF中角色分配的具体实现.ASP.NET上的源代码与WPF不符.
我正在尝试使用@PreAuthorize注释的弹簧安全性(用户角色授权)的示例,遇到以下错误.
Caused by: org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.aopalliance.intercept.MethodInterceptor]:
Factory method 'methodSecurityInterceptor' threw exception; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'methodSecurityInterceptor': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 91 more
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'methodSecurityInterceptor': Requested bean is currently in creation: I
s there an unresolvable circular reference?
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:347)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor.getAdvice(MethodSecurityMetadataSourceAdvisor.java:107)
at org.springframework.aop.aspectj.AspectJProxyUtils.isAspectJAdvice(AspectJProxyUtils.java:67)
at org.springframework.aop.aspectj.AspectJProxyUtils.makeAdvisorChainAspectJCapableIfNecessary(AspectJProxyUtils.java:49)
Run Code Online (Sandbox Code Playgroud)
我的WebSecurityConfigurerAdapter …
我试图在jhipster中添加和更改角色.首先,我只是尝试将一个用例的角色从用户更改为admin.然后我测试了它,即使角色是ROLE_ADMIN,用户也可以添加员工,所以它没有改变任何东西.
我还添加了一个名为MANAGER的新角色.我编辑了AuthoritiesConstants.java并为JHI_AUTHORITY-table添加了新角色.我应该做些什么还是这足以使这个工作?
state('employee.new', {
parent: 'employee',
url: '/new',
data: {
roles: ['ROLE_ADMIN'],
},
onEnter: ['$stateParams', '$state', '$modal', function($stateParams, $state, $modal) {
$modal.open({
templateUrl: 'scripts/app/entities/employee/employee-dialog.html',
controller: 'EmployeeDialogController',
size: 'lg',
resolve: {
entity: function () {
return {nameFirst: null, nameLast: null, taxNumber: null, isFinnish: null, finnishSOTU: null, valtticard: null, birthDate: null, isContactPerson: null, isTiedonantaja: null, cOTARKENNE: null, id: null};
}
}
}).result.then(function(result) {
$state.go('employee', null, { reload: true });
}, function() {
$state.go('employee');
})
}]
})
Run Code Online (Sandbox Code Playgroud) HttpServletRequest isUserInRole()方法将根据角色是否存在返回布尔值.现在,如果它正在这样做,它应该具有登录用户的完整角色列表.如何获得完整的角色列表?
我正在尝试使用ibm-application-bnd.xml映射用户组.将它放入META-INF文件夹.在尝试访问安全页面时获取下一条消息:
[08.05.15 17:42:21:242 MSK] 00000084 WebCollaborat A SECJ0129E: ... GET ? null:/loginmodule/date/, Authorization failed, Not granted any of the required roles: user-role
Run Code Online (Sandbox Code Playgroud)
当我尝试使用ibm控制台进行配置时,它可以工作.所有配置WAS都写入ibm-application-bnd.xmi而不是ibm-application-bnd.xml.
我错了什么?将Websphere AS 8.5.5与Java 1.6一起使用
IBM应用-bnd.xml:
<?xml version="1.0" encoding="UTF-8"?>
<application-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/dxml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-bnd_1_2.xsd"
xmlns="http://websphere.ibm.com/xml/ns/javaee" version="1.2">
<security-role name="user-role">
<group name="user-group" />
</security-role>
</application-bnd>
Run Code Online (Sandbox Code Playgroud)
web.xml中:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<security-constraint>
<display-name>Constraint</display-name>
<web-resource-collection>
<web-resource-name>secrets</web-resource-name>
<description />
<url-pattern>/date/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user-role</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>user-role</role-name>
</security-role>
<servlet>
<servlet-name>date</servlet-name>
<servlet-class>ru.servlet.TimeServlet</servlet-class>
</servlet>
<servlet-mapping> …
Run Code Online (Sandbox Code Playgroud) 我是 spring mvc 的新手,在我现有的项目中,有一个管理员,他们有权更新数据,但现在我需要创建 2 个新管理员,admin1 和 admin2,它们在登录时只能看到有限的页面,例如:
当管理员登录时,他们可以在菜单栏中看到添加数据、更新数据、发布消息页面。但在 Admin1 的情况下,只能在菜单栏中看到 Post meassage 页面。
所以,请指导我如何在 spring mvc 中完成这项任务 提前致谢。
一个伟大的问候社区
我的问题与Django中的管理用户和架构用户的类型有关,一开始我请你道歉,以防万一我的问题可能太"新手"或没有意义,我开始把我与Django联系起来用户模式及其在项目中的不同工作可能性.
我有以下情况.
我正在构建一个应用程序,其中我将有三个不同的用户类型:
我使用默认的Django身份验证方案(django.contrib.auth).
最初,我确实在这个实体方案中思考,其中User表是auth_user
Django保存用户创建的表:
我有is_patient
,is_medical
和is_physiotherapist
用户表中的布尔属性字段.
像特定细节一样,我理解在Django默认模型中,用户无法修改或添加属性或字段.
这是一个重要而有力的理由我不能添加的 is_patient
,is_medical
并且is_physiotherapist
在用户表布尔字段.
经典建议是使用Userprofile表扩展User模型,在该表中我通过OneToOne关系向User Model添加字段或属性.基本样本如下:
就是这样,我得到了我在Django的用户可以拥有现场照片并在特定时刻上传一个...
利用前面的方案,以下模式可以适用于管理用户角色(和用户类型)patient
,也可以作为替代方案?medical
physiotherapist
我会在以下方面建立关系:
用户医疗和用户患者
用户物理治疗师和用户患者
他们和其他桌子之间......
通过这种方法,这些关系不会受到影响吗?
将在Users和UserProfile表之间保存不同的用户.这是可扩展性意义上的一个好习惯吗?我的表可能是崩溃还是我的数据库?
此外,我还看到了其他替代方案,例如:
我将有一个独立或独立的角色表/模型,这可以与Django用户模型相关(一个用户可以通过示例拥有许多角色)当我想要存储有关特定角色的角色的独家信息时,这种方法非常有用?
我忽略或不知道让我工作的粒度等级.我只看到权限和授权系统允许我使用创建,编辑和删除操作....
在这里,我可以看到创建群组吗?例如,医疗组并为其分配权限并将此权限链接到组成该组的用户?这是另一个好的选择吗?这个选项似乎更单一,虽然我不知道用户是否可以根据具有的组权限进行一些操作...我不知道这个想法是否正确/正确
我对患者,医疗和物理治疗师用户的要求需要构建自定义用户模型吗?
pom.xml
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Hoxton.SR10</version>
</parent>
...
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.5</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当使用 springdoc-openapi-ui、springdoc-openapi-security 以及 spring-boot-starter-security 和 keycloak-spring-boot-starter 时,我们面临一个问题。
pom.xml
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-security</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
<version>12.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.4.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
DummySecurityConfig(当前使用配置文件dev):
@Profile({"test", "dev"})
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(
prePostEnabled = true,
securedEnabled = true,
jsr250Enabled = true)
@EnableWebMvc
public class DummySecurityConfig extends WebSecurityConfigurerAdapter implements WebMvcConfigurer {
protected static final String[] ACTUATOR_WHITELIST = {
"/actuator/**"
};
protected …
Run Code Online (Sandbox Code Playgroud) 我需要添加两种不同的运费,具体取决于购买用户的角色。我的角色是“wholesale_customer”,不应支付运费。但是,如果购物车小计等于或小于 \xe2\x82\xac90,则必须阻止购买并在结账时添加一条消息。(记住一定要达到\xe2\x82\xac90的数量)
\n另一个选项是所有其他 WordPress 角色,如果他们的购物车小计为 \xe2\x82\xac40 或更少,则需要支付 \xe2\x82\xac5 运费。
\n我已在 WooCommerce 中配置了送货,我创建了两种具有最低订单金额的免费送货方式,一种为 \xe2\x82\xac40,另一种为 \xe2\x82\xac90。
\n问题是,具有“wholesale_customer”角色的用户在达到 \xe2\x82\xac40 的金额时,也启用了该免费送货方法,但这种情况不应该发生,因为对于此用户角色(\' Wholesale_customer \' ) 如果购买量超过 \xe2\x82\xac90 的最小值,则免运费。
\n我已按以下方式在 WooCommerce 中配置发货,创建 2 种发货方式:\n- 其中一种在 \xe2\x82\xac90 处具有“所需的最小数量”
\n另一个在 \xe2\x82\xac40 处具有“所需的最小数量”
\n以及其中一份运费为 \xe2\x82\xac0。
\n我尝试添加以下功能来添加以获得我需要的内容,但所有运输方式始终处于启用状态,因此也为用户激活了“最小 \xe2\x82\xac40 免费送货”的零售运输方式具有批发客户角色的情况不应发生这种情况,因为具有此角色的用户将受益于不属于他们的好处。
\n我正在展示一些我用来尝试做我正在寻找的事情的代码,因为我做了很多测试。只是我还没有办法添加我在演示文稿中提到的角色“wholesale_customer\”的文本\n显示 WooCommerce 设置的图像
\nfunction custom_shipping_methods_visibility( $available_methods ) {\n \n $subtotal = WC()->cart->subtotal;\n \n $user = wp_get_current_user();\n $user_roles = $user->roles;\n \n // Check user role and cart subtotal to …
Run Code Online (Sandbox Code Playgroud) user-roles ×10
java ×4
php ×2
c# ×1
django ×1
django-users ×1
jaas ×1
jhipster ×1
mvvm ×1
mysql ×1
openapi ×1
python ×1
servlets ×1
spring ×1
spring-boot ×1
spring-mvc ×1
springdoc ×1
wcf ×1
websphere ×1
woocommerce ×1
wordpress ×1
wpf ×1