FormatToday
V2EX  ›  Java

关于 Spring Security 携带 token 反而 403 的问题请教

  •  
  •   FormatToday ·
    FormatToday · Jan 25, 2022 · 2695 views
    This topic created in 1568 days ago, the information mentioned may be changed or developed.

    简单说一下情况,项目前端是 vue,后端是 spring boot,spring security.

    对路径/list/all设置了公开访问:

     ...
     httpSecurity.antMatchers("/list/**").anonymous()
     ...
    

    在前端没有登录的时候没有问题,一登录接口就会报403.

    后面测试发现是登录的时候携带了 token 相关信息. 现在解决办法是前端去掉了 token ,但是想搞清原理,后端是在哪里报错的,怎么在后端去规避这个情况. debug 很久没找到头绪.

    3 replies    2022-01-25 14:17:35 +08:00
    sagfsguioafjdn
        1
    sagfsguioafjdn  
       Jan 25, 2022
    改为 permitAll 可禁用认证
    Tenlearn
        2
    Tenlearn  
       Jan 25, 2022
    anonymous 是仅允许匿名,如果是公开的话要用 permitAll
    FormatToday
        3
    FormatToday  
    OP
       Jan 25, 2022
    感谢
    @sagfsguioafjdn
    @Tenlearn
    两位大佬,确实是这
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   961 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 20:00 · PVG 04:00 · LAX 13:00 · JFK 16:00
    ♥ Do have faith in what you're doing.