gpt4 book ai didi

java - spring security framework中不使用ROLE_前缀的影响

转载 作者:行者123 更新时间:2023-11-30 08:55:00 24 4
gpt4 key购买 nike

如果我在@Secured Annotation 中使用没有“ROLE_”前缀的行,这里有什么影响?假设 spring security RoleVoter 期望角色以 "ROLE_"为前缀。

  • @Secured({"ADMIN"})
  • @Secured({"ROLE_ADMIN"}) public void sampleMethod(SampleClass sampleObject) { 操作;

最佳答案

除非您将前缀设置为空,否则不会评估第一个选项。

RoleVoter.setRolePrefix("");

因此该方法将不安全。正如您提到的,RoleVoter 的默认前缀是 "ROLE_"

关于java - spring security framework中不使用ROLE_前缀的影响,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29245599/

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