具有 spring 启动后端的 android 本机应用程序的 oauth 授权类型
oauth grant type for android native app with spring boot backend
我有一个 android 本机应用程序作为客户端,spring 在后端使用 REST 端点启动服务。我想知道使用 oAuth2 进行身份验证的最佳策略(没有社交登录方法)。
我目前正在使用 spring oauth 安全性并已启动授权服务器并且 运行(用户使用电子邮件和密码注册)。我使用授权类型 "password" 在 android 应用程序中获取访问令牌。但是,此方法需要 android 应用程序在请求中发送客户端 ID 和密码。我读了一些 posts,表明这种资助类型并不理想。我不介意收到用户密码,但我认为将客户端密码存储在应用程序中不是一个好方法。
另一种方法是使用授权码授权流程,但在这种情况下,因为我只有一个本机应用程序和后端 API,所以我不知道如何授权用户。用户看到要求他们授权应用程序的浏览器页面似乎并不是一种无缝体验。这也没有意义,因为这不是第三方应用程序。
我找到了 post where people suggest using Authorization Code flow with PKCE. But this apparently doesn't yet work with spring.
所以,现在我想知道其他本机移动应用程序如何处理身份验证?他们不使用访问令牌吗?在处理移动应用程序和 spring 后端时,我如何最好地支持身份验证?
Spring 安全 OAuth 支持 password
和 authorization_code
流 ,即 "public client"。由于您拥有授权服务器 and 本机应用程序 and 您可以接受本机应用程序获取凭据,因此让本机应用程序使用public 授予类型为 password
的客户。
不过,如果您决定您的本机应用程序不应获取凭据,那么 PKCE 是当前的最佳做法。建议将 authorization_code
流程与 public 客户端一起使用 alternative to PKCE:
In the time since the spec was originally written, the industry best practice has changed to recommend using the authorization code flow with no secret for native apps.
正如您提到的,这意味着 jumping out to a browser。
我有一个 android 本机应用程序作为客户端,spring 在后端使用 REST 端点启动服务。我想知道使用 oAuth2 进行身份验证的最佳策略(没有社交登录方法)。
我目前正在使用 spring oauth 安全性并已启动授权服务器并且 运行(用户使用电子邮件和密码注册)。我使用授权类型 "password" 在 android 应用程序中获取访问令牌。但是,此方法需要 android 应用程序在请求中发送客户端 ID 和密码。我读了一些 posts,表明这种资助类型并不理想。我不介意收到用户密码,但我认为将客户端密码存储在应用程序中不是一个好方法。
另一种方法是使用授权码授权流程,但在这种情况下,因为我只有一个本机应用程序和后端 API,所以我不知道如何授权用户。用户看到要求他们授权应用程序的浏览器页面似乎并不是一种无缝体验。这也没有意义,因为这不是第三方应用程序。
我找到了 post where people suggest using Authorization Code flow with PKCE. But this apparently doesn't yet work with spring.
所以,现在我想知道其他本机移动应用程序如何处理身份验证?他们不使用访问令牌吗?在处理移动应用程序和 spring 后端时,我如何最好地支持身份验证?
Spring 安全 OAuth 支持 password
和 authorization_code
流 password
的客户。
不过,如果您决定您的本机应用程序不应获取凭据,那么 PKCE 是当前的最佳做法。建议将 authorization_code
流程与 public 客户端一起使用 alternative to PKCE:
In the time since the spec was originally written, the industry best practice has changed to recommend using the authorization code flow with no secret for native apps.
正如您提到的,这意味着 jumping out to a browser。