Azure AD Web Api Authentication Multitenant | .Net6 Web API Azure AD Multi Tenant Authentication
AzureTeach•Net
View ChannelAbout
I am NC, having 11+ years of experience on various Microsoft Technologies. In my career, I have worked for multiple Fortune 500 companies as a Tech Lead and Senior Developer. I am Microsoft Certified Technology Specialist and Azure Certified Developer. I have created this channel to share my knowledge with you all. Please subscribe to my channel for excellent learning tutorials on .Net and Azure. Github repo - https://github.com/AzureTeachNet/AzureTeachTutorials Buy Me A Coffee - https://www.buymeacoffee.com/azureteachnet
Video Description
Azure AD Web Api Authentication Multitenant | .Net6 Web API Azure AD Multi Tenant Authentication | Azure AD Multi Tenant Authentication | Multi Tenant Authentication Web Api Azure AD | Authenticate Web API with multiple Azure Accounts | .Net Core 6 Azure AD multi tenant Authentication ========================================= .Net6 Web Api Azure AD Multi Tenant authentication and authorization is demonstrated in this video with example. It is super easy to implement multi tenant authentication and authorization in .Net core using Azure AD/Microsoft Entra ID. To Implement multi tenant authentication we need to have multiple tenants. In this video I have used Two Azure AD active directory tenants. First step is to create the app registrations in each Azure directory. Then go to expose an API section and add a scope. If you have roles you can add it in app roles section. You have to configure these in multi tenants. i.e in all the tenants that you want to include as part of your Web API Azure AD authentication. Please make a note of Application Id Uri and tenant details. In .Net 6/.Net Core Web API project install Microsoft.AspNetCore.Authentication.JwtBearer.dll so AddJwtBearer method will be available. In app settings.json file, you have to configure multi tenants (in this example two tenants) Issuer, Authority and Audience details. This you can get from Azure AD app registration. It is clearly demonstrated in the video. ================================================ In Program.cs, we need to write AddAuthentication() middleware on the services then we need to write AddJwtBearer for each tenant. In AddJwtBearer configuration, we have to mention all the parameters that we want to validate like ValidateIssuer, ValidateAuthority, ValidateIssuerSigningKey and ValidateLifeTime. We have to do it for each tenant. Later we need to add a policy scheme, which has options.ForwardDefaultSelector func. In this we need to write code to select the JWT Bearer scheme that the application have to select for each request. This configuration will allow the app to decide which jwt bearer configuration to select for each request. Because, we have added multiple tenants in the .Net6 Web API Multi Tenant Authentication. Next, we need to add the policy builders and use RequireAuthenticatedUser and we need to add this in builder.Services.AddAuthorization middleware. Add Authorize attribute on the controller which needs authentication. After doing all these, We have successfully implemented Multi Tenant Azure AD authentication on .Net6 Web API. Next is Testing. For Testing Azure AD Multi Tenant Authentication for .Net6 Web API, we need to create client App registrations in each tenant and provide permissions on Api App in multi tenants. We need to assigns scopes on the client application. After doing all these, you can use Postman to generate the token from Oauth2.0 endpoint of Microsoft Azure AD and use it access the web api. =========================================== Chapters 00:00 .Net6 Azure AD Multi Tenant Authentication -Intro 01:00 Azure Ad .Net6 MultiTenant- Create Api App Reg 03:25 .Net6 Multi Tenant Azure AD- Configurations 05:46 Add Authentication, Jwt Bearer Multi Tenant 14:03 Add Authorization - Azure Ad Multi Tenant 16:45 Client App reg - Web Api Azure AD Multi Tenant 17:20 Testing Azure AD Multitenant Api-Postman #azure #MultTenant #.Net6Authentication
Upgrade Your Gaming Audio
AI-recommended products based on this video

New SteelSeries Arctis Nova Pro for Xbox Multi-System Gaming Headset - Premium Hi-Fi Drivers - Hi-Res Audio - 360° Spatial - GameDAC Gen 2 - Quad-DAC - ClearCast Gen 2 Mic - Xbox, PC, PS5/PS4, Switch

NEW SteelSeries Arctis Nova 3 Multi-Platform Gaming Headset - Signature Arctis Sound - ClearCast Gen 2 Mic - PC, PS5/PS4, Xbox Series X|S, Switch, Mobile

HyperX Cloud II - Gaming Headset, 7.1 Surround Sound, Memory Foam Ear Pads, Durable Aluminum Frame, Detachable Microphone, Works with PC, PS5, PS4, Xbox Series X|S, Xbox One – Red

Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black

Logitech G305 LIGHTSPEED Wireless Gaming Mouse, Hero 12K Sensor, 12,000 DPI, Lightweight, 6 Programmable Buttons, 250h Battery Life, On-Board Memory, PC/Mac - Black

Logitech K400 Plus Wireless Touch TV Keyboard With Easy Media Control and Built-in Touchpad, HTPC Keyboard for PC-connected TV, Windows, Android, Chrome OS, Laptop, Tablet - Black

Logitech M185 Wireless Mouse, 2.4GHz with USB Mini Receiver, 12-Month Battery Life, 1000 DPI Optical Tracking, Ambidextrous, Compatible with PC, Mac, Laptop - Black

Bose QuietComfort Wireless Noise Cancelling Headphones, Bluetooth Over Ear Headphones with Up to 24 Hours of Battery Life, Moonlight Grey - Limited Edition

New SteelSeries Arctis Nova Pro for Xbox Multi-System Gaming Headset - Premium Hi-Fi Drivers - Hi-Res Audio - 360° Spatial - GameDAC Gen 2 - Quad-DAC - ClearCast Gen 2 Mic - Xbox, PC, PS5/PS4, Switch

NEW SteelSeries Arctis Nova 3 Multi-Platform Gaming Headset - Signature Arctis Sound - ClearCast Gen 2 Mic - PC, PS5/PS4, Xbox Series X|S, Switch, Mobile

HyperX Cloud II - Gaming Headset, 7.1 Surround Sound, Memory Foam Ear Pads, Durable Aluminum Frame, Detachable Microphone, Works with PC, PS5, PS4, Xbox Series X|S, Xbox One – Red

Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black

Logitech G502 HERO High Performance Wired Gaming Mouse, HERO 25K Sensor, 25,600 DPI, RGB, Adjustable Weights, 11 Programmable Buttons, On-Board Memory, PC / Mac, Black

Logitech G305 LIGHTSPEED Wireless Gaming Mouse, Hero 12K Sensor, 12,000 DPI, Lightweight, 6 Programmable Buttons, 250h Battery Life, On-Board Memory, PC/Mac - Black

Logitech K400 Plus Wireless Touch TV Keyboard With Easy Media Control and Built-in Touchpad, HTPC Keyboard for PC-connected TV, Windows, Android, Chrome OS, Laptop, Tablet - Black

Sony WH-CH720N Noise Cancelling Wireless Headphones Bluetooth Over The Ear Headset with Microphone and Alexa Voice Control, Black

AC Power Cord Cable Fit for Sony PS5 PS4 PS3 Slim PlayStation 5 4 3, Xbox Series X/S, Xbox One X/S, TV, Printer Universal 2 Prong Supply Replacement - (ETL Listed Cable)

SmallRig FX3 / FX30 HawkLock Quick Release Camera Cage Kit for Sony with Cable Clamp, Bulit-in QR Cold Shoe NATO Rail/QR Plate for Arca, Modular Design Compatible with Original XLR Handle - 4770

SmallRig ZV-E1 Camera Baseplate for Sony ZV-E1, Built-in Cold Shoe Mount and QR Plate (for Arca) Quick Switch Between Tripod and Stabilizer for DJI RS 2 / RSC 2 / RS 3 / RS 3 Pro - 4314

Bose QuietComfort Wireless Noise Cancelling Headphones, Bluetooth Over Ear Headphones with Up to 24 Hours of Battery Life, Moonlight Grey - Limited Edition

Lightning to 3.5mm Audio Jack Adapter Apple MFi Certified iPhone Headphone Jack Adapter Lightning to Aux Adaptor Dongle for iPhone 14 13 12 11 XS XR X 8 7 2 Pack

Deeyaple USB C to Aux, 4FT/1.2M, Type C to 3.5mm Audio Cable Headphone Jack Cable for Car Mobile Phone, iPhone 16 15, iPad Pro, Samsung Galaxy S24 S23 S2010, Google Pixel,Oneplus Grey (1)

ACEMAGIC Laptop Computer AMD Ryzen 7 5700U Windows Laptop 16.1-in IPS 16GB DDR4 512GB NVMe SSD Backlit & Numeric Input WiFi 6 HDMI Type-C USB-3.2 Webcam 3.5mm Audio Office Laptops Home Laptops

Lemorele 10 in 1 USB C Docking Station Dual Monitor, Laptop Dock USB C Hub Multiport Adapter Triple Monitor W/2 HDMI 4K, VGA, 3 USB 3.0/2.0, PD, SD/TF, 3.5MM Audio for Lenovo, Surface, MacBook

Hard Carrying Case for Meta Quest 3S, VR Gaming Headset and Touch Controllers Accessories Travel Case, Small Hard Shell Storage Case for Oculus Quest 3S/Quest 3/Vision Pro, Gray

