[英]two authentication mechanism on a spring boot application (Basic & JWT)
我有一個spring boot應用程序,我剛剛完成了基於jwt
的無狀態身份驗證/授權模塊。
這就是我配置安全模塊的方式:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.exceptionHandling()
.authenticationEntryPoint(authenticationEntryPoint)
.and()
.csrf()
.disable()
.headers()
.frameOptions()
.disable()
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/api/authenticate").permitAll()
.antMatchers("/api/**").authenticated()
.and()
.apply(securityConfigurerAdapter());
}
所以基本上如果我想訪問url /api/jobs
我會收到401錯誤,除非我發送了在/api/authenticate
上成功驗證后獲得的持有者令牌。
我需要知道的是,如果可以在不提供持有者令牌的情況下訪問/api/jobs
,則使用帶登錄和passowrd的基本http身份驗證
是的,這是可能的,只要確保你有:
http.httpBasic();
在您的配置中。 該構建器還具有其他方法來配置基本身份驗證的詳細信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.