V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Kevinyy
V2EX  ›  Java

请教一个关于 Spring-Security 开放 URL 白名单问题

  •  
  •   Kevinyy · 2022-09-20 12:30:13 +08:00 · 1707 次点击
    这是一个创建于 556 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题描述:项目中有这样一个需求,利用 Nacos 配置中心,可以在项目运行后动态更改的 URL 白名单,不需要鉴权直接放行。目前鉴权使用的是 Spring-Security 框架,项目本身是 SpringBoot 单体项目。各位大佬能指点迷津。

    3 条回复    2022-09-21 10:07:25 +08:00
    2020beBetter
        1
    2020beBetter  
       2022-09-20 13:09:05 +08:00
    https://blog.csdn.net/L_zsen/article/details/118517148

    这个博主,不就满足你的需求?
    aboat365
        2
    aboat365  
       2022-09-21 09:29:28 +08:00
    Spring-Security 动端权限,只需要自定义写个 AccessDecisionVoter 接口实现即可,详细鉴权逻辑内容在 vote 方法中。
    frank1256
        3
    frank1256  
       2022-09-21 10:07:25 +08:00
    1 、nacos 动态刷新,最简单的配合 @value 注解即可。用 @value 注解一个 list 类型 property ,eg:whiteList ,要配置 RefreshScope
    2 、security 配置 http.pathMatchers(ArrayUtil.toArray(whiteList)).permitAll()
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5374 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 07:32 · PVG 15:32 · LAX 00:32 · JFK 03:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.