Asp.Net Core Web Application Azure Active Directory (Azure AD) Authentication

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 68

  • @KanokpitsunLertprommakul
    @KanokpitsunLertprommakul Год назад +2

    Very helpful for everyone, Keep doing the best tutorial. Thanks

  • @MsYogeshPandey
    @MsYogeshPandey Месяц назад

    Best channel for quick and to the point learning. Great, hats off to you.

    • @azureteachnet
      @azureteachnet  Месяц назад

      Thanks a lot for the feedback. These kind of comments motivates me a lot to make good stuff. Please subscribe to the channel if you have not subscribed yet. Thanks.

    • @MsYogeshPandey
      @MsYogeshPandey Месяц назад

      @@azureteachnet Already done and pressed the bell icon as well :)

  • @ajaykumarreddyk
    @ajaykumarreddyk 2 года назад

    simple and straight to point topic with right example on how to authenticate with delegated permissions and provide the redirect uri.

  • @josephbseeley
    @josephbseeley Год назад

    Very nice straightforward walk-through to a very needed and potentially complicated topic. Great job!

    • @azureteachnet
      @azureteachnet  Год назад

      Thank you for the feedback. We can take help of visual studio too. No need to write code manually. Here is the video - ruclips.net/video/ZO7C6YmalXg/видео.html
      Please subscribe to the channel if you have not subscribed yet. Thanks

    • @josephbseeley
      @josephbseeley Год назад

      @@azureteachnet Subscribed! I wanted to follow up and tell you that I walked through the steps you laid out on an existing web app that was originally .Net Core 3.1 but refactored to .Net 6 and it still worked without any issues. My mind is blown, you saved me a ton of time, thanks sooo much! :)

  • @kelinengambou4676
    @kelinengambou4676 Год назад

    Merci beaucoup, très bon tutoriel

  • @202sivasagar
    @202sivasagar 3 года назад

    Good video...thank you aacharya for nice explanation..

  • @GilbertoTezini
    @GilbertoTezini 2 года назад

    very useful tutorial!
    Thank you

  • @sruthigujjarlapudi8211
    @sruthigujjarlapudi8211 2 года назад

    Really Helped.Thank you so much.👏

    • @azureteachnet
      @azureteachnet  2 года назад +1

      Thank you for feedback. Please subscribe to the channel if you have not subscribed yet.

  • @khadyjhalabbadi8743
    @khadyjhalabbadi8743 Год назад

    thank you for the video, I want to ask if there is a way to make our UI instead the Microsoft one?

  • @TellaTrix
    @TellaTrix 10 месяцев назад

    Is this openid connect protocol we used for authentication of user?

  • @DevQc70
    @DevQc70 Год назад

    Great vidéo.
    Just a little side note : I would prefer to do not use Scaffold operation. Some of the users are not using the same version of Visual Studio as you. Or they are using different IDE (VS code, Riders)
    It would be better if you implement manually the scaffold components.

    • @azureteachnet
      @azureteachnet  Год назад

      Thanks for the suggestion. I will consider it in my future videos. Please subscribe to the channel if you have not subscribed yet. There are a lot videos on Azure in the channel and more to come in future.

  • @conaxlearn8566
    @conaxlearn8566 3 года назад +1

    Hello, do you know how we can get the logged in user's full name, please? It'll be great if we can display 'Hello ' instead of 'Hello ' at the top. Thank you!

    • @azureteachnet
      @azureteachnet  3 года назад +3

      You can read it from User Claims. Try this. @User.Claims.FirstOrDefault(x=>x.Type.Equals("name")).Value. This will give you the name attribute defined with the user.
      If you want both First Name and Last Name, you have to enable it from optional claims.
      Goto App Registration-->Token Configuration-->Add Optional Claim-->ID-->Choose family_name & given_name-->Add-->Turn On Graph Permission.
      After that, you can get the first name and last name from User.Claims.
      Please subscribe to AzureTeach. Net if you have not subscribed yet.🙂

    • @conaxlearn8566
      @conaxlearn8566 3 года назад

      @@azureteachnet Thank you so much!

  • @dhartipatel5805
    @dhartipatel5805 Год назад

    Great video, can you please share how to read token to get the login user information like role

    • @azureteachnet
      @azureteachnet  Год назад

      You can use User class in your controller. From User you can find role claims. You can get the User from HttpContext.
      Please subscribe to the channel if you have not subscribed yet. Thanks

  • @shahrulamir983
    @shahrulamir983 2 года назад

    Great job, just wonder can I develop using Asp.Net Visual Basic language instead of C#? Thank you

    • @azureteachnet
      @azureteachnet  2 года назад +1

      Thanks for the comment. Yes. Instead of doing all these things manually, you can take help of visual studio to configure the Azure AD.
      You can click on the connected services under the project, Choose Microsoft Identity and configure the azure ad. Please check - ruclips.net/video/ZO7C6YmalXg/видео.html
      Please subscribe to the channel, if you have not subscribed yet. Thanks

    • @shahrulamir983
      @shahrulamir983 2 года назад

      @@azureteachnet Thanks for your reply. Do you think I can do this with VB.Net languages instead of C#. Right now by using C# it can run without any problem.

  • @aimanalnami7655
    @aimanalnami7655 3 года назад

    thank you good tutorial

    • @azureteachnet
      @azureteachnet  3 года назад

      Please subscribe to AzureTeach.net for more tutorials on Azure and .Net. Thank you.

  • @kinshuktaya1627
    @kinshuktaya1627 2 года назад

    Can you share the code ? I am not able see the full code of Startup.cs and in new Visual Studio, there is Program.cs and not Startup.cs by default

    • @azureteachnet
      @azureteachnet  2 года назад

      you might be using .Net6. This is older version. You can refer to this video - ruclips.net/video/ZO7C6YmalXg/видео.html . Take help of Visual studio and generate the code. Later you may have to upgrade the packages. Please subscribe and share my channel if it helps. Thanks

  • @anurag3487
    @anurag3487 2 года назад

    Hi, I have an angular app and a .NET 6 API.
    1) I am able to login to the Angular app using Azure AD, and call the protected API resources.
    The API is also registered as an azure ad app.
    2) Now I want to perform profile management in which a super admin can assign various permissions to various users.
    I am thinking of doing it at the application level and not at Azure AD level, because the Azure Admin will not have idea of the application's permissions and granularity.
    3) I am thinking of sending the logged in user's details to the API once the login is successful at Angular end, so that it can be saved to the DB.
    4) Once I have users details in the DB, I can write a filter which will delegate which users have what permissions.
    5) How can I capture user details like id, name, email etc. at Angular end after successful login and send it back to the .NET API for save purposes?
    6) I know I will have to use Graph API in this case.
    Do you happen to have some pointers? Is my approach correct?
    Thanks and Regards

    • @azureteachnet
      @azureteachnet  2 года назад +1

      If I understand your requirement correctly, you want to allow super admins to manage the details of other users. I did not understand why we need to save the user details to DB once logged in. Instead, create a role super admin and assign it to the admin users. Create an action in your api, which will do the user management which you are expecting. Authorize that action only for Super Admin role. You can get the user details from Graph Api As you mentioned.

    • @anurag3487
      @anurag3487 2 года назад

      @@azureteachnet Thanks for replying.
      I guess my comment wasn't much clear.
      We create users in Azure portal, right? For them to login at Angular side using Azure AD.
      How do we get these users in the application database automatically?
      Either I give a button at Admin side to sync created users from Azure AD.
      Or whenever an Azure user logs into the Angular portal, at that time I call an API and save that very user to my database.
      Once I have user details in my db, I can create a profile management module.
      I do not want to create and manage roles using Azure AD.
      Hope the question is clear.
      Regards

    • @azureteachnet
      @azureteachnet  2 года назад +1

      @@anurag3487 Both the approaches looks good. But I would prefer giving the sync button to admins.

    • @anurag3487
      @anurag3487 2 года назад

      @@azureteachnet thanks for your inputs.

  • @sayaanashaikh694
    @sayaanashaikh694 2 года назад

    How to insert Microsoft authentication to an existing asp.net core application?

    • @azureteachnet
      @azureteachnet  2 года назад +1

      did not get you... what do you mean inserting microsoft authentication?
      If you want to add azure ad to existting asp.net core application, this video would help you... you can configure it with a wizard too following connected services option. you can checkout the video in the channel.
      Please subscribe to the channel if you have not subscribed yet.

    • @sayaanashaikh694
      @sayaanashaikh694 2 года назад

      @@azureteachnet I referred the video and implemented this azure Ad authentication to my existing asp.net core web app but after successfully login it shows error like “ an unhandled exception occurred while processing the request… exception : OpenIdConnectAuthenticationHandler : message. State is null or empty

    • @azureteachnet
      @azureteachnet  2 года назад

      @@sayaanashaikh694 Did add all the configurations and code similar to the video? Ping me your startup.cs/program.cs code and the configurations

    • @sayaanashaikh694
      @sayaanashaikh694 2 года назад

      @@azureteachnet where can I send u ?

    • @azureteachnet
      @azureteachnet  2 года назад

      @@sayaanashaikh694 post screenshots in this facebook group - facebook.com/groups/203337538580278
      Dont include client specific information as it may be an issue to you. If it is practice code.. not an issue to post

  • @ArtandLifestyle-t4z
    @ArtandLifestyle-t4z 2 года назад

    Please let me know can we do azure ad configure to asp.net application ie aspx appln 4.6 framework and how . PLease reply

    • @azureteachnet
      @azureteachnet  2 года назад +2

      I never tried that. Will let you know in 2 days.

    • @ArtandLifestyle-t4z
      @ArtandLifestyle-t4z 2 года назад

      @@azureteachnet yes please help solution for same

    • @azureteachnet
      @azureteachnet  2 года назад +1

      @@ArtandLifestyle-t4z do you have startup.cs file in your project and also, do you see connected services under your project file in solution explorer?

    • @ArtandLifestyle-t4z
      @ArtandLifestyle-t4z 2 года назад

      @@azureteachnet earlier I didn't. Had now I have created and made needed webconfig into startup file it is showing values while debugging wat next..

  • @BhanuPrakash-ib2um
    @BhanuPrakash-ib2um 2 года назад

    how can we redirect to other webpages

    • @azureteachnet
      @azureteachnet  2 года назад

      One way we can do is, we have to write our own account controller, sign in action and in that we have to handle the login and preserving the access token. From that you can redirect to the page you want. Asp.net core mvc has Signin method and to that we can pass the authentication mechanisms. Here in this case, it is openid connect

  • @ThougtsNeverEnd
    @ThougtsNeverEnd 2 года назад

    Hi ,
    i have implemented same code in my .net core .i can't able to same Claims after Auzure ad login, if i am comment app.useAuthentication i can able to save the claims, any suggestion ?

    • @azureteachnet
      @azureteachnet  2 года назад

      your question is not clear. Are you trying to add custom claims to the user? You can directly add the claims to user using azure portal. Are you trying to do with code?

    • @ThougtsNeverEnd
      @ThougtsNeverEnd 2 года назад

      @@azureteachnet thanks for reply, i am not adding any claims Azure AD ,Because of the Azure AD and Web application user details different , after the AD authentication i am getting email from the Assure return funtion, based on the emailId fetching details from DB and need to save the claims, here claims not saved , if i am comment the App.Useauthentication claims saved properly.

    • @ThougtsNeverEnd
      @ThougtsNeverEnd 2 года назад

      same web application user have two type of the login one is internal another one is External ,external user only using ad login user id only different , other details same . here use same controller and different action
      Any type of the user logged in i need to save claim's

  • @motivationalbeast3569
    @motivationalbeast3569 2 года назад

    Hi, I'm using .NET 6 and it doesn't contain startup.cs file. While in program.cs file it is giving me this error
    "configuration is a type which is not valid in given context"
    For this line of code:
    builder.Services.AddMicrosoftIdentityWebAppAuthentication(Configuration, "AzureAd");
    Can you pls help me to resolve this issue...

    • @azureteachnet
      @azureteachnet  2 года назад +3

      are you using Minimal Api? did you try adding all the required dependencies? Soon I am going to post a video on .Net 6 Minimal API Azure AD.

    • @motivationalbeast3569
      @motivationalbeast3569 2 года назад

      @@azureteachnet I didn't used minimal API. I just used asp.net mvc web project...

    • @azureteachnet
      @azureteachnet  2 года назад +2

      ​@@motivationalbeast3569
      This fix should work for you. If it works, Please share my channel to your friends who works on .net technologies :-)
      Possible ways to fix the issue:
      1. use builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration.GetSection("AzureAd"));.
      If it did not fix the issue do step 2.
      2. Instead of adding the azure AD manually, we can take help of visual studio. In solution explorer, under your project, you can see connected services. Double click on that. It will show you two sections. In Service Dependencies Section, click on "+" symbol. Choose Azure AD, follow the wizard. In the Wizard you may have to select your app registration. Once you complete the Wizard, It will generate Azure AD code for you.

    • @motivationalbeast3569
      @motivationalbeast3569 2 года назад

      @@azureteachnet Brother first one didn't worked for me it give error:
      The clientId option must be provided.
      On 2nd solution I didn't find Azure AD named specifically in Service Dependencies

    • @azureteachnet
      @azureteachnet  2 года назад +2

      @@motivationalbeast3569 What is the name of AzureAd configuration in your appsettings.json? did you provide clientid, instance,tenantid in your azuread configuration in appsettings.json?.
      Option 2 - In service dependencies, It should show you "Microsoft Identity Platform" with description "Authentication for your application using Azure AD or Azure AD B2C.

  • @mopurisivakumar2296
    @mopurisivakumar2296 3 года назад

    Nice video and please share function app as well