How to Authenticate a Blazor Server App with Azure AD

Sdílet
Vložit
  • čas přidán 19. 06. 2024
  • Do you want to create a new Blazor Server application and authenticate it using Azure AD?
    What sounds simple cost me a whole day to figure out. In this video, I will show you how I made it work.
    00:00 Introduction
    00:15 Creating a Blazor Server App using Microsoft Identity
    01:17 Connect to an Azure App Registration
    03:22 Authenticating a User
    04:06 Make the Home Page Non-Authenticated
    05:48 Show Menu Items only to authenticated Users
    07:05 Conclusion
    🔥 C#/.NET Bootcamp: The Fundamentals & more (Code FRIENDS10 for 10% OFF)*
    claudiobernasconi.ch/dotnet-c...
    📌 .NET Developer Roadmap
    claudiobernasconi.ch/learn-do...
    📌 CZcams Playlists:
    The FREE Blazor Crash Course: • The FREE Blazor Crash ...
    Blazor: • Blazor
    ✅ SUBSCRIBE FOR MORE VIDEOS
    Subscribe: 🔔 claudiobernasconi.ch/Subscribe
    🚀 CONNECT & SUPPORT
    Twitter: / chbernasconic
    Blog: claudiobernasconi.ch
    Newsletter: claudiobernasconi.ch/newsletter
    CREDITS
    🎵 www.bensound.com/
    * Affiliate Link: I earn a small commission at no additional cost
  • Věda a technologie

Komentáře • 24

  • @fieryscorpion
    @fieryscorpion Před 8 měsíci +3

    Thank you. Can you please make a new video on how to add permissions to the access token (for cases when your app calls a downstream API)?

  • @wontonotnow2
    @wontonotnow2 Před 3 měsíci +1

    Thanks Claudio, my department is moving to Azure AD instead of Ping Federate as broker and this helps. Now I have to figure out how to get my tenant administrator to approve the app registration so we can actually log in - It seems that even though the permissions needed in the app registration say admin approval isn't required, I still get a notification after login prompt that admin must approve the app. I think this is because users aren't allowed to approve the app registration's usage of our data so it must be done at the tenant admin level? Ah well, just another gate to open. The other issue I had in an earlier version of this new app was DevOps pipelines that we normally use don't seem to work - publishing directly from VS works fine, but when deploying via DevOps there are errors in the browser and theme is broken. Once we have a development process that works well and can pump out apps efficiently, things change and we have to start from scratch! This is the life... :(

    • @ClaudioBernasconi
      @ClaudioBernasconi  Před 3 měsíci +1

      I understand migrating can be a great effort. Don't get discouraged, and work step-by-step. I didn't know that tenant admins have to approve new app registrations in certain scenarios. However, that makes perfect sense. I usually get the best results when I work with those admins and other people affected by the change rather than working against them. Explaining why we need certain things and what upsides they provide takes time and effort but usually leads to success. Good luck on your journey.

  • @verbeeckorama
    @verbeeckorama Před 9 měsíci

    Great stuff. Thanks for the very clear explanation!!

  • @10Totti
    @10Totti Před 9 měsíci +1

    Thanks for your tutorial!

  • @niteshsetin
    @niteshsetin Před měsícem

    How do i get the access token in blazor server app build with net 8?

  • @shatvani
    @shatvani Před měsícem

    Hi, thanks for sharing your knowledge. Can you tell me how to create role-based authorization in a Blazor Server application, please?

    • @ClaudioBernasconi
      @ClaudioBernasconi  Před měsícem

      You can configure the roles as part of the [Authorize] attribute. The following article is a great starting point: www.c-sharpcorner.com/article/role-based-authorization-in-blazor/

  • @khaetee
    @khaetee Před 8 měsíci

    Thanks for this. I modified your tutorial for the .NET 8 and Blazor Web App which currently doesn't have an authentication template yet... The Log in button gets hung, and there is a debug message that there was a type error "couldn't fetch" at "ai blazor.web.js". Logging in didn't appear to work until I hit the refresh button on the webpage... and I was logged in. Any suggestions on making the logging in a bit smoother?

    • @ClaudioBernasconi
      @ClaudioBernasconi  Před 8 měsíci

      Thanks for your feedback. I haven't tried it with .NET 8 yet. I might record a video once I figured it out. Meanwhile, you have the highest chance to fix your issue by putting the code on GitHub and asking fir help in a .NET community.

    • @Ashandsax
      @Ashandsax Před 5 měsíci +1

      hi, how did you get this to work for .Net 8 blazor server when there isn't an option to choose 'microsoft identity platform' when creating a new blazor app?

  • @Ashandsax
    @Ashandsax Před 5 měsíci +1

    Hi, for .net 8, when creating a Blazor App, there is no option to choose 'microsoft identity platform'. So how would I setup if that wizard window doesn't pop up?

    • @ClaudioBernasconi
      @ClaudioBernasconi  Před 5 měsíci

      Thanks for your question. I'm not very familiar with Microsoft Identity Platform itself. I also noticed that the current .NET 8 Blazor App project template does not provide this option. I think it's best to start with the official documentation. After all, it should only be a few lines of code to glue it all together. learn.microsoft.com/en-us/entra/identity-platform/

    • @sciclops3443
      @sciclops3443 Před 2 měsíci

      @@ClaudioBernasconi Apparently Microsoft Identity option will be added back again on .NET 9 in the official release on 11/2024.

  • @CharlieTheFacehugger
    @CharlieTheFacehugger Před 3 měsíci

    Thanks man

  • @rasemaier
    @rasemaier Před 7 měsíci

    is it possible to set permission levels?

    • @ClaudioBernasconi
      @ClaudioBernasconi  Před 7 měsíci +1

      You can manage roles and other permissions in Azure AD and I'm sure you can check for them within your application. However, I have only authenticated users up to this point.

  • @mohammadmz1058
    @mohammadmz1058 Před 9 měsíci

    very nice video

  • @moatasemkremed5395
    @moatasemkremed5395 Před 7 měsíci

    Great 🎉 please add new video how to create app registration on azure portal

  • @arrrryyy
    @arrrryyy Před 29 dny

    Dude, can you stop making these facial impressions like you are disgusted?

  • @niteshsetin
    @niteshsetin Před měsícem

    How do i get the access token in blazor server app build with net 8?