首页 \ 问答 \ Spring Security 3.1(Spring Security 3.1)

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
更新时间:2023-12-09 17:12

最满意答案

你现在可能处于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 ...
  • 我被迫创建“数据传输对象”来去除不需要传输的关系和数据。 而你认为这是坏事? 相反,正是如此设计的ASP.NET MVC应用程序应该如何工作:它应该使用视图模型。 而且不仅适用于返回JSON而且适用于所有操作的操作。 您应该避免将EF模型传递给视图。 观点永远不应该知道EF的存在。 视图模型是专门为满足视图要求而设计的类。 因此,控制器查询存储库以获取模型(EF),将其映射到视图模型并将其传递给要显示的视图。 要简化模型和视图模型之间的映射,可以使用AutoMapper 。 I've been forced ...
  • 我发现这可能是第三方数据适配器处于奇怪状态的问题。 打开您的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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)