我们最近从Spring Boot 1.4.1升级到1.5.2。 1.5.2的一个特点是,如果Spring Security是包的一部分,那么它受到基本身份验证的保护。即使经过基本身份验证,我仍无法访问/h2-console
。它抛出403禁止。Spring Boot/h2-console在Spring Security 1.5.2中引发403问题
application.yml
:
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:file:../app-db/app_db;AUTO_SERVER=TRUE
username: sa
password: sa
initialize: false
jpa:
hibernate:
ddl-auto: validate
show-sql: true
database-platform: org.hibernate.dialect.H2Dialect
h2:
console:
enabled: true
settings:
web-allow-others: true
allowed:
resources: /h2-console/**
我甚至明确允许/h2-console/**
httpSecurity.authorizeRequests()
.antMatchers(allowedResources)
.permitAll()
试图访问localhost:8080/h2-console
时,我不断收到403。 我试过很多设置,以及将:
management.security.enabled=true
security.basic.enabled=true
但我无法访问H2控制台。
你有没有提到这个[示例](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-secure-custom)on github在弹簧启动与安全 –