如何使用Spring安全性取消安全性方法>>

问题描述 投票:1回答:2

我已经为RESTful Web服务项目实现了Spring Security。它具有具有相同网址格式但具有不同请求方法类型的请求映射。

@RequestMapping(value = "/charity/accounts", method = RequestMethod.POST)
public AccountResponseDto createAccount(HttpServletResponse response, @RequestBody AccountRequestDto requestDTO) {
    // some logics here
}

@RequestMapping(value = "/charity/accounts", method = RequestMethod.GET)
public AccountResponseDto getAccount(HttpServletResponse response) {
    // some logics here
}

@RequestMapping(value = "/charity/accounts", method = RequestMethod.PUT)
public void updateAccount(HttpServletResponse response, @RequestBody AccountRequestDto requestDTO){
    // some logics here
}

当前所有这些方法都需要Authorization

才能执行,但是我需要删除createAccount(...)方法的授权。是否有基于注释的解决方案?

注意:

我需要一个不会对URL模式进行更改的解决方案,因为它将影响许多其他模块。

我已经为RESTful Web服务项目实现了Spring Security。它具有具有相同网址格式但具有不同请求方法类型的请求映射。 @RequestMapping(value =“ / charity / ...

java spring spring-mvc spring-security spring-annotations
2个回答
1
投票

下面是一个示例配置,该配置将允许请求signupabout


4
投票

这就是我们拥有角色,授权的原因。首先,我们可以定义谁可以进行GET / PUT / POST并相应地向用户授予权限。

© www.soinside.com 2019 - 2024. All rights reserved.