gpt4 book ai didi

spring - 在 Grails 的 Spring Security Rest Plugin 中注销时出现 404

转载 作者:行者123 更新时间:2023-12-02 14:40:07 25 4
gpt4 key购买 nike

我正在使用 Spring Security Rest Plugin 在我的项目 ( Grails - Angularjs ) 上设置安全系统适用于 Grails 2.4.4 的 v1.5.4(使用 spring 安全核心 2.0.0)。关于这个插件的文档可以找到here .

我正在使用 postman chrome rest 客户端测试登录和注销,我可以登录,但是当我注销时得到 404。

在文档中明确表示:

The logout filter exposes an endpoint for deleting tokens. It will read the token from an HTTP header. If found, will delete it from the storage, sending a 200 response. Otherwise, it will send a 404 response

You can configure it in Config.groovy using this properties:

Config key...................................................................................Default value

grails.plugin.springsecurity.rest.logout.endpointUrl....................../api/logout grails.plugin.springsecurity.rest.token.validation.headerName....X-Auth-Token



因此,在成功登录后,我尝试使用 GET 方法注销该 URL( my_host_url/api/logout )并发送 header X-Auth-Token 使用我之前从登录获得的 token 。

但我一直收到 404。见下图

enter image description here

编辑 :我正在设置这样的链图(为了获得无状态行为):
grails.plugin.springsecurity.filterChain.chainMap = [
'/api/**': 'JOINED_FILTERS,-exceptionTranslationFilter,-authenticationProcessingFilter,-securityContextPersistenceFilter,-rememberMeAuthenticationFilter', // Stateless chain
'/**': 'JOINED_FILTERS,-restTokenValidationFilter,-restExceptionTranslationFilter' // Traditional chain
]

所以。我在这里做错了什么,或者我错过了什么?

提前致谢!

最佳答案

您错过了文档的另一个摘录。这是您引用的 block 之前的警告消息,并说:

Logout is not possible when using JWT tokens (the default strategy), as no state is kept in the server.

If you still want to have logout, you can provide your own implementation by creating a subclass of JwtTokenStorageService and overriding the methods storeToken and removeToken. Then, register your implementation in resources.groovy as tokenStorageService.

关于spring - 在 Grails 的 Spring Security Rest Plugin 中注销时出现 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41744671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com