日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java 匿名访问权限_java-春季安全性allowAll()不允许匿名访问

發(fā)布時(shí)間:2024/9/3 编程问答 56 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 匿名访问权限_java-春季安全性allowAll()不允许匿名访问 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

我有一個(gè)方法要同時(shí)允許匿名和身份驗(yàn)證訪問。

我正在使用基于Java配置的Spring Security 3.2.4。

覆蓋的configure方法(在我的自定義配置類中,擴(kuò)展了WebSecurityConfigurerAdapter)具有以下http塊:

http

.addFilterBefore(muiltpartFilter, ChannelProcessingFilter.class)

.addFilterBefore(cf, ChannelProcessingFilter.class)

.authorizeRequests()

.anyRequest()

.authenticated()

.and()

.authorizeRequests()

.antMatchers("/ping**")

.permitAll()

.and()

.formLogin()

.loginPage("/login")

.permitAll()

.and()

.logout()

.logoutUrl("/logout")

.logoutSuccessUrl("/login");

ping請求處理程序和方法位于還包含登錄處理程序的控制器中,并且沒有單獨(dú)的@PreAuthorize或其他可能引起此問題的注釋。

問題是匿名訪問被拒絕,用戶被重定向到登錄頁面。

在調(diào)試級別登錄時(shí),我從Spring Security看到以下反饋:

[2014-07-11 13:18:04,483] [DEBUG] [org.springframework.security.web.access.intercept.FilterSecurityInterceptor] Secure object: FilterInvocation: URL: /ping; Attributes: [authenticated]

[2014-07-11 13:18:04,483] [DEBUG] [org.springframework.security.web.access.intercept.FilterSecurityInterceptor] Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@6faad796: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@ffffa64e: RemoteIpAddress: 192.168.2.128; SessionId: 0EF6B13BBA5F00C020FF9C35A6E3FBA9; Granted Authorities: ROLE_ANONYMOUS

[2014-07-11 13:18:04,483] [DEBUG] [org.springframework.security.access.vote.AffirmativeBased] Voter: org.springframework.security.web.access.expression.WebExpressionVoter@123f2882, returned: -1

[2014-07-11 13:18:04,483] [DEBUG] [org.springframework.security.web.access.ExceptionTranslationFilter] Access is denied (user is anonymous); redirecting to authentication entry point

我要完成的工作是擁有一個(gè)可以隨時(shí)調(diào)用的方法,該方法將發(fā)送答復(fù),指示請求是否在登錄的會話中。

總結(jié)

以上是生活随笔為你收集整理的java 匿名访问权限_java-春季安全性allowAll()不允许匿名访问的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。