如何在Azure中处理API和客户端之间的身份验证 [英] How to handle authentication between API and Client in Azure

查看:44
本文介绍了如何在Azure中处理API和客户端之间的身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太确定该怎么称呼,但是基本上我有一个服务应用程序,该应用程序仅提供API,而偶尔在后台调用外部API以保持数据更新.除了对外部API进行身份验证外,此应用程序上没有其他身份验证.

I'm not really sure what to call this but basically I have a service app that just serves up an API while occasional calling external APIs in the background to keep the data updated. Aside from authenticating to the external APIs there is no other authentication on this app.

然后,我有一个前端应用程序,该应用程序使用服务应用程序的API来获取数据并将其显示给用户,并可以选择修改某些数据.此应用程序设置为可针对Azure AD进行身份验证,并具有应用程序角色设置,可限制对各个部分的访问.

Then, I have a front end app that uses the API of the service app to get data and display it to the user, and optionally modify some of the data. This app is setup to authenticate against Azure AD and has app roles setup to restrict access to various sections.

我将如何确保服务应用程序API的安全性,以便仅处理来自前端应用程序的调用,而其他所有消息都将被401拒绝?

How would I secure the service app API so only calls from the front end app are served, and everything else gets rejected with 401?

推荐答案

您可以通过将OAuth与Azure AD结合使用来保护API.以下概述可以帮助您解决方案:

You can protect the API by using OAuth with Azure AD. The below overview can help you out with your scenario:

  1. 在Azure AD中注册一个代表API的应用程序.基本上,在此步骤中,您将确保只有拥有权限的应用程序(您的应用程序)才能访问API.

    Basically in this step, you will be making sure only the application (your app) who has permission can access the API.

    1. 在Azure AD中注册另一个应用程序以代表客户端应用程序.在此步骤中,您将创建另一个代表您的应用程序的应用程序,以便可以在API和您的应用程序之间建立信任.

      In this step, you are creating another application representing your app so that trust can be created between API and your app.

      1. Azure AD中的授予权限.参考.

      在此步骤中,您将授予您的应用访问API的权限.

      In this step, you are giving permission to your app to access your API.

      1. 利用客户端凭据流向您的API验证您的应用.参考.

      在此步骤中,将使用API​​的Azure AD应用程序的信息来配置应用程序.使用这些信息,您将获取访问令牌,并且需要将此访问令牌传递给您的API.

      In this step, you will be configuring your app with the information of Azure AD application of the API. Using that information, you will be retrieving access token and you need to pass this access token to your API.

      这篇关于如何在Azure中处理API和客户端之间的身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆