Java Spring Force开发人员将在HTTP端点设置许可注释
我想通过弹簧安全注释保护所有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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我解决了实施单位测试,该单元测试通过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.
只需在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.