Spring Security 3.1(Spring Security 3.1)
有人可以帮我这个吗? 感谢你的帮助。
我使用Spring security 3.1和create-session =“stateless”选项。 抛出“InsufficientAuthenticationException”:“访问此资源需要完全身份验证”ExceptionTranslationFilter例外。
我无法理解我做错了什么以及为什么我得到这个例外。 由于此异常表明凭据不正确,但我可以看到凭据正在通过请求。但是我的401未经授权
事实是用户能够正确登录并且我也在控制台上收到消息。 但由于访问被拒绝异常,它再次被重定向到登录页面。
我在这里放置代码
弹簧security.xml文件
<http entry-point-ref="negotiateSecurityFilterEntryPoint" create-session="stateless" > <intercept-url pattern="/user/loginuser" access="ROLE_ANONYMOUS"/> <intercept-url pattern="/**" access="ROLE_USER"/> <custom-filter ref="securityContextPersistenceFilter" after="BASIC_AUTH_FILTER" /> <custom-filter ref="ldapAuthFilter" position="CAS_FILTER" /> <custom-filter ref="databaseAuthFilter" position="FORM_LOGIN_FILTER" /> </http> <bean id="securityContextPersistenceFilter" class="org.springframework.security.web.context.SecurityContextPersistenceFilter"> <property name='securityContextRepository'> <bean class='org.springframework.security.web.context.HttpSessionSecurityContextRepository'> <property name='allowSessionCreation' value='false' /> </bean> </property> </bean>
Could someone help me on this. appreciate your help.
I am using Spring security 3.1 with create-session="stateless" option. Which throwing "InsufficientAuthenticationException" : "Full authentication is required to access this resource" exception of ExceptionTranslationFilter.
I am not able to understand what I am doing wrong and why I am getting this exception . As this exception stated that the credentials are not proper but I can see the credentials are going through request.Still I am getting 401 unauthorized
Fact is that the user is able to login properly & I get the message on console also. But again it is redirecting to login page due to access denied exception.
Here I am putting the code
Spring-Security.xml
<http entry-point-ref="negotiateSecurityFilterEntryPoint" create-session="stateless" > <intercept-url pattern="/user/loginuser" access="ROLE_ANONYMOUS"/> <intercept-url pattern="/**" access="ROLE_USER"/> <custom-filter ref="securityContextPersistenceFilter" after="BASIC_AUTH_FILTER" /> <custom-filter ref="ldapAuthFilter" position="CAS_FILTER" /> <custom-filter ref="databaseAuthFilter" position="FORM_LOGIN_FILTER" /> </http> <bean id="securityContextPersistenceFilter" class="org.springframework.security.web.context.SecurityContextPersistenceFilter"> <property name='securityContextRepository'> <bean class='org.springframework.security.web.context.HttpSessionSecurityContextRepository'> <property name='allowSessionCreation' value='false' /> </bean> </property> </bean>
原文:https://stackoverflow.com/questions/38521027
最满意答案
你现在可能处于foreach循环中吗? 这是造成这种情况的常用方法 - 在循环内执行n + 1(每个项目的查询)时对第一个读取器进行预处理。 通常的修复方法是(其中之一):
- 配置查询以急切地获取嵌套数据,以便它已经可用
- 将外部循环缓冲到列表/数组中,以便在内部循环开始之前完成读取器
Are you perhaps in a foreach loop at this point? That is the usual way of causing this - foreaching over the first reader while doing an n+1 (query per item) inside the loop. The usual fixes are (one of):
- configure the query to eagerly fetch the nested data so that it is already available
- buffer the outer loop into a list/array, so that the reader is finished before the inner loop starts
相关问答
更多-
这是指向SqlCacheDependency的msdn链接 这里是LINQ和SqlCacheDependency This is an msdn link to SqlCacheDependency and here's for LINQ & SqlCacheDependency
-
右键单击模型设计器并选择“从数据库更新模型”,将弹出一个对话框。 点击确定,你的模型将被刷新。 仅供参考,我使用的是EF 4.0,而我跳过了早期版本,所以我无法告诉您VS 2008中的情况。 Right-click on the model designer and choose "Update Model from Database", and a dialog box will pop up. Click OK and your model will be refreshed. FYI, I'm usi ...
-
实体数据模型有助于从数据库请求数据,它不存储数据。 您的请求将针对服务器数据完成,因此您将从数据库获取最新数据。 但是,如果数据库的结构发生更改,则必须相应地重新创建模型类。 The entity data model helps requesting data from the DB, it doesn't store data. Your request will be done against the server data, so you will get up to date data from ...
-
右键单击您的项目,然后选择添加新项。 从添加新项目并选择“ADO.net实体数据模型”。 提供名称和所有必要的东西,附上您的数据库和签名凭据。 完成.edmx文件后,将添加到您的项目中。 打开edmx文件并右键单击设计视图,然后选择“添加代码生成项”。 出现添加新项目面板。 从面板中选择“ADO.net DbContext Generator”。 给出名称并添加它。 克里特岛是DbContext类的一个对象。 使用DbContex Object方法插入/更新/删除命令来完成你的工作。 Right click ...
-
这完全取决于您的应用,范围和要求。 为了层次而引入抽象层意味着引入复杂性和间接性,通常它并不能真正让你到处都是。 对于过度使用分层架构,目前正在引入Lasagna Software这一术语 - 取代臭名昭着的Spaghetti软件 。 为了清楚起见,我不打算反对抽象层。 使用它们在很大程度上取决于您的具体要求。 我从一个简单的架构开始,根据需要添加层,以确保可测试性和可维护性。 当前版本的Entity Framework (撰写本文时为4.1)允许使用POCO , DbContext非常类似于Reposit ...
-
你现在可能处于foreach循环中吗? 这是造成这种情况的常用方法 - 在循环内执行n + 1(每个项目的查询)时对第一个读取器进行预处理。 通常的修复方法是(其中之一): 配置查询以急切地获取嵌套数据,以便它已经可用 将外部循环缓冲到列表/数组中,以便在内部循环开始之前完成读取器 Are you perhaps in a foreach loop at this point? That is the usual way of causing this - foreaching over the first ...
-
很一般的问题,但有些想法。 性能: 只要所有开发人员都有线索,简单的SqlCommand和DataReader在性能方面会明显加快。 使用.net 4.5和EF 5,似乎EF将获得良好的性能提升,但普通的SQL总是会更快。 请看这里的一些数字: http : //blogs.msdn.com/b/adonet/archive/2012/02/14/sneak-preview-entity-framework-5-0-performance-improvements.aspx 普通的ADO.NET也支持异步模 ...
-
我想我刚刚找到了一些解决方案,我改变了我的删除控制器: [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) { // i change this piece of code, not really sure what it means though // very appreciate if ...
-
如何从ADO.net模型动态创建动态数据传输对象(How do I create a dynamic data transfer object dynamically from ADO.net model)[2022-04-09]
我被迫创建“数据传输对象”来去除不需要传输的关系和数据。 而你认为这是坏事? 相反,正是如此设计的ASP.NET MVC应用程序应该如何工作:它应该使用视图模型。 而且不仅适用于返回JSON而且适用于所有操作的操作。 您应该避免将EF模型传递给视图。 观点永远不应该知道EF的存在。 视图模型是专门为满足视图要求而设计的类。 因此,控制器查询存储库以获取模型(EF),将其映射到视图模型并将其传递给要显示的视图。 要简化模型和视图模型之间的映射,可以使用AutoMapper 。 I've been forced ... -
ADO.NET实体数据模型BUG(ADO.NET Entity Data Model BUG)[2023-07-26]
我发现这可能是第三方数据适配器处于奇怪状态的问题。 打开您的View > Server Explorer并删除您的第三方数据连接。 然后,再次尝试打开向导。 I've found this can be a bug with third party data adapters being left in strange states. Open your View > Server Explorer and remove your third-party data connections. Then, tr ...