简体   繁体   English

使用Android和iOS的Spring Boot Rest Security

[英]Spring boot rest security with android and ios

I am developing spring rest webservice and my clients are android and ios applications. 我正在开发spring rest网络服务 ,我的客户是androidios应用程序。 The problem is my application is 100% api based there is no website even for the admin, everything is mobile and I have been struggling how to do authentication and authorization with just apis. 问题是我的应用程序是基于100%api的 ,即使是管理员也没有网站,所有内容都是移动的,我一直在努力仅使用api进行身份验证和授权 I did small spring projects before where my client was the browser. 在我的客户是浏览器之前,我做了一些小型的春季项目。 But now I have been stuck for a week and I can't seem to find anything on how to do this authentication and authorization thing. 但是现在我已经呆了一个星期,而且我似乎找不到有关如何执行身份验证和授权的任何信息。 Is it my approach or is it so unusual thing. 是我的方法还是如此不寻常的事情。 I would appreciate any help. 我将不胜感激任何帮助。 Thanks 谢谢

You can use Basic Authentication or Digest Authentication 您可以使用基本身份验证或摘要身份验证

https://docs.spring.io/spring-security/site/docs/3.0.x/reference/basic.html https://docs.spring.io/spring-security/site/docs/3.0.x/reference/basic.html

But you should be careful and do not use it with HTTP, only with HTTPS, since basic authentication transmits the password as plain text. 但是您应该小心,不要将其与HTTP一起使用,而只能与HTTPS一起使用,因为基本身份验证会将密码作为纯文本传输。

Second way is to use JWT for securing your application. 第二种方法是使用JWT保护您的应用程序。 Here is example of using JWT https://github.com/szerhusenBC/jwt-spring-security-demo 这是使用JWT的示例https://github.com/szerhusenBC/jwt-spring-security-demo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM