Security
參考資料:
如何引入Security?
implementation 'org.springframework.boot:spring-boot-starter-security'初始頁面 & 預設帳密


如何調整預設的帳號密碼
如何調整輸入帳密的方式
利用 HTTP基本認證

Last updated
implementation 'org.springframework.boot:spring-boot-starter-security'


Last updated
spring.security.user.name=user # Default user name.
spring.security.user.password= # Password for the default user name.
spring.security.user.roles= # Granted roles for the default user name.@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// 直接跳過驗證
httpSecurity.authorizeRequests().anyRequest().permitAll();
// 利用 HTTP 基本認證
// For example: Use only Http Basic and not form login.
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic();
}
}