简体   繁体   English

从Android应用验证Spring Boot应用(使用jwt)

[英]authenticate spring boot app (using jwt) from android app

I am trying to authenticate a Spring Boot app (created using jHipster with jwt authentication) from an Android client. 我正在尝试从Android客户端验证Spring Boot应用程序(使用带有jwt身份验证的jHipster创建)。 What will be a standard procedure to follow. 将遵循的标准程序是什么。 Here are the steps I am trying to implement: 这是我尝试执行的步骤:

  • Use Android form to capture user input of credentials (username and password) 使用Android表单捕获用户输入的凭据(用户名和密码)
  • Call spring security authentication endpoint with user credentials 使用用户凭证呼叫Spring Security验证端点
  • Get jwt token from server and save it in the local storage (SQLite in my case) 从服务器获取jwt令牌并将其保存在本地存储中(在我的情况下为SQLite)
  • Every time the Android app calls a REST endpoint, send jwt token with the request. 每次Android应用程序调用REST端点时,都将jwt令牌与请求一起发送。

Any help/suggestion appreciated. 任何帮助/建议表示赞赏。

if this solution works for you, you can do it this way! 如果此解决方案适合您,您可以通过这种方式做到!

If you want to do it "better" (mind, what better means), you can use the UAA or OAuth2 option on JHipster (if you are using microservices). 如果您想做得更好(请记住,更好的意思),则可以在JHipster上使用UAA或OAuth2选项(如果您使用的是微服务)。 This provides a OAuth2 solution, which has the advantage, you must not implement security flows on your own (as you do), but rely on standard implementations, which do exist for android. 这提供了一个OAuth2解决方案,该解决方案具有以下优点:您不能自己实现安全流程(如您所愿),而必须依靠android确实存在的标准实现。

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

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