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

在使用 Spring 写 REST 接口工程时,你是使用 Spring Security 还是自定义的逻辑来实现安全?

  •  
  •   qwerthhusn · 2020-10-29 10:56:01 +08:00 · 1572 次点击
    这是一个创建于 1246 天前的主题,其中的信息可能已经有所发展或是发生改变。

    自己实现的话感觉也不复杂,至少逻辑自己很清楚比较清晰。

    使用 Spring Security 的话,感觉看着很简单,但是实际用起来没那么简单。而且 Spring Security 拦截后返回给 Client 的响应不是自己想要的样子。我是加上一个 HandlerInterceptor 处理/error请求。

    3 条回复    2020-10-29 11:12:37 +08:00
    Oktfolio
        1
    Oktfolio  
       2020-10-29 10:59:22 +08:00   ❤️ 2
    http.exceptionHandling()
    .accessDeniedHandler(accessDeniedHandler);

    http.formLogin()
    .successHandler(authenticationSuccessHandler)
    .failureHandler(authenticationFailureHandler);

    http.exceptionHandling()
    .authenticationEntryPoint(authenticationEntryPoint);

    http.logout()
    .logoutSuccessHandler(logoutSuccessHandler);
    qwerthhusn
        2
    qwerthhusn  
    OP
       2020-10-29 11:08:24 +08:00
    @Oktfolio 还有这些啊,我去,很多 Spring Security 的概念和功能我都不知道,看来我需要仔细看看 Spring Security 的文档了
    leafre
        3
    leafre  
       2020-10-29 11:12:37 +08:00
    shiro 轻量
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5321 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 09:16 · PVG 17:16 · LAX 02:16 · JFK 05:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.