首页 文章

Identity Server 4用于Nativescript应用程序的流程以及如何保护?

提问于
浏览
1

我一直在做很多关于这个主题的研究,我对如何去做有点困惑 . 我的理解是这样的:

要将Identity Server 4与Android应用程序一起使用,最好的方法是让Android应用程序打开一个嵌入式浏览器实例,该实例将为用户可以登录的用户呈现身份服务器登录页面 . 完成后,浏览器将关闭并且将在应用程序上调用一个方法来传递访问apis和声明所需的令牌,以及不需要的令牌 . 现在令人困惑的部分是我用什么类型的客户端来完成这个以及该客户端的配置是什么样的?

这是我上面描述的图表,如果这是错误的,请随时纠正我 .

我得到它的文章是:https://tools.ietf.org/html/draft-ietf-oauth-native-apps-09#section-4.1

我正在使用nativescript来构建我的应用程序,我将它放在那里,因为我不确定有多重要,所以如果你认为它确实请提到原因 .

Implicit客户端用于SPA应用程序,这是我已经设置并使用我的角度应用程序的客户端之一 . 现在我'm trying to get it to work with the native script app but the options from what I'阅读是 GrantTypes.HybridGrantTypes.Code 我发现的一些答案说我们应该使用Hybrid而其他人说我们应该使用Code而我不确定哪个是正确的,为什么?

困扰我的另一件事是在Android应用程序上这是如何安全的 . 使用SPA和隐式流程,我们定义了登录和注销URL,因此这些域名是白名单,不会与其他任何使其安全的域名一起使用 . 但是,使用Android应用程序如何获得安全?我不能在手机上保存一个秘密,因为任何人都可以把它挖出来,那么究竟关于流量(Hyrbrid或Code,取决于我想要使用哪个)保持它的诱惑力?

1 回答

  • 0

    对于您描述的流程,您应该使用"Implicit Grant Type" . 不幸的是,与远程服务器URL不同,"there is no reliable way to ensure that the binding between a given redirect URI and a specific mobile application is honored."(来自What's the right OAuth 2.0 flow for a mobile app) .

    https://oauth.net/2/grant-types/implicit/所述,"it is generally not recommended to use the implicit flow (and some servers prohibit this flow entirely). In the time since the spec was originally written, the industry best practice has changed to recommend that public clients should use the authorization code flow with the PKCE extension instead."

    有关PKCE的详细信息,请参阅Proof Key for Code Exchange by OAuth Public Clients .

相关问题