简体   繁体   English

基本身份验证而不是 AAD(Azure Active Directory)身份验证

[英]Basic Authentication instead of AAD (Azure Active Directory) Authentication

my Microsoft Teams app needs to access a REST web service that uses Basic Authentication.我的 Microsoft Teams 应用需要访问使用基本身份验证的 REST web 服务。

the tutorials only seem to show how to do this for authentication with Azure Active Directory:教程似乎只显示了如何使用 Azure Active Directory 进行身份验证:

https://docs.microsoft.com/en-us/learn/modules/embedded-web-experiences/7-exercise-implement-tab-authentication https://docs.microsoft.com/en-us/learn/modules/embedded-web-experiences/7-exercise-implement-tab-authentication

the above tutorial shows the user a login prompt and authenticates client side.上面的教程向用户显示了登录提示并验证了客户端。 how do i implement something like this for Basic Authentication?我如何为基本身份验证实现类似的东西?

EDIT : i'm mentioning client side because i want Teams to remember the login.编辑:我提到客户端是因为我希望团队记住登录。 the web service is basically for collaboration. web 服务基本上是为了协作。 so i can't use the same account for all users所以我不能为所有用户使用同一个帐户

EDIT2编辑2

for completeness i'm including an example client side call that ended up working (it shows a login popup to the user the first time as it does in a browser):为了完整起见,我包含了一个最终工作的示例客户端调用(它第一次向用户显示登录弹出窗口,就像在浏览器中一样):

var url = "https://example.com/Service.svc/Request";
var init = {credentials:"include", headers:{"Accept":"application/json"}};
fetch(url,init)
    .then(response => response.text())
    .then(data => alert(data));

I assume you are trying to access some external page or resource that requires basic auth.. otherwise there would be no reason to try to do oath.我假设您正在尝试访问一些需要基本身份验证的外部页面或资源。否则就没有理由尝试宣誓。 Teams Seems to support Basic Auth for tabs, eg i can add a tab point it to a website with basic auth, and a purple popup will appear, but how to trigger it from an application would be a different story. Teams 似乎支持标签的基本身份验证,例如,我可以将标签指向具有基本身份验证的网站,然后会出现一个紫色弹出窗口,但如何从应用程序触发它是另一回事。 assuming you're just calling https://api.abc.com/whatever all the time in the app, one "maybe" solution would be to embed an iframe somewhere in your teams app view, and load that domain, like https://api.abc.com/test if that page requires authentication, it should popup this purple authenticate window that you can type in your "basic auth" in. after you do that, the teams "browser" in theory should now have a session authed.假设您只是在应用程序中一直调用https://api.abc.com/whatever ,一个“可能”的解决方案是将 iframe 嵌入您的团队应用程序视图中的某个位置,然后加载该域,例如Z5E056C500ADDB87B4: //api.abc.com/test如果该页面需要身份验证,它应该弹出这个紫色的身份验证 window,您可以在其中输入您的“基本身份验证”。之后,理论上团队“浏览器”现在应该有一个session 认证。

If you don't like this way, you could make an initial page in your app where they type in their username and password, take the input and then make an http call something like this: https://stackoverflow.com/a/57665644/13470894 ?如果您不喜欢这种方式,您可以在您的应用程序中创建一个初始页面,他们在其中输入用户名和密码,进行输入,然后进行 http 调用,如下所示: https://stackoverflow.com/a/ 57665644/13470894 ?

Hopefully that helps a bit希望这会有所帮助

Regards,问候,

Azure AD does not support basic auth for external services. Azure AD 不支持外部服务的基本身份验证。 You have two options:你有两个选择:

  • Migrate from Basic Auth to "Modern Auth" (OpenID Connect / OAuth / (last resort) SAML) if you can.如果可以的话,从基本身份验证迁移到“现代身份验证”(OpenID Connect / OAuth /(最后的手段)SAML)。 This one is preferred.这个是首选。

  • Figure out a wat to ask the enduser for their username / password, as this is basically what you need for basic auth想办法向最终用户询问他们的用户名/密码,因为这基本上是基本身份验证所需要的

Last but not least, if your web service does not actually need a user account, but just a service account, you can save the authentication details about that web service in an Azure KeyVault and read them out when you need to construct the basic auth header. Last but not least, if your web service does not actually need a user account, but just a service account, you can save the authentication details about that web service in an Azure KeyVault and read them out when you need to construct the basic auth header .

But again, Azure AD does not support Basic Auth.但同样,Azure AD 不支持基本身份验证。 And in fact, Microsoft is deprecating basic auth for Exchange Online as announced here .事实上,微软正在弃用此处宣布的 Exchange Online 的基本身份验证。

There are APIs, which are showing Basic Authentication window / error on trying to reach them, but in fact, access is able by passing some auth header - sometimes totally custom.有些 API 显示基本身份验证 window / 尝试访问它们时出错,但实际上,通过传递一些身份验证 header 可以访问 - 有时完全自定义。

Contact with the API owner and ask about that, you will not do anything more without just talk to them.与 API 所有者联系并询问有关问题,如果不与他们交谈,您将不会做任何事情。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM