Java Spring Force开发人员将在HTTP端点设置许可注释

发布于 2025-01-31 14:51:54 字数 84 浏览 4 评论 0原文

我想通过弹簧安全注释保护所有HTTP端点。有没有办法惩罚开发人员忘记对方法设置注释。春季配置?还是我必须编写自己的AOP/反射代码,以在编译时进行此操作?

I want to protect all http endpoints with spring security annotations. Is there a way to punish developers that forget setting annotations on methods. Spring configuration? Or do I have to write my own AOP/Reflection code that does this at compile time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离去的眼神 2025-02-07 14:51:54

我解决了实施单位测试,该单元测试通过Java反射收集所有端点并检查注释。如果开发人员忘记了它,詹金斯(Jenkins)会抱怨该测试失败了。

I solved that implementing a unit test that collects all endpoints with java reflection and checks for the annotation. If a developer forgets it, Jenkins will complain that this test failed.

温柔戏命师 2025-02-07 14:51:54

只需在POM文件上添加Spring Security Core Maven依赖性,此配置Spring将保护您的所有端点。
它将生成用户名作为用户和密码在您的控制台上显示的用户名,您也可以手动配置它。

just add spring security core maven dependency on your pom file , with this configuration spring will secure your all endpoints.
it will generate username as user and password will show on your console and you can also configure it manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文