第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么我的 spring 安全配置不起作用,我的預(yù)期如何?

為什么我的 spring 安全配置不起作用,我的預(yù)期如何?

寶慕林4294392 2021-07-01 10:15:07
我有一個(gè)問(wèn)題……我有這樣的 SecurityConfig.class(這是一個(gè)擴(kuò)展 WebSecurityConfigurerAdapter 的類):/** * This method define which resources are public and which are secured */@Overrideprotected void configure(HttpSecurity http) throws Exception {    http.cors().and().csrf().disable().authorizeRequests()            .antMatchers(HttpMethod.POST, SecurityConstants.SIGN_UP_URL).permitAll().anyRequest()            .authenticated()            .and().addFilter(new JWTAuthenticationFilter(authenticationManager()))            .addFilter(new JWTAuthorizationFilter(authenticationManager()))         .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);}但我的問(wèn)題是,當(dāng)我嘗試訪問(wèn) SIGN_UP_URL 時(shí),應(yīng)用程序正在嘗試使用此過(guò)濾器對(duì)用戶進(jìn)行身份驗(yàn)證:@Overrideprotected void doFilterInternal(HttpServletRequest req,                                HttpServletResponse res,                                FilterChain chain) throws IOException, ServletException {    String header = req.getHeader(SecurityConstants.HEADER_STRING);    if (header == null || !header.startsWith(SecurityConstants.TOKEN_PREFIX)) {        chain.doFilter(req, res);        res.sendError(HttpServletResponse.SC_UNAUTHORIZED,"Access Denied");        return;    }    UsernamePasswordAuthenticationToken authentication = getAuthentication(req);    SecurityContextHolder.getContext().setAuthentication(authentication);    chain.doFilter(req, res);}檢查到那時(shí)為空的標(biāo)頭(因?yàn)樵?URL 理論上不需要身份驗(yàn)證或任何令牌)這應(yīng)該不會(huì)發(fā)生,有人可以幫我嗎?當(dāng)我在沒(méi)有身份驗(yàn)證的情況下為所有用戶打開安全性時(shí),該方法成功執(zhí)行
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 256 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)