How to authenticate local Users (ASPNERUSERS)

Ramesh Sathiya narayanan 0 Reputation points
2023-06-28T20:41:43.7866667+00:00

I have a scenario, I am using Asp.net Core 6 and Azure.

The Scenario is that I have an IdentityProvider (ASPNETUSERS, ASPNETUSERROLES, etc.) table in an Azure SQL database. Whenever I create a new user, the information gets saved into ASPNERUSERS and related tables. I want to authenticate these users while they log in, and I should generate an on-behalf flow to connect with the API along with a JWT Token.

Can anyone help me achieve this?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,815 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,275 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 30,276 Reputation points Microsoft Employee
    2023-06-30T10:25:45.3933333+00:00

    Hi @Ramesh Sathiya narayanan

    Thanks for reaching out.

    To authenticate users in Azure SQL database while they log in and generate an on-behalf flow to connect with the API along with a JWT Token, you can use Azure Active Directory (Azure AD) authentication with Azure SQL Database.

    Azure AD authentication provides a way to authenticate users with Azure AD identities and access Azure SQL Database. You can use Azure AD authentication with Azure SQL Database to centrally manage the identities of database users and other Microsoft services in one central location.

    To use Azure AD authentication with Azure SQL Database, you need to create an Azure AD application and configure it to access Azure SQL Database. You can then use the Azure AD application to authenticate users and obtain tokens to call APIs protected by Azure AD.

    Here are the high-level steps to use Azure AD authentication with Azure SQL Database:

    Create an Azure AD application and configure it to access Azure SQL Database.

    Configure Azure SQL Database to use Azure AD authentication.

    Authenticate users with Azure AD and obtain tokens to call APIs protected by Azure AD.

    Use the obtained token to connect to Azure SQL Database.

    You can find more information on how to use Azure AD authentication with Azure SQL Database in this document:

    https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure?view=azuresql&tabs=azure-powershell#azure-ad-token

    https://github.com/microsoft/sql-server-samples/tree/master/samples/features/security/azure-active-directory-auth/token

    https://learn.microsoft.com/en-us/sql/connect/ado-net/sql/azure-active-directory-authentication?view=sql-server-ver16

    Hope this will help.

    Thanks,

    Shweta


    Please remember to "Accept Answer" if answer helped you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.