In order to use the Verifiable Credentials with Azure AD B2C, you need to deploy the following:
- Deploy the sample issuer and verifier located in the vc folder
- Create an Azure Storage Account and deploy the custom html that B2C uses (explained here)
- Deploy an Azure AD B2C instance and setting up B2C Identity Experience Framework (explained here)
- Modify and upload the B2C Custom Policies in this github repo
- Create an Azure Storage Account and CORS enable it for your B2C tenant, as explained here. You should perform step 2 through 3.1. Note that you can select
LRS
for Replication asRA-GRS
is a bit overkill. - Edit the selfAsserted.html file and replace the url reference
var apiUrl = "https://yourappname.azurewebsites.net";
with the url for your verifier deployment. If you are usingngrok
, this url will look something likehttps://901dc458579f.ngrok.io
. If you are using Azure App Services, it will look something likehttps://yourappname.azurewebsites.net
- Edit both
selfAsserted.html
andunified.html
and replacehttps://your-storage-account.blob.core.windows.net/your-container/
with the name of your storage account and container. - Edit
selfAsserted.html
and change the link to the issuer sample in the html elementDon't have a digital membership card?
. It should point to your deployed VC sample issuer. Again, this would either point to yourngrok
process for the issuer or to your Azure App Service deployment of the sample issuer. - If you want a different background and logo images, change the
img
html elements inselfAsserted.html
andunified.html
. - Upload the files background and logo images,
selfAsserted.html
,unified.html
to the container in the Azure Storage. - Copy the full url to the files and test that you can access them in a browser. If it fails, the B2C UX will not work either.
You need an B2C tenant instance for this sample to work. The current B2C price model is free for 50K MAU per month, so the deployment will not cost anything. How to deploy a B2C tenant is explained in the documentation here. You should follow that documentation and stop when you come to section "Custom policy starter pack". You do not need to complete the Facebook part, but you should create a face Policy Key named FacebookSecret
with a fake value like abc123
.
The XML files in the policies folder are the B2C Custom Policies. These files are in a generic state and need to be updated to match your tenant. Therefor, the following needs to be done:
- Search-and-replace all references to
yourtenant.onmicrosoft.com
with your real tenant name, for examplecontosob2c.onmicrosof.com
, in all policy xml files. - Search-and-replace all references to
yourstorageaccount.blob.core.windows.net
with your real storage account in fileTrustFrameworkExtensions.xml
. Make sure the path matches to the full path of each uploaded html document in previous section. - Find the
login-NonInteractive
TechnicalProfile in theTrustFrameworkExtensions.xml
file and replace the guids for the IdentityExperienceFramework and ProxyIdentityExperienceFramework applications. You need to replace it with the AppIDs (client_id's) from the registered applications in your B2C tenant. Please note that there are 2+2 places you need to update! - Find the
ServiceUrl
for the VC Verifier deployed and update it. - Possibly add your AppInsights InstrumentationKey in the
Sign*.xml
files so you can get trace events when the B2C policy engine executes your policy. If you don't want to use AppInsights, comment that line out. - Upload the policies in order:
TrustFrameworkBase.xml
,TrustFrameworkExtensions.xml
and then the rest in no particular order.
You should have created a test application during the "Custom Policy Getting Started" section above. If you didn't, follow the documentation here. Make sure you set the Redirect URI type to Web
and the redirectUri to https://jwt.ms
as it makes testing B2C policies easy.
- Create a B2C account
- Click on the
B2C_1A_VC_susi
policy in the portal, select your test app and run the policy and https://jwt.ms as the reply url. - In the sign in user interface, select
Sign up
and create an account
- Click on the
- Issue your self a VC for your B2C account
- Again, click on the
B2C_1A_VC_susi
policy in the portal, select your test app and run the policy and https://jwt.ms as the reply url. - Select the
Verifiable Credentials
button and then click on the linkDon't have a digital membership card?
to open the sample VC issuer. Scan the QR code with your Microsoft Authenticator, sign in to your B2C account in the Authenticator and accept the VC card.
- Again, click on the
- Try signing in to your B2C account using your VC
- Click on the
B2C_1A_VC_susi_vc
policy in the portal, select your test app and run the policy and https://jwt.ms as the reply - When the QR code comes, scan it with your VC in the Authenticator app on your phone
- When you get to the jwt.ms page, notice that the
sub
claim is the objectId of your B2C user
- Click on the
- Try signing in using only your VC
- Click on the
B2C_1A_VC_signin
policy in the portal, select your test app and run the policy and https://jwt.ms as the reply - When the QR code comes, scan it with your VC in the Authenticator app on your phone
- When you get to the jwt.ms page, notice that the
sub
claim is not the objectId of your B2C user, but thedid
from the VC.
- Click on the