Coding Shorts: Using Azure Entra ID to Protect Your APIs

Поділитися
Вставка
  • Опубліковано 25 січ 2025

КОМЕНТАРІ • 39

  • @dsheardown
    @dsheardown 10 місяців тому +1

    Brilliant as always and appreciate the time put into these videos! I realise you are essentially "buying into" a certain platform for your auth but then again I don't really want to try to roll my own auth! I still get this from time to time i.e. the vendor lock-in but come on! we are all "locking" ourselves to some framework/platform etc. :). Personally, I do like the feeling the auth is handled by people who know more about this stuff than I! I am still trying to wrap my head around integrating this type of auth and allowing users to sign up/pay for a SaaS/API access.. I did experiment with the older Azure AD B2C / API Gateway stuff... I should really spend some time reading the updated docs!! Anyway, thank you again for a great intro to this and sharing the code :)

    • @swildermuth
      @swildermuth  10 місяців тому +1

      I am in agreement, find a partner you trust (AWS, Azure, Okta, etc.) and you'll be close the the same implementation. Luckily if you change, it's just changing a little code on both sides, not re-engineering a complete login/security system.

  • @jamesevans6438
    @jamesevans6438 10 місяців тому

    Hi Shawn, great vid, this is not a straight forward concept to get your head around, great explanation and very nice clean code, love it! probably need to handle the access token expiry and a bit of a consideration for refresh tokens, maybe they can't be used with public clients.

  • @lpsoldier357
    @lpsoldier357 4 місяці тому

    Great tutorial. Which font are you using in visual studio? Seems pretty good

  • @clipsacademiques4288
    @clipsacademiques4288 2 місяці тому

    Very good. But for the front end, how about Blazor wasm? Can you give me where i can get the information?

  • @MohamedBeyremMakhlouf-gn6iv
    @MohamedBeyremMakhlouf-gn6iv Місяць тому

    thanks for sharing

  • @PaulA-c4x
    @PaulA-c4x Місяць тому

    Would this work with .NET YARP Gateway? SPA Style? Great video thanks

  • @OmegaCosmos
    @OmegaCosmos 8 місяців тому

    Hey Shawn, fantastic video! I've searched around for a tutorial on this for ages and just couldn't understand any of them!!
    Is there a way to implement a navigation guard using this? I want my users to be automatically directed to a login page if they aren't already logged in.

    • @swildermuth
      @swildermuth  8 місяців тому

      Yes you can! The client-side Entra API has a simple call to see if the user is logged in. I didn't cover it here, but you'll want to use the client library (it works across frameworks in JS/TS).

  • @eusouodouglas5730
    @eusouodouglas5730 10 місяців тому

    Thank you for sharing ! How is this token working? Is it possible to revoke a token for a consumer in case the person had to token stolen?

    • @swildermuth
      @swildermuth  10 місяців тому

      You can revoke the user and the refresh token, but not the access token. The token should be short-lived to limit the amount of time. The token is proof that the user has access, and if it if went back to MS on every request, it would perform really badly. I hope that helps.

  • @lpsoldier357
    @lpsoldier357 4 місяці тому

    What if I want to have a custom login page, and also a .net api with a custom IdentityUser?

    • @swildermuth
      @swildermuth  4 місяці тому

      Then you probably want to use Azure B2C or ASP.NET Identy

  • @akiander
    @akiander 10 місяців тому

    Can you explain why Microsoft's tutorials tell us to create one Entra Application definition for the API and another definition for the client application? This demo appears to use the same application definition for both.

    • @swildermuth
      @swildermuth  10 місяців тому

      I wish I could. I think Microsoft is assuming you'll need to create several APIs to protect APIs in chunks, but with roles, that's unnecessary IMO. But maybe an Entra/security person can correct me.

    • @coderider3022
      @coderider3022 10 місяців тому

      You should use an app reg to represent each district app. The api is a standalone app, the client is standalone. You could have other apps, power apps , server apps etc. in a contrived example where it’s 1 logical app, it’s ok to use 1. I have an api layer and support multiple clients via their own app reg and my app reg.

  • @Max-kj2us
    @Max-kj2us 9 місяців тому

    Hi Shawn,
    As always, your videos are great and helpful! Thanks.
    Could you do me a favor and expand upon this topic? I would like to figure out how I can secure an API with bearer tokens (Entrar ID), but I would like to trigger the OAuth flow by hand (or by code).
    Could you show me how I can get that done?
    So the steps would be:
    Secure the API like in your video.
    Write a small C# program that does the OAuth 2 flow and gets the Bearer token.
    Get weather info and add the token from step 2.
    I'm mainly curious how you configure Azure.

  • @paulh6933
    @paulh6933 10 місяців тому

    Do u know if the login modal can be customized? maybe branded to my website?

    • @swildermuth
      @swildermuth  10 місяців тому +4

      I'm azure you can add your own branding

    • @matejl92
      @matejl92 10 місяців тому

      😂😂😂​@@swildermuth

    • @PaulA-c4x
      @PaulA-c4x Місяць тому

      @@swildermuth He is an Azure computer!

  • @Paul-uo9sv
    @Paul-uo9sv 2 місяці тому

    Azure EntraId on-premis also works basically the same way? Great video thank yoU!

    • @swildermuth
      @swildermuth  2 місяці тому +1

      I haven't dealt with on-prem, but I believe it is.

    • @Paul-uo9sv
      @Paul-uo9sv 2 місяці тому

      @swildermuth ok thane

  • @arnjmllr
    @arnjmllr 5 місяців тому

    great tutorial. I must have missed something though as even when I log in and get the token, pass it to the web api I am getting a 401 error. I've gone over the code and tutorial and I'm not seeing my mistake. Any "usual suspects" for this issue? I am able to display my name once logged, it's just the call to the weatherforecast that is denied. truly appreciate any ideas.

    • @swildermuth
      @swildermuth  5 місяців тому

      Are you sure you have the middleware in the server app correctly setup with the same client/tenant ids and client secret? Are you sure you're setting the auth header correctly? Those are two places I'd start

    • @arnjmllr
      @arnjmllr 5 місяців тому

      @@swildermuth thanks so much for the reply, I'm not quite sure what you mean by client secret. I've checked the clientid/tenantid, authority, scopes and the "bearer " + token... all look good. I'll keep looking :)

    • @swildermuth
      @swildermuth  5 місяців тому

      If you go to your App Registration for your app and look at "Manage->Certificates and Secrets" - you'll need to create a new secret and pass it into the options.ClientSecret where you set the clientid and the tenant id.

    • @ksalk91
      @ksalk91 3 місяці тому

      @@arnjmllr Have you made it work? I'm having the same issue, still getting 401 although everything is the same as in the tutorial. Adding ClientSecret did not help.

    • @arnjmllr
      @arnjmllr 3 місяці тому +1

      @@ksalk91 sorry, no. I think Shawn's suggestion of the " client secret." may be the missing piece, but have not tried it, got busy with another project.

  • @bacbaphii
    @bacbaphii 10 місяців тому

    Hi, Thank you for sharing. Can you create tutotiral design project apply clean architecture from basic to advanced?
    I couldn't find good videos with such content on youtube.I am new to this topic.
    Thank you for following my question.

    • @swildermuth
      @swildermuth  10 місяців тому +1

      These are short tutorials, I don't create full courses on UA-cam

    • @dsheardown
      @dsheardown 10 місяців тому +1

      But Shawn has some great courses on Pluralsight :) as well as own courses on website I think?