c# - Identity Server 4 for Nativescript 应用程序应使用哪种流程以及它的安全性如何?

标签 c# nativescript openid identityserver4 angular-nativescript

我对这个主题做了很多研究,但我对如何进行它感到有点困惑。我的理解是这样的:

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

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

App Identity Flow
我从中得到它的文章是:https://datatracker.ietf.org/doc/html/draft-ietf-oauth-native-apps-09#section-4.1

我正在使用 NativeScript 来构建我的应用程序,并将其放在那里,因为我不确定这有多重要,所以如果您认为它确实重要,请说明原因。

隐式客户端用于 SPA 应用程序,这是我已经设置并使用我的 Angular 应用程序的客户端之一。现在我试图让它与 native 脚本应用程序一起使用,但我正在阅读的选项是 GrantTypes.HybridGrantTypes.Code 一些我发现的答案说我们应该使用混合,其他人说我们应该使用代码,但我不确定哪个是正确的以及为什么?

另一件让我困扰的事情是它在 Android 应用程序上的安全性。通过 SPA 和隐式流程,我们定义登录和注销 URL,因此这些域被列入白名单,并且不会与任何其他确保其安全的域一起使用。然而,对于 Android 应用程序来说,这到底是如何变得安全的呢?我无法在手机上存储 secret ,因为任何人都可以将其挖掘出来,那么到底如何使用流程(混合或代码,具体取决于我要使用的方式)来保证其安全?

最佳答案

现在回答这篇文章可能为时已晚,但我认为这对这篇文章的其他读者可能有用。

总结答案:

在这种情况下最好不要使用隐式流。
您应该使用混合授权代码流程之一,这完全取决于您的应用程序中的安全性有多重要?
事实上,您应该在安全性性能之间进行权衡。如果安全性对您来说更重要,您应该使用混合流,这可以减轻许多适用于浏览器 channel 的攻击,例如代码替换。 但此流程会产生性能开销,无法为您的应用程序和 IDP 提供更高的安全性。
如果平衡的安全级别足以满足您的应用程序的需求,那么最好使用授权代码流程。

更详细的答案:

混合流使用 ID Token其中包括c_hash (这是返回的 authorization_code 的哈希值,用于将 authorization_code 绑定(bind)到 state (链接到 session 本身)。
根据this article :

OpenID Connect’s hybrid flow falls into this category as well and mitigates the attack fine. OpenID Connect clients send a nonce in the request. At the same time, the nonce is stored in the session that is linked to the state. The nonce will be returned in a signed ID Token unchanged, so the ID Token and the state are linked through the session. The ID Token also includes c_hash, which is a hash of the code returned. Thus, the code and the session are also bound. If the adversary just swaps the code, the value of c_hash will not match and the attack will be detected. Even if the adversary swaps both code and ID Token, the attack will not work since the nonce in the ID Token and the session will not match.

关于c# - Identity Server 4 for Nativescript 应用程序应使用哪种流程以及它的安全性如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53686559/

相关文章:

c# - WebBrowser "steals"来 self 的表单的 KeyDown 事件

c# - 如何在谷歌电子表格中间插入一行

nativescript - 在 NativeScript 中调整图像大小?

找不到c#dll

c# - JavaScriptSerializer C# 和泛型(我认为是新手犯的错误!)

ios - 带有 AppBuilder 插件更新的 Nativescript

properties - 属性 'schedule' 在类型 'typeof import().ts' 上不存在

java - 为什么在谷歌的响应中缺少使用 openid4java 的 OAuth request_token?

openid - 使用 Active Directory 和 Open ID 对基于 Play Framework 的应用程序进行身份验证

grails - 如何将OpenID集成到我的项目中?