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
[Solved] World's first country to have cashless economy
'Dumb Money' fact check: Did GameStop investor Keith Gill really tell Congress he's 'not a cat'?
Xre-02022
Uti Hvacr
Wordscapes Level 6030
Faint Citrine Lost Ark
Coffman Memorial Union | U of M Bookstores
Craigslist Nj North Cars By Owner
Umn Biology
Progressbook Brunswick
Lantana Blocc Compton Crips
Nichole Monskey
Lesson 2 Homework 4.1
Slmd Skincare Appointment
Hope Swinimer Net Worth
Amelia Bissoon Wedding
Slushy Beer Strain
Colts Snap Counts
Games Like Mythic Manor
Espn Horse Racing Results
Www.publicsurplus.com Motor Pool
Unforeseen Drama: The Tower of Terror’s Mysterious Closure at Walt Disney World
Epguides Strange New Worlds
Shiftselect Carolinas
Dragonvale Valor Dragon
Red8 Data Entry Job
Directions To Nearest T Mobile Store
Best Boston Pizza Places
Roseann Marie Messina · 15800 Detroit Ave, Suite D, Lakewood, OH 44107-3748 · Lay Midwife
Parent Management Training (PMT) Worksheet | HappierTHERAPY
Rush County Busted Newspaper
Bad Business Private Server Commands
Basil Martusevich
Los Amigos Taquería Kalona Menu
Royal Caribbean Luggage Tags Pending
Petsmart Distribution Center Jobs
Craigslist Ludington Michigan
Microsoftlicentiespecialist.nl - Microcenter - ICT voor het MKB
Synchrony Manage Account
AI-Powered Free Online Flashcards for Studying | Kahoot!
Myfxbook Historical Data
Cbs Fantasy Mlb
Nearest Ups Office To Me
Colorado Parks And Wildlife Reissue List
O'reilly's El Dorado Kansas
Conan Exiles Armor Flexibility Kit
FREE - Divitarot.com - Tarot Denis Lapierre - Free divinatory tarot - Your divinatory tarot - Your future according to the cards! - Official website of Denis Lapierre - LIVE TAROT - Online Free Tarot cards reading - TAROT - Your free online latin tarot re
Das schönste Comeback des Jahres: Warum die Vengaboys nie wieder gehen dürfen
Julies Freebies Instant Win
Selly Medaline
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.