【问题标题】:Spring authentication is working only for first apiSpring 身份验证仅适用于第一个 api
【发布时间】:2021-08-11 17:36:41
【问题描述】:

当我通过邮递员访问第一个 API 时,它会询问用户/密码,但在第一个 API 之后它也可以在没有身份验证的情况下工作

http.authorizeRequests()
                .antMatchers("/altitude/bro/code").hasRole(Constants.USER)
                .anyRequest().authenticated()
                .and()
                .httpBasic().and().csrf().disable();

【问题讨论】:

  • 不,不是。成功认证后,浏览器会自动包含基本认证头,因此您不需要每次都重新认证。

标签: spring-boot spring-security


【解决方案1】:

如果你想重新认证,要么删除cookies,要么进入Postman的设置,让它不再使用cookies。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-14
    • 1970-01-01
    • 2019-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-08
    • 2015-12-11
    相关资源
    最近更新 更多