我們最近從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在彈簧啓動與安全 –