首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Basic / JWT令牌,删除Basic弹出

Basic / JWT令牌,删除Basic弹出
EN

Stack Overflow用户
提问于 2022-01-19 11:32:45
回答 1查看 167关注 0票数 -1

我使用基本的auth和spring安全性(JWT令牌) (Springboot)的组合。

我有以下设置: web.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    <display-name>det</display-name>
    <description>det</description>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>images</web-resource-name>
            <url-pattern>/images/*</url-pattern>
        </web-resource-collection>
        <!-- OMIT auth-constraint -->
    </security-constraint>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Entire Application</web-resource-name>
            <url-pattern>/login</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>User</role-name>
        </auth-constraint>
        <user-data-constraint>
            <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

因此,登录服务返回一个JWT令牌。然后spring安全性接管并使用令牌来验证rest服务的使用。

这一切都有效。我只有一个问题。当用户发送错误的凭据时,我得到一个401错误,弹出窗口就会出现。我想避免这件事。我尝试使用一个过滤器来更改响应代码,但是它似乎没有被触发。

我该怎么解决这个问题。

EN

回答 1

Stack Overflow用户

发布于 2022-01-19 13:45:41

我找到了解决方案,对401个错误使用了一个错误servlet,并从响应头中删除了WWW-身份验证值。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70769858

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档