On-premise AD to Azure AD authentication/authorization for ASP.NET Core

时间:2017-08-30 21:01:17

标签: authentication asp.net-core active-directory authorization azure-active-directory

I currently have an ASP.Net Core and Ionic(Angular) 1.x intranet application for my organization that authenticates the user using Active Directory (NTLM/Kerberos), and signs them in using UIColor(named: "MyColor") after a redirect from authorization failure.

Now with ASP.Net Core 2, I want to transition from on premise Active Directory, to Azure Active Directory so I can open the doors for some more interesting things, such as staff being able to log in externally using Azure AD Application Proxy. I still want to be able to persist some information about the users though, kind of like Identity let me do.

Right now in my experimentations, I am using ADAL.js (Active Directory Authentication Library) to authenticate my user, as I have disabled Windows Authentication.

This works great and I receive a token indicating who this person is, and I can access UIColor(named: "MyColor") restricted API endpoints. How though, do I turn this token into a session on my Web API that I can sign a user in and persist information about them?

EDIT: Could one thing I do be to generate my token, but instead of using Public Function ItemNum() As Integer Dim loc As range Dim numChkCell As range Set loc = Application.Caller If loc.Row = 7 Then ItemNum = 1 Exit Function End If Set numChkCell = loc.Offset(-1, 0) Do While Application.WorksheetFunction.IsNumber(numChkCell) = False If (numChkCell.Value <> loc.Value2 And Application.WorksheetFunction.IsNumber(numChkCell) = True) Then ItemNum = numChkCell.Value2 + 1 Exit Do Else Set numChkCell = numChkCell.Offset(-1, 0) End If Loop ItemNum = numChkCell.Value2 + 1 End Function for authentication, I use cookie authentication and then on the server validate the token, and if valid manually set the user to be authenticated through Identity

1 个答案:

答案 0 :(得分:2)

它不应该将令牌转换为会话,因为Web API是RESTful。

您可以使用控制器中的User属性获取身份信息,以从Asp.net core 2.0 Web应用程序获取身份验证用户信息。