Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit ef158f7

Browse files
committed
change method signature and update scopes
1 parent 6757c68 commit ef158f7

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

6-AdvancedScenarios/3-call-api-acrs/API/auth/AuthProvider.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AuthProvider {
1616
return new msal.ConfidentialClientApplication(msalConfig);
1717
}
1818

19-
async login(req, res, next) {
19+
login = async (req, res, next) => {
2020
// create a GUID for csrf
2121
req.session.csrfToken = this.cryptoProvider.createNewGuid();
2222

@@ -129,7 +129,7 @@ class AuthProvider {
129129
}
130130
}
131131

132-
async handleRedirect(req, res, next) {
132+
handleRedirect = async (req, res, next) => {
133133
const authCodeRequest = {
134134
...req.session.authCodeRequest,
135135
code: req.body.code, // authZ code
@@ -218,7 +218,7 @@ class AuthProvider {
218218
* @param res: Express response object
219219
* @param next: Express next function
220220
*/
221-
async logout(req, res, next) {
221+
logout = async (req, res, next) => {
222222
/**
223223
* Construct a logout URI and redirect the user to end the
224224
* session with Azure AD. For more information, visit:

6-AdvancedScenarios/3-call-api-acrs/API/auth/routeGuard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const checkForRequiredAuthContext = require('./claimsManager');
1+
const checkForRequiredAuthContext = require('./claimsHelper');
22
const AuthContext = require('../models/authContext');
33

44
const authContextGuard = async (req, res, next) => {

6-AdvancedScenarios/3-call-api-acrs/API/authConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const msalConfig = {
3434
const protectedResources = {
3535
msGraphAcrs: {
3636
endpoint: 'https://graph.microsoft.com/beta/identity/conditionalAccess/policies',
37-
scopes: ['Policy.ReadWrite.ConditionalAccess', 'Policy.Read.ConditionalAccess'],
37+
scopes: ['Policy.Read.ConditionalAccess'],
3838
},
3939
};
4040

6-AdvancedScenarios/3-call-api-acrs/API/routes/adminRoutes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ router.get('/', (req, res, next) => res.redirect('/admin/home'));
1818
router.get('/home', dashboardController.getHomePage);
1919

2020
// authentication routes
21-
router.get('/signin', (req, res, next) => authProvider.login(req, res, next));
22-
router.get('/signout', (req, res, next) => authProvider.logout(req, res, next));
23-
router.post('/redirect', (req, res, next) => authProvider.handleRedirect(req, res, next));
21+
router.get('/signin', authProvider.login);
22+
router.get('/signout', authProvider.logout);
23+
router.post('/redirect', authProvider.handleRedirect);
2424

2525
// check if user is authenticated, then obtain an access token for the specified resource
2626
router.get(

6-AdvancedScenarios/3-call-api-acrs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The web API is protected using [passport-azure-ad](https://github.com/AzureAD/pa
3838
| `SPA/src/fetch.js` | Claims challenge for the client is handled here. |
3939
| `API/authConfig.js` | Authentication parameters for the web API project. |
4040
| `API/auth/routeGuard.js` | Custom middleware protecting app routes |
41-
| `API/auth/claimsManager.js` | Custom middleware handling checking for auth context and generating claims challenge. |
41+
| `API/auth/claimsHelper.js` | Custom middleware handling checking for auth context and generating claims challenge. |
4242
| `API/app.js` | passport-azure-ad is initialized here. |
4343

4444
## Prerequisites
@@ -354,7 +354,7 @@ const authContextGuard = (req, res, next) => {
354354
}
355355
```
356356

357-
In [claimsManager.js](./API/auth/claimsManager.js):
357+
In [claimsHelper.js](./API/auth/claimsHelper.js):
358358

359359
```javascript
360360
const checkForRequiredAuthContext = (req, res, next, authContextId) => {
@@ -386,7 +386,7 @@ const isClientCapableOfClaimsChallenge = (accessTokenClaims) => {
386386

387387
### Generating claims challenge
388388

389-
If there is an auth context entry in the database and the incoming request does not contain an access token with the necessary claims, the web API needs to create a **claims challenge** and send it to client application to allow the user to satisfy the challenge (for instance, perform multi-factor authentication). This is shown in [claimsManager.js](./API/auth/claimsManager.js):
389+
If there is an auth context entry in the database and the incoming request does not contain an access token with the necessary claims, the web API needs to create a **claims challenge** and send it to client application to allow the user to satisfy the challenge (for instance, perform multi-factor authentication). This is shown in [claimsHelper.js](./API/auth/claimsHelper.js):
390390

391391
```javascript
392392
const generateClaimsChallenge = (authContextId) => {

0 commit comments

Comments
 (0)