secure a REST API

secure a REST API using Spring Security

--

  • A REST API can be secured using Spring Security Java configuration. A good approach is to use form login with fallback to HTTP Basic authentication, and include some CSRF protection and the possibility to enforce that all backend methods are only accessible via HTTPS

  • This means the backend will propose the user a login form and assign a session cookie on successful login to browser clients, but it will still work well for non-browser clients by supporting a fallback to HTTP Basic where credentials are passed via the Authorization HTTP header.

  • Following OWASP recommendations, the REST services can be made minimally stateless (the only server state is the session cookie used for authentication) to avoid having to send credentials over the wire for each request.

--

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • =========================================================...
    lavor阅读 8,862评论 0 5
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,496评论 0 23
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,064评论 19 139
  • 每天两点一线的生活本是枯燥无聊, 偶尔抬头或低头便有了新的发现。 图片均拍摄于: Waterloo, Canada...
    Miwill米阅读 4,624评论 0 0
  • 我希望衬衣领子永远不会太脏 我希望裤子永远显得腿很修长 我希望鞋子永远是洁白的纯样 我希望阳光总不会太刺眼 我希望...
    木辛阿梓阅读 1,738评论 2 6

友情链接更多精彩内容