Spring Security登录无法远程工作

时间:2019-01-25 14:54:40

标签: java spring spring-boot spring-security

我已经建立了一个非常简单的登录名(使用jdbc身份验证-从参考+自定义复制/粘贴到我的端点)/ 在本地运行(访问本地主机)时,完美运行正在部署(春季启动),并尝试远程访问服务器,该服务器根本无法正常工作

我找不到任何异常。但是必须有一些东西,因为它正在到达/error处理程序。我有自定义错误页面,它将打印出堆栈跟踪信息,但没有任何内容。

当增加了更多调试详细信息时(添加了application.property logging.level.org.springframework.security: DEBUG),我发现(在/login之后)立即识别出某些anonymousUser。但是完全没有错误。

可以完全访问数据库,因为应用程序的其他部分无需身份验证即可正常访问。

@Configuration
public class ApplicationSecurity extends WebSecurityConfigurerAdapter {
  @Override
  protected void configure( HttpSecurity http ) throws Exception {
    http
        .logout()
        .invalidateHttpSession( true )
        .clearAuthentication( true )
        .and()
        .authorizeRequests()
        .antMatchers( "/tags/**" ).authenticated()
        .anyRequest().permitAll()
        .and()
        .formLogin()
        .and()
        .httpBasic();
  }

  @Autowired
  @Qualifier( "localDataSource" )
  private DataSource localDataSource;

  @Autowired
  public void configureGlobal( AuthenticationManagerBuilder auth ) throws Exception {
    auth.jdbcAuthentication()
        .dataSource( localDataSource )
    ;
  }

春季启动版本:2.1.0.RELEASE Java 8

编辑:

事实证明,设置没有问题。我发现第二天它可以在其他浏览器或同一浏览器中运行。它帮助我发现它与会话缓存更相关。

一旦遇到这种情况,我就会进入开发人员控制台(firefox)并清除所有会话数据。并且它开始正常工作。

0 个答案:

没有答案