【发布时间】:2017-10-03 07:58:05
【问题描述】:
我们最近从 Spring Boot 1.4.1 升级到了 1.5.2。 1.5.2 的特性之一是,如果 Spring Security 是包的一部分,那么它受到基本身份验证的保护。即使经过基本身份验证,我也无法访问/h2-console。它抛出 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 控制台。
【问题讨论】:
-
你有没有在 github 上用安全性在 Spring Boot 上引用这个 example
标签: spring spring-boot spring-security