Asp.net WebForms Silent Authentication AAD on Team

2019-08-09 04:57发布

问题:

I'm looking a way to build a Web Forms App C# 4.7 with Azure Active Directory (AAD) Authentication like a SSO Authentication. This WebApp was deployed on Azure Web Application.

I'Would like to use this site from : Web Browser - all

Teams Tab (adding this to teams as a Tab) -- Working on Web and Desktop App

I'have try 3 option :

1/ Using Azure Web Application Authentication (configuration with our AAD) it's work fine on Web Browser and on Teams Web
But doesn't Work on Teams Desktop App...

2/ Implementation off OWin Auth with AAD V2 OAuth2 on C# code it's work like the 1 option. But doesn't work on Teams Desktop App....

3/ Now I'm looking a way i think this it's good way but i didn't find use on WebForms C# .Net project https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/authentication/auth-tab-aad

回答1:

OAuth is a web-based protocol that relies on redirects between URLs. When your tab is running inside the Teams client, there is no URL to redirect back to, so authentication fails (that's what's happening when you run your tab in the desktop client). You need to have Teams initiate the authentication process for you: you can't do it directly. This method also works in the browser, and the user experience is improved because the login doesn't occur in a separate browser tab, it occurs in a modal popup.

You need to use the tabs SDK method microsoftTeams.authentication.authenticate(). The usage of this is explained in great detail here. (The URL you found is a companion article specific to AAD and doesn't have the overview information.)

There's a C# example here: Microsoft Teams tab authentication sample (C#).