How to verify Azure AD B2C token? (2024)

How to verify Azure AD B2C token? (1)

  • Report this article

Cương Vũ How to verify Azure AD B2C token? (2)

Cương Vũ

Fusion of developer and operator

Published Oct 10, 2022

+ Follow

Azure AD B2C is a great service, it helps simplify software architect. You don't need to build an SSO system but only apply few lines of code. When making authorization with Az B2C, the AD will response a payload with access token. TheMicrosoft docs doesn't mention about how to verify it, there are many libraries support the validation, but I suppose to make and API to verify token as below:

How to verify Azure AD B2C token? (3)

The Token from Az B2C has three segments separated by "." The first segment is a header, the second segment is payload, the third segment is a signature which is created by encrypting the hash of first and second segment, and Az B2C encrypts it with private key. To verify the token, you need to decrypt the signature with public key to get hash 1, hashing the header + payload to get hash 2 then compare hash 1 and hash 2. If 2 hashes are matched, then the token is valid.

Next question is: Where is public key? The doc says you can get public key from https://<tenant>.b2clogin.com/<tenant>.onmicrosoft.com/<policy name>/discovery/v2.0/keys

But when GET into that URL, you don't see public key

Recommended by LinkedIn

Sending SMTP email with Microsoft Graph and OAUTH… Elie Karkafy 1 year ago
What does New Salesforce bring for You With Its Winter… FEXLE Services Private Limited 2 years ago
 "keys": [ {"kid":"X5eXk4xy8dlNP4-c57dO6QGTVBwaNk", "nbf":1493763266, "use":"sig", "kty":"RSA", "e":"AQAB", "n":"tVKUtcxLq6CScb0P3ZGXYbPzXvmmLiWZizpb-h0qup5jznOvOr-Dhw9908584BSgC83YacjWNqEK3urxhyE2jWjwRm2N95WGgb5mzE5XmZIvkvyXnn7X8dvgFPF5QwIngGsDG8LyHuJS5s8vJL0pVSrkuNojtokp84AtkADCDU_BUhrc2sIgfnvZ03koCQRoZmWiHu86SuJZYkDFstVTVSR0hiXudFlfQ2rOhPlpObmku68lXw-7V-P7jwrQRFfQVXw" } 

According to the doc. Azure AD B2C uses the RS256 algorithm, which is based on theRFC 3447specification. The public key consists of two components: the RSA modulus (n) and the RSA public exponent (e). You can programmatically convertnandevalues to a certificate format for token validation. So you need to make your own code to create public key from modulus and exponent.

I have made a public docker image to verify token, the program language is golang. Why golang? Because it fasts and small, the image is only 9 Mb, and when deploy it with Az Container App, it takes less than minute to provision.

https://hub.docker.com/repository/docker/kimcuongbvh/azureb2cauth

Like
Comment

3

To view or add a comment, sign in

More articles by this author

No more previous content

  • Terraform with Azure Api Management Oct 20, 2021
  • Automate scale in/out for Az VM Sep 13, 2021
  • Creating an email notification api with Python Feb 1, 2021
  • Analyzing log with pandas, matplotlib Jan 18, 2021
  • How to use Azure Application Insights with Python? Dec 23, 2020
  • PowerShell and XML Dec 17, 2020
  • Powershell multi-threading Aug 7, 2020
  • Deploy Flask to Azure App Services May 12, 2020
  • Automate DB restoring with python and Azure May 4, 2020

No more next content

See all

Sign in

Stay updated on your professional world

Sign in

By clicking Continue to join or sign in, you agree to LinkedIn’s User Agreement, Privacy Policy, and Cookie Policy.

New to LinkedIn? Join now

Insights from the community

  • Software as a Service (SaaS) How do you implement SaaS user authentication and authorization?
  • E-commerce How can you ensure your CMS is always backed up in case of data loss?
  • Computer Science What is SaaS and how does it work?
  • System Architecture How can you implement secure logging and auditing in SaaS applications?
  • Computer Networking What message queuing systems can you use to improve client-server performance?
  • Software as a Service (SaaS) How do you compare and select the best SaaS solutions for your specific needs and requirements?
  • Software as a Service (SaaS) How do you troubleshoot and resolve SaaS issues quickly and effectively?
  • Process Automation What are the most effective ways to use IFTTT for cloud-based process automation tasks?
  • Content Strategy How can you recover lost or corrupted CMS content?
  • Managed Services How do you evaluate and compare different SaaS providers and features for your needs?

Others also viewed

  • Create Azure AD apps with one line of code Waldek Mastykarz 3y
  • Azure AD roles Vs. Azure resources roles Tarek N. 2y
  • What can be replicated with AD Connect / Azure AD Sync Valentin Komarovskiy, MBA 12mo
  • Data Cloud, Security and Go Lightning Fast Paul Battisson 4mo
  • Shield Up: Essential Security Standards Every SaaS Innovator Needs Kulpreet Singh 3mo
  • How to Register Azure Active Directory App for oAuth Fidel Martin 2y
  • Microsoft Azure Administrator: Azure Identities (With Step By Step Demo) Fakhar ul Hassan 2y
  • ORGanizer: The Swiss Army Knife of Salesforce Browser Extensions Enrico MURRU ☁ 6y
  • Salesforce Spring ’21 Release – what’s new in Salesforce? Mark Hartnady 3y
  • The easiest way to setup your Azure AD app Waldek Mastykarz 3y

Explore topics

  • Sales
  • Marketing
  • IT Services
  • Business Administration
  • HR Management
  • Engineering
  • Soft Skills
  • See All
How to verify Azure AD B2C token? (2024)
Top Articles
How are FICO Scores Calculated? | myFICO
Canva Uncovered: How A Young Australian Kitesurfer Built A $3.2 Billion (Profitable!) Startup Phenom
Amc Near My Location
Bloxburg Image Ids
Craigslist - Pets for Sale or Adoption in Zeeland, MI
Hover Racer Drive Watchdocumentaries
Unit 1 Lesson 5 Practice Problems Answer Key
Five Day National Weather Forecast
Hilo Hi Craigslist
Houses and Apartments For Rent in Maastricht
Craigslist Red Wing Mn
St Maries Idaho Craigslist
Edicts Of The Prime Designate
Palm Springs Ca Craigslist
Traveling Merchants Tack Diablo 4
Iu Spring Break 2024
Conan Exiles Sorcery Guide – How To Learn, Cast & Unlock Spells
Highmark Wholecare Otc Store
Thick Ebony Trans
Weve Got You Surrounded Meme
Troy Gamefarm Prices
Mandy Rose - WWE News, Rumors, & Updates
Www Pointclickcare Cna Login
Craig Woolard Net Worth
Barista Breast Expansion
Craigslist Pasco Kennewick Richland Washington
Spirited Showtimes Near Marcus Twin Creek Cinema
Jt Closeout World Rushville Indiana
Ravens 24X7 Forum
Nextdoor Myvidster
Forager How-to Get Archaeology Items - Dino Egg, Anchor, Fossil, Frozen Relic, Frozen Squid, Kapala, Lava Eel, and More!
Gideon Nicole Riddley Read Online Free
Colorado Parks And Wildlife Reissue List
Agematch Com Member Login
Merge Dragons Totem Grid
Skill Boss Guru
When His Eyes Opened Chapter 2048
Dr Adj Redist Cadv Prin Amex Charge
Infinite Campus Parent Portal Hall County
Ferguson Employee Pipeline
Emily Tosta Butt
Torrid Rn Number Lookup
Birmingham City Schools Clever Login
Dragon Ball Super Super Hero 123Movies
Dying Light Mother's Day Roof
Bank Of America Appointments Near Me
Race Deepwoken
Craigslist Pets Charleston Wv
Morbid Ash And Annie Drew
Where Is Darla-Jean Stanton Now
Minecraft Enchantment Calculator - calculattor.com
Cognitive Function Test Potomac Falls
Latest Posts
Article information

Author: Prof. Nancy Dach

Last Updated:

Views: 5837

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Prof. Nancy Dach

Birthday: 1993-08-23

Address: 569 Waelchi Ports, South Blainebury, LA 11589

Phone: +9958996486049

Job: Sales Manager

Hobby: Web surfing, Scuba diving, Mountaineering, Writing, Sailing, Dance, Blacksmithing

Introduction: My name is Prof. Nancy Dach, I am a lively, joyous, courageous, lovely, tender, charming, open person who loves writing and wants to share my knowledge and understanding with you.