当前位置: 首页 > 知识库问答 >
问题:

Spring Security permitAll不允许匿名访问

空谦
2023-03-14
    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");

在调试级别进行日志记录时,我看到了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

我试图实现的是有一个可以在任何时候调用的方法,它将发送一个答复,指示请求是否在登录的会话中。

共有1个答案

郑帅
2023-03-14
.authorizeRequests()
        .antMatchers("/ping**")
        .permitAll()
        .and()
.authorizeRequests()
        .anyRequest()
        .authenticated()
        .and()
 类似资料:
  • 我有一个方法,我想允许匿名和身份验证访问。 我正在使用Spring Security3.2.4和基于java的配置。 在调试级别进行日志记录时,我看到了Spring Security的以下反馈: 我试图实现的是有一个可以在任何时候调用的方法,它将发送一个答复,指示请求是否在登录的会话中。

  • 如何在受Spring Security保护的Spring Boot应用程序中允许匿名访问springdoc-openapi-ui(openapi3.0)?

  • 问题内容: 我看到以下错误: 使用此代码: 是什么原因引起的,如何解决? 问题答案: 在当前域之外发出ajax请求时,Javascript是受限制的。 例1:您的域名为example.com,并且您想向test.com提出请求=>您不能。 例2:您的域名是example.com,并且您想向inner.example.com发送请求,但是您不能。 例3:您的域名为example.com:80,并且您

  • 问题内容: 我需要用户将文件上传到我的Google云端存储,而无需通过Google进行身份验证。这些主要是运行我的应用程序的Windows台式机/笔记本电脑用户。阅读完不同的身份验证机制后,我发现可恢复的上传可能是我想要的。上面的页面提供了有关如何实现此功能的REST API。我有几个问题: 这是第三方将数据上传到我的帐户而不登录任何Google帐户的正确方法吗? 是否存在包含可恢复上传相关代码的

  • 我试图理解为什么客户端中的匿名用户不能获得访问令牌。 我在Spring博客上找到了这篇关于这个主题的帖子,Dave Syer对此做出了回答: 请记住,这是一个与客户端应用程序有关的问题,而不是auth服务器,所以请尝试从cllient的角度来看它。在步骤1。有一个用户试图访问受保护的资源。如果您不能对该用户进行身份认证,那么您的所有用户最终都将获得相同的访问令牌(第一个用户使用他在auth服务器上

  • 此url位于AWS API网关中,方法为get,stage部署良好。我在aws文档之后启用了CORS。 -资源->操作->启用CORS->默认设置->启用CORS并替换CORS头。在CORS结果中没有错误日志。 我不是profesional web开发人员,我的浏览器是Safari。 以下是我查询“http://my.com”的代码 控制台打印错误:XMLHttpRequest不能加载“http: