简体   繁体   English

公共本地移动应用程序中的WSO2 Api Manager OAuth2 DCR安全性

[英]WSO2 Api Manager OAuth2 DCR security in public native mobile app

I am designing security in a public native mobile application for iOS and Android which is using publicly available API using WSO2 Api Manager (APIM). 我正在设计用于iOS和Android的公共本机移动应用程序中的安全性,该应用程序使用WSO2 Api Manager(APIM)使用公开可用的API。

As such I understand the security issues that are related to this setup and I would like to apply OAuth2 for native apps (according RFC 8252 ). 因此,我了解与此设置相关的安全性问题,因此我想将OAuth2应用于本机应用程序(根据RFC 8252进行 )。

I understand that the first thing that such application should do is to register with WSO2 APIM server through the interface described in Store API in order to receive unique consumer key/secret for every application, which is Dynamic Client Registration (DCR). 我知道此类应用程序应该做的第一件事是通过Store API中描述的接口向WSO2 APIM服务器注册,以便为每个应用程序接收唯一的使用者密钥/秘密,即动态客户端注册(DCR)。

The following is sample of request that should be sent in order to get keys: 以下是为获取密钥而应发送的请求示例:

curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -d @payload.json https://localhost:9443/client-registration/v0.11/register

To do such request, it should be secured using TLS 1.2 and there is a Basic Authorization using username/password of WSO2 APIM (which in this case is Base64 encoded admin:admin ) 为此,应使用TLS 1.2对其进行保护,并且存在使用WSO2 APIM的用户名/密码(在这种情况下为Base64编码admin:admin )的基本授权。

I understand that it should be protected at least by Basic Authorization to provide some security against DoS attacks, but on the other hand that means that the application should be distributed with username:password in order to be able to do DCR. 我了解至少应受到基本授权的保护,以提供针对DoS攻击的安全性,但另一方面,这意味着应使用username:password分发应用程序,以便能够进行DCR。

And if it will be distributed with this information then everyone can get the information and request for example malicious application registration. 而且,如果将其随此信息一起分发,那么每个人都可以获取该信息并请求进行恶意应用程序注册。

How is the native mobile application handled in order to register in WSO2 APIM securely? 为了安全地在WSO2 APIM中注册,如何处理本地移动应用程序? I think that there is something missing in my understanding of how it works. 我认为我对它的工作原理缺乏了解。

Does it mean that the user who installed the mobile application should have its own account on WSO2 APIM and should provide credentials right after installation? 这是否意味着安装移动应用程序的用户应在WSO2 APIM上拥有自己的帐户,并应在安装后立即提供凭据?

What about situation when the user does not have credentials in WSO2 APIM but has credentials for backend service that is accessed through API from WSO2 APIM? 如果用户在WSO2 APIM中没有凭据,但具有从WSO2 APIM通过API访问的后端服务的凭据,情况会如何? Can such credentials be used in order to register application through DCR of WSO2 APIM? 可以使用此类凭据来通过WSO2 APIM的DCR注册应用程序吗? (currently the backend and WSO2 APIM authentication has no integration) (当前后端和WSO2 APIM身份验证尚未集成)

Your understanding of how APIM works is partially correct. 您对APIM的工作方式的理解部分正确。 Let me explain and correct the whole thing. 让我解释并纠正整个问题。

Basically, there are 3 parties involved in this scenario. 基本上,此方案涉及3个参与方。

  1. API developers/publishers API开发人员/发布者
  2. Application developers (ie You, I guess, in your case) 应用程序开发人员(即您,我想就是您)
  3. End users (ie mobile users in your case) 最终用户(在您的情况下为移动用户)

As you already know, API developers develop and publish APIs from Publisher portal. 如您所知,API开发人员可以通过Publisher门户开发和发布API。 Then Application developers can see those APIs in API Store Portal. 然后,应用程序开发人员可以在API Store Portal中看到那些API。 Now, if they want to use those APIs in their mobile apps, they need to subscribe to those APIs. 现在,如果他们想在其移动应用程序中使用这些API,则需要订阅这些API。 For that, they need something in API manager to represent their mobile app. 为此,他们需要API管理器中的某些内容来表示其移动应用程序。 For that, they create an application in API Store portal and then subscribe to APIs through the created application. 为此,他们在API Store门户中创建一个应用程序,然后通过创建的应用程序订阅API。

Now App Developers need keys to invoke APIs via their mobile app. 现在,应用程序开发人员需要密钥才能通过其移动应用程序调用API。 For that, they do a DCR call via Store portal and generate consumer-key and consumer-secret pair. 为此,他们通过商店门户进行了DCR呼叫,并生成了消费者密钥和消费者秘密对。 Using those, they can generate access tokens. 使用它们,它们可以生成访问令牌。

There are a few different ways of generating an access token. 有几种不同的生成访问令牌的方式。 We call them grant types. 我们称它们为赠款类型。 For example, password grant type, client credentials grant type, authorization code grant type etc. Client credentials grant type only needs consumer-key and consumer-secret pair to generate an access token, where password grant type needs a username and password too in addition to consumer-key, consumer-secret pair. 例如,密码授予类型,客户端凭证授予类型,授权代码授予类型等。客户端凭证授予类型仅需要使用消费者密钥和消费者秘密对来生成访问令牌,其中密码授予类型还需要用户名和密码。消费者密钥,消费者秘密对。 So, if you have your mobile app users in some kind of a userstore, you can use password grant type, and that can help you identify each user in APIM level. 因此,如果您的移动应用程序用户位于某种用户存储区中,则可以使用密码授予类型,这可以帮助您识别APIM级别的每个用户。 If you don't have such a mechanism, you can use client credentials grant type, by which you can't differentiate end users at APIM level. 如果没有这种机制,则可以使用客户端凭据授予类型,通过这种类型,您不能在APIM级别区分最终用户。 Here a token generated by password grant type represents the end user, while a token generated by client credentials grant type represents the application. 在此,由密码授予类型生成的令牌代表最终用户,而由客户端凭证授予类型生成的令牌代表应用程序。

In either case, the application developer has to embed consumer-key and consumer-secret pair into their mobile app, so that end users can generate access tokens to access the APIs. 无论哪种情况,应用程序开发人员都必须将消费者密钥和消费者秘密对嵌入到他们的移动应用程序中,以便最终用户可以生成访问令牌来访问API。 The important thing is users don't have to call DCR individually. 重要的是用户不必单独呼叫DCR。 It's a task of the application developer. 这是应用程序开发人员的任务。

I hope this helps. 我希望这有帮助。

EIDT : EIDT:

If you let users sign up for the mobile app and have them in a userstore, you can use Authorization code grant type. 如果允许用户注册移动应用程序并将其保存在用户存储中,则可以使用授权代码授予类型。 Then you can enable only the Authorization Code grant type in your mobile app, and set the callback URL. 然后,您只能在移动应用程序中启用授权码授予类型,并设置回调URL。 So if someone steals the consumer secret and use it in a different app, they can't use it to generate a token even via Authorization code grant type, because the callback URL is validated in the server side. 因此,如果有人窃取了消费者的秘密并在其他应用程序中使用它,则即使通过授权代码授予类型,他们也无法使用它来生成令牌,因为回调URL已在服务器端进行了验证。

Another option is implicit grant type, which does not require client-secret, but it has its own flaws. 另一个选择是隐式授予类型,它不需要客户端秘密,但是有其自身的缺陷。

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

相关问题 使用服务器和移动应用程序实现oauth2登录 - Implementing oauth2 login with server and mobile app 使用 WSO2 作为移动应用的 API 网关时,如何安全地处理消费者密钥和秘密 - When using WSO2 as API gateway for mobile app, how to handle comsumer-key and secret securely 适用于Facebook(或Twitter)移动APP的OAuth2实现? - OAuth2 implementation for Facebook (or Twitter) mobile APP? 移动应用程序中良好的Oauth2流程? - good Oauth2 flow in mobile app? 为了实现android(requests)和API安全性,HTTPS和oauth2都是必需的吗? - For android(requests) and API security, are both HTTPS and oauth2 necessary? OAuth2 - 移动应用重定向问题,停留在浏览器中 - OAuth2 - mobile app redirection issue, stays in browser 重定向URI是否为本机移动应用程序的OAuth实现提供安全性? - Does Redirect URI provide security in OAuth implementation for native Mobile Application? OAuth2在Android应用中使用Google Calendar API的问题 - The issue with OAuth2 of using Google Calendar API in Android app 使用OAuth2令牌对Google App Engine上托管的API进行身份验证? - Using OAuth2 token to authenticate to an API hosted on Google App Engine? 反应原生android oauth2 - react native android oauth2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM