SOLVED

How to get a custom .Net app with forms auth to work

%3CLINGO-SUB%20id%3D%22lingo-sub-1584216%22%20slang%3D%22en-US%22%3EHow%20to%20get%20a%20custom%20.Net%20app%20with%20forms%20auth%20to%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1584216%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20have%20an%20existing%20Azure%20dotnet%20app%20that%20simply%20uses%20traditional%20asp.net%20forms%20authentication.%26nbsp%3B%20The%20app%20service%20itself%20is%20set%20to%20anonymous%20access.%20We%20would%20like%20to%20add%20it%20into%20Teams%20as%20an%20alternative%20access%20point%20for%20users%20but%20after%20trying%20we've%20hit%20a%20problem%20that%20the%20custom%20authentication%20page%20doesn't%20seem%20to%20be%20able%20to%20set%20the%20cookie%20on%20a%20successful%20submit%20and%20the%20user%20stays%20on%20the%20login%20page%20rather%20than%20being%20redirected.%20Does%20the%20app%20have%20to%20be%20modified%20in%20some%20way%20for%20this%20to%20work%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1584216%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELOB%20Apps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1586245%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20a%20custom%20.Net%20app%20with%20forms%20auth%20to%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1586245%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2836%22%20target%3D%22_blank%22%3E%40Ryan%20Stone%3C%2FA%3E%26nbsp%3B%2C%20Have%20you%20implemented%20Teams%20authentication%20in%20your%20.net%20forms%20app%3F%3C%2FP%3E%0A%3CP%3EYou%20need%20to%20use%20the%20tabs%20SDK%20method%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EmicrosoftTeams.authentication.authenticate()%3C%2FCODE%3E.%20Please%20look%20at%20here%20for%20more%20detail%3CSPAN%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fplatform%2Fconcepts%2Fauthentication%2Fauth-flow-tab%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fplatform%2Fconcepts%2Fauthentication%2Fauth-flow-tab%3C%2FA%3E%3C%2FSPAN%3E.%26nbsp%3BThere's%20a%20C%23%20example%20here%3A%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FOfficeDev%2Fmicrosoft-teams-sample-complete-csharp%22%20rel%3D%22noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EMicrosoft%20Teams%20tab%20authentication%20sample%20(C%23)%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1586571%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20a%20custom%20.Net%20app%20with%20forms%20auth%20to%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1586571%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F371090%22%20target%3D%22_blank%22%3E%40Trinetra-MSFT%3C%2FA%3E%26nbsp%3Bthank%20you%20for%20the%20response.%20Why%20would%20this%20be%20needed%20though%20if%20the%20app%20is%20not%20using%20Azure%20AD%20or%20an%20identify%20provider%20like%20that%2C%20and%20is%20not%20making%20any%20external%20API%20calls%3F%26nbsp%3B%20It's%20completely%20self-contained%20app%20with%20anonymous%20access%20and%20traditional%20built-in%20forms%20authentication.%26nbsp%3B%20Is%20all%20this%20still%20required%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1586689%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20a%20custom%20.Net%20app%20with%20forms%20auth%20to%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1586689%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2836%22%20target%3D%22_blank%22%3E%40Ryan%20Stone%3C%2FA%3E%20I%20think%20that%20this%20documentation%20will%20help%20you%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fplatform%2Fresources%2Fsamesite-cookie-update%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fplatform%2Fresources%2Fsamesite-cookie-update.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EI%20think%20that%20the%20problem%20is%20related%20the%20chromium%20engine%20used%20by%20Teams%20and%20the%20fact%20that%20you%20are%20app%20is%20embedded%20in%20an%20iframe%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1586709%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20a%20custom%20.Net%20app%20with%20forms%20auth%20to%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1586709%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F13603%22%20target%3D%22_blank%22%3E%40Alexis%20CONIA%3C%2FA%3E%26nbsp%3Bthank%20you!%26nbsp%3B%20That%20makes%20complete%20sense.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

We have an existing Azure dotnet app that simply uses traditional asp.net forms authentication.  The app service itself is set to anonymous access. We would like to add it into Teams as an alternative access point for users but after trying we've hit a problem that the custom authentication page doesn't seem to be able to set the cookie on a successful submit and the user stays on the login page rather than being redirected. Does the app have to be modified in some way for this to work?

4 Replies
Highlighted

@Ryan Stone , Have you implemented Teams authentication in your .net forms app?

You need to use the tabs SDK method microsoftTeams.authentication.authenticate(). Please look at here for more detail https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/authentication/auth-flow-tab. There's a C# example here: Microsoft Teams tab authentication sample (C#).

Highlighted

@Trinetra-MSFT thank you for the response. Why would this be needed though if the app is not using Azure AD or an identify provider like that, and is not making any external API calls?  It's completely self-contained app with anonymous access and traditional built-in forms authentication.  Is all this still required?

Highlighted
Best Response confirmed by Ryan Stone (Contributor)
Solution

@Ryan Stone I think that this documentation will help you https://docs.microsoft.com/en-us/microsoftteams/platform/resources/samesite-cookie-update.

I think that the problem is related the chromium engine used by Teams and the fact that you are app is embedded in an iframe

Highlighted

@Alexis CONIA thank you!  That makes complete sense.