Skip to content

Commit 338056c

Browse files
author
derisen
committed
resolve b2c issue
1 parent 951cfa3 commit 338056c

24 files changed

Lines changed: 303 additions & 345 deletions

File tree

1-Authentication/1-sign-in/App/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ app.use(bodyParser.urlencoded({extended: false}));
2323

2424
app.use(express.static(path.join(__dirname, './public')));
2525

26-
app.use(session({secret: 'vancouver', resave: false, saveUninitialized: false}));
26+
app.use(session({secret: 'your-secret', resave: false, saveUninitialized: false}));
2727

2828
app.use(router);
2929

1-Authentication/1-sign-in/AppCreationScripts/sample.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"Sample": {
33
"Title": "A Node.js & Express Web App authenticating users against Azure AD with MSAL Node",
44
"Level": 100,
5-
"Client": "Node.js Express Web App",
5+
"Client": "Node.js & Express Web App",
66
"RepositoryUrl": "ms-identity-javascript-nodejs-tutorial",
77
"Endpoint": "AAD v2.0"
88
},
99
"AADApps": [
1010
{
1111
"Id": "webApp",
12-
"Name": "ExpressWebApp-1",
12+
"Name": "ExpressWebApp-c1s1",
1313
"Kind": "WebApp",
1414
"Audience": "AzureADMyOrg",
1515
"HomePage": "http://localhost:4000",

1-Authentication/1-sign-in/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ description: "This sample demonstrates a Node.js & Express Web App authenticatin
2828

2929
## Overview
3030

31-
This sample demonstrates a Node.js & Express web application that authenticates users against Azure AD, with the help of [Microsoft Authentication Library for Node.js](https://aka.ms/msalnode) (MSAL Node). In doing so, it also illustrates various authentication concepts, such as [OpenID scopes](https://docs.microsoft.com/azure/active-directory/develop/v2-permissions-and-consent#openid-connect-scopes), [ID Tokens](https://docs.microsoft.com/azure/active-directory/develop/id-tokens), [ID Token validation]() and more.
31+
This sample demonstrates a Node.js & Express web application that authenticates users against Azure AD, with the help of [Microsoft Authentication Library for Node.js](https://aka.ms/msalnode) (MSAL Node). In doing so, it also illustrates various authentication concepts, such as [OpenID scopes](https://docs.microsoft.com/azure/active-directory/develop/v2-permissions-and-consent#openid-connect-scopes), [ID Tokens](https://docs.microsoft.com/azure/active-directory/develop/id-tokens), [ID Token validation](https://docs.microsoft.com/azure/active-directory/develop/id-tokens#validating-an-id_token) and more.
3232

3333
## Scenario
3434

@@ -51,7 +51,6 @@ This sample demonstrates a Node.js & Express web application that authenticates
5151
- [Node.js](https://nodejs.org/en/download/) must be installed to run this sample.
5252
- A modern web browser. This sample uses **ES6** conventions and will not run on **Internet Explorer**.
5353
- [Visual Studio Code](https://code.visualstudio.com/download) is recommended for running and editing this sample.
54-
- [VS Code Azure Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-node-azure-pack) extension is recommended for interacting with Azure through VS Code Interface.
5554
- An **Azure AD** tenant. For more information, see: [How to get an Azure AD tenant](https://docs.microsoft.com/azure/active-directory/develop/quickstart-create-new-tenant)
5655
- A user account in your **Azure AD** tenant. This sample will not work with a **personal Microsoft account**. Therefore, if you signed in to the [Azure portal](https://portal.azure.com) with a personal account and have never created a user account in your directory before, you need to do that now.
5756

@@ -175,6 +174,8 @@ Were we successful in addressing your learning objective? Consider taking a mome
175174

176175
## About the code
177176

177+
## Configuration
178+
178179
### Sign-in
179180

180181
### ID Token validation
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Account":{"a283a601-6ad4-4528-975d-6abbefa5edd7.cbaf2168-de14-4c72-9d88-f5f05366dbef-login.windows.net-cbaf2168-de14-4c72-9d88-f5f05366dbef":{"home_account_id":"a283a601-6ad4-4528-975d-6abbefa5edd7.cbaf2168-de14-4c72-9d88-f5f05366dbef","environment":"login.windows.net","realm":"cbaf2168-de14-4c72-9d88-f5f05366dbef","local_account_id":"a283a601-6ad4-4528-975d-6abbefa5edd7","username":"admin@msaltestingjs.onmicrosoft.com","authority_type":"MSSTS","name":"Dogan Erisen","client_info":"eyJ1aWQiOiJhMjgzYTYwMS02YWQ0LTQ1MjgtOTc1ZC02YWJiZWZhNWVkZDciLCJ1dGlkIjoiY2JhZjIxNjgtZGUxNC00YzcyLTlkODgtZjVmMDUzNjZkYmVmIn0"}},"IdToken":{"a283a601-6ad4-4528-975d-6abbefa5edd7.cbaf2168-de14-4c72-9d88-f5f05366dbef-login.windows.net-idtoken-9c8521c1-bab5-4725-a87b-574f83c462c6-cbaf2168-de14-4c72-9d88-f5f05366dbef-":{"home_account_id":"a283a601-6ad4-4528-975d-6abbefa5edd7.cbaf2168-de14-4c72-9d88-f5f05366dbef","environment":"login.windows.net","credential_type":"IdToken","client_id":"9c8521c1-bab5-4725-a87b-574f83c462c6","secret":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCJ9.eyJhdWQiOiI5Yzg1MjFjMS1iYWI1LTQ3MjUtYTg3Yi01NzRmODNjNDYyYzYiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vY2JhZjIxNjgtZGUxNC00YzcyLTlkODgtZjVmMDUzNjZkYmVmL3YyLjAiLCJpYXQiOjE2MDU2Njc5NDEsIm5iZiI6MTYwNTY2Nzk0MSwiZXhwIjoxNjA1NjcxODQxLCJuYW1lIjoiRG9nYW4gRXJpc2VuIiwib2lkIjoiYTI4M2E2MDEtNmFkNC00NTI4LTk3NWQtNmFiYmVmYTVlZGQ3IiwicHJlZmVycmVkX3VzZXJuYW1lIjoiYWRtaW5AbXNhbHRlc3Rpbmdqcy5vbm1pY3Jvc29mdC5jb20iLCJyaCI6IjAuQUFBQWFDR3Z5eFRlY2t5ZGlQWHdVMmJiNzhFaGhaeTF1aVZIcUh0WFQ0UEVZc1pGQURnLiIsInN1YiI6IlBjXzhvdGx4dGIwaG9fM0hVbW9XQW42LTBLOVE3S1lQczk2cVRJNm9LcW8iLCJ0aWQiOiJjYmFmMjE2OC1kZTE0LTRjNzItOWQ4OC1mNWYwNTM2NmRiZWYiLCJ1dGkiOiJxcVFLRHgwMnZFS21pVndlRkxVX0FBIiwidmVyIjoiMi4wIn0.oCfv-zsKIu80y0Z7h7gbzDXxoYhCTX3pWWUYiA7eq_uXbpiu0Kfx52h26ewne2VBykzizMNT9wbhces4yy0eFOgF_y3wapP59C4hhJ-9sJlvSIdVds4M06zSEgZMpbJDUxIZNXj0Wp8RAGEpLNq6Bzq_-IQsCb8EU-ZbEmbPuNnuT55rkc6gGBLcng2C1bRII8WY-sdZM8ucHoFjCY2R8tov4R5YBXkCCWoQraCpMgBGSRPbmelTxoX0gah9IFZuekIS68BgcEmaGKt5vZ1B7g30mv9Olj-5fTMjLMxeFxB-eNYqdIuAnj24pI9fnpTgp5Gm46gIXp4pdW83oqtc1A","realm":"cbaf2168-de14-4c72-9d88-f5f05366dbef"}},"AccessToken":{"a283a601-6ad4-4528-975d-6abbefa5edd7.cbaf2168-de14-4c72-9d88-f5f05366dbef-login.windows.net-accesstoken-9c8521c1-bab5-4725-a87b-574f83c462c6-cbaf2168-de14-4c72-9d88-f5f05366dbef-openid profile email user.read":{"home_account_id":"a283a601-6ad4-4528-975d-6abbefa5edd7.cbaf2168-de14-4c72-9d88-f5f05366dbef","environment":"login.windows.net","credential_type":"AccessToken","client_id":"9c8521c1-bab5-4725-a87b-574f83c462c6","secret":"eyJ0eXAiOiJKV1QiLCJub25jZSI6InRzbWpyaHFfU1lmU1Y0enNfeE4xUll2LUJ4c1pVWGwyNkphWVJDeUxhbUkiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCIsImtpZCI6ImtnMkxZczJUMENUaklmajRydDZKSXluZW4zOCJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9jYmFmMjE2O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pZCBwcm9maWxlIFVzZXIuUmVhZCBlbWFpbCIsInN1YiI6Ikozc0xRRmFSb0taMlViMzBOakNhOE45OWxFWmlwZmpvaDZibHpCUmZOZmciLCJ0ZW5hbnRfcmVnaW9uX3Njb3BlIjoiTkEiLCJ0aWQiOiJjYmFmMjE2OC1kZTE0LTRjNzItOWQ4OC1mNWYwNTM2NmRiZWYiLCJ1bmlxdWVfbmFtZSI6ImFkbWluQG1zYWx0ZXN0aW5nanMub25taWNyb3NvZnQuY29tIiwidXBuIjoiYWRtaW5AbXNhbHRlc3Rpbmdqcy5vbm1pY3Jvc29mdC5jb20iLCJ1dGkiOiJxcVFLRHgwMnZFS21pVndlRkxVX0FBIiwidmVyIjoiMS4wIiwid2lkcyI6WyI2MmU5MDM5NC02OWY1LTQyMzctOTE5MC0wMTIxNzcxNDVlMTAiLCJiNzlmYmY0ZC0zZWY5LTQ2ODktODE0My03NmIxOTRlODU1MDkiXSwieG1zX3N0Ijp7InN1YiI6IlBjXzhvdGx4dGIwaG9fM0hVbW9XQW42LTBLOVE3S1lQczk2cVRJNm9LcW8ifSwieG1zX3RjZHQiOjE1NzkzMDk0MDR9.NpBIIHcC5QNbkiCIIriRDTtOi1dvRh49DMsgCg0OyfzJT7e6hbQWpx7HQ-nT_iwDwh_t8kYC-jJEEkuHvccve0RBvM7Xn86MVZnWDqX5vjhhR9OSA5GNNc25bHLOFcYdgdJCt2HPariEyH4EBlieeAvaMNgUtkmdnaS9s0WRBrjIK7qjUNU97GJvJeC4MPOTU8DAXgS7Vvk_qtGT-scZ2AtK56TdLKH-oyO_GuocGPssEdvsuoYnWHohtIaRgoi3M06tdx0QXXXJAMH4Id78B3-728VxWXYLo4FRVUGZFaPSaIpRblr9ueDAEkKyuoIbsux-sV_x8AjbyctF1Y_aBw","realm":"cbaf2168-de14-4c72-9d88-f5f05366dbef","target":"openid profile email User.Read","cached_at":"1605668241","expires_on":"1605671840","extended_expires_on":"1605675439","token_type":"Bearer"}},"RefreshToken":{"a283a601-6ad4-4528-975d-6abbefa5edd7.cbaf2168-de14-4c72-9d88-f5f05366dbef-login.windows.net-refreshtoken-9c8521c1-bab5-4725-a87b-574f83c462c6--":{"home_account_id":"a283a601-6ad4-4528-975d-6abbefa5edd7.cbaf2168-de14-4c72-9d88-f5f05366dbef","environment":"login.windows.net","credential_type":"RefreshToken","client_id":"9c8521c1-bab5-4725-a87b-574f83c462c6","secret":"0.AAAAaCGvyxTeckydiPXwU2bb78EhhZy1uiVHqHtXT4PEYsZFADg.AgABAAAAAAB2UyzwtQEKR7-rWbgdcBZIAQDs_wIA9P9xJnk7F0ATAJYDzP4xRwBKrRddoqulZj366lseTnqWzQzU6PRjct8FHm7wLjgMS528F8VVgo5sP1TwM2fOcXBymbnox6CN9o5MmsGyM1UA2SSxiLuKzaRVvm3prwzLgqPAwJAAxTvfBa3xGDLiXnLKRflvd4iBk_hIvg-g45jCqjpqPua01SMkwfmnLqLDk3wKA_JpsINiYIax5k--HMFwQ-do6L5hDtHez0I9B607k0C0W1aWqsEbdka1gnMyWQKoxxOXq56XXJUO1EMwfg0wMZrmAzDtyd_N4ynPWsAiuvxV3ELAkq4ST1EevXU0XcGq9lYkTm3H9ehC0x5hIyxVoPn3SEIm-xpwFGxvPfSE1YwyzOZ1_QaURX-POZ3zaOZzp0g4_QSXpQAtaN17sUDjhoZzynWWfkcN8JPBE9rUyTyQblcSXZ3KhlW7dB_aKeBTuKDwiiIehUzRhvCtD9C9_K287Ub5hICYB-fiEVYw6sm2utl-35g3zBIwOuvaNlbxKIzwRot1UR9h63T3O1nPq2DpN0xVA6IarzBIX5O7_-m1jPa-yyY4XajirtVliazOhgZaSKgfIU5QMslG_JJC41rEYBfCDVVlHN6OzIewyYHOm_VOa34PW6t4uBgDR18aeaunez0ovSZbizuBc3yW8kG7ahrEDpzNWOrsnL0uaCugdTWc6rPsPIMqxNoW5dw5x07Eq2cNm-cpyGyyzwxdlxR9gerX39LOc4yKThg4Ww2-NLDPOjwGhCmYfFG0oPbJ47jYvlKHZ73-9XxyiWvz3myeJ9EcWxGzfaK4qEWMH6C_GwG-T1uR1u78DFhiTsa0V6X3hkSoephj6jIHVjBgYB5W0knWK_RfK_ykoGRH3GRRmcrf63hlHNEl2v2vlzrjOd0"}},"AppMetadata":{}}

1-Authentication/2-sign-in-b2c/App/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ app.use(bodyParser.urlencoded({extended: false}));
2323

2424
app.use(express.static(path.join(__dirname, './public')));
2525

26-
app.use(session({secret: 'vancouver', resave: false, saveUninitialized: false}));
26+
app.use(session({secret: 'your-secret', resave: false, saveUninitialized: false}));
2727

2828
app.use(router);
2929

1-Authentication/2-sign-in-b2c/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ description: "This sample demonstrates a Node.js Express Web App application tha
2727

2828
## Overview
2929

30-
This sample demonstrates a Node.js & Express web application that authenticates users against Azure AD, with the help of [Microsoft Authentication Library for Node.js]() (MSAL Node). In doing so, it also illustrates various authentication concepts, such as [OIDC scopes](), [ID Tokens](), [ID Token validation](), [user-flows](), [custom policies]() and more.
30+
This sample demonstrates a Node.js & Express web application that authenticates users against Azure AD, with the help of [Microsoft Authentication Library for Node.js](https://aka.ms/msalnode) (MSAL Node). In doing so, it also illustrates various authentication concepts, such as [OpenID scopes](https://docs.microsoft.com/azure/active-directory/develop/v2-permissions-and-consent#openid-connect-scopes), [ID Tokens](https://docs.microsoft.com/azure/active-directory/develop/id-tokens), [ID Token validation](https://docs.microsoft.com/azure/active-directory/develop/id-tokens#validating-an-id_token), [user-flows](https://docs.microsoft.com/azure/active-directory-b2c/user-flow-overview) and more.
3131

3232
## Scenario
3333

@@ -50,7 +50,6 @@ This sample demonstrates a Node.js & Express web application that authenticates
5050
- [Node.js](https://nodejs.org/en/download/) must be installed to run this sample.
5151
- A modern web browser. This sample uses **ES6** conventions and will not run on **Internet Explorer**.
5252
- [Visual Studio Code](https://code.visualstudio.com/download) is recommended for running and editing this sample.
53-
- [VS Code Azure Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-node-azure-pack) extension is recommended for interacting with Azure through VS Code Interface.
5453
- An **Azure AD B2C** tenant. For more information see: [How to get an Azure AD B2C tenant](https://docs.microsoft.com/azure/active-directory-b2c/tutorial-create-tenant)
5554
- A user account in your **Azure AD B2C** tenant.
5655

@@ -120,9 +119,9 @@ Open the project in your IDE (like Visual Studio or Visual Studio Code) to confi
120119
> In the steps below, "ClientID" is the same as "Application ID" or "AppId".
121120
122121
1. Open the `auth.json` file.
123-
1. Find the key `ClientId` and replace the existing value with the application ID (clientId) of the application copied from the **Azure Portal**.
124-
1. Find the key `TenantId` and replace the existing value with your Azure AD tenant ID copied from the **Azure Portal**.
125-
1. Find the key `ClientSecret` and replace the existing value with the key you saved during the creation of the application, on the **Azure Portal**.
122+
1. Find the key `ClientId` and replace the existing value with the application ID (clientId) of the application copied from **Azure Portal**.
123+
1. Find the key `TenantId` and replace the existing value with your Azure AD tenant ID (or tenant name) copied from **Azure Portal**.
124+
1. Find the key `ClientSecret` and replace the existing value with the key you saved during the creation of the application, on **Azure Portal**.
126125
1. Find the key `homePageRoute` and replace the existing value with the home page route of your application, e.g. `/home`.
127126
1. Find the key `redirectUri` and replace the existing value with the redirect URI that you have registered on **Azure Portal**, e.g. `http://localhost:4000/redirect`.
128127
1. Find the key `postLogoutRedirectUri` and replace the existing value with the URI of the page that you wish to be redirected after signing-out, e.g `http://localhost:4000/`.

1-Authentication/2-sign-in-b2c/auth.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@
1010
"postLogoutRedirectUri": "http://localhost:4000/"
1111
},
1212
"resources": {},
13+
"protected": {},
1314
"policies": {
14-
"authorities": {
15-
"signUpSignIn": {
16-
"authority": "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/B2C_1_susi"
17-
},
18-
"resetPassword": {
19-
"authority": "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/B2C_1_reset"
20-
},
21-
"editProfile": {
22-
"authority": "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/B2C_1_edit_profile"
23-
}
15+
"signUpSignIn": {
16+
"authority": "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/B2C_1_susi"
17+
},
18+
"resetPassword": {
19+
"authority": "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/B2C_1_reset"
20+
},
21+
"editProfile": {
22+
"authority": "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/B2C_1_edit_profile"
2423
},
2524
"authorityDomain": "fabrikamb2c.b2clogin.com"
2625
}

0 commit comments

Comments
 (0)