Skip to content

Commit 0524fab

Browse files
authored
Merge pull request #36 from kengaderdus/add-out-of-repo-reference-tags
Add out of repo code reference tags
2 parents 5298361 + f61c6e3 commit 0524fab

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

index.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ const passport = require('passport');
44
const config = require('./config.json');
55
const todolist = require('./todolist');
66
const cors = require('cors');
7-
const BearerStrategy = require('passport-azure-ad').BearerStrategy;
87

8+
//<ms_docref_import_azuread_lib>
9+
const BearerStrategy = require('passport-azure-ad').BearerStrategy;
10+
//</ms_docref_import_azuread_lib>
911

1012
global.global_todos = [];
1113

14+
//<ms_docref_azureadb2c_options>
1215
const options = {
1316
identityMetadata: `https://${config.credentials.tenantName}.b2clogin.com/${config.credentials.tenantName}.onmicrosoft.com/${config.policies.policyName}/${config.metadata.version}/${config.metadata.discovery}`,
1417
clientID: config.credentials.clientID,
@@ -20,12 +23,15 @@ const options = {
2023
passReqToCallback: config.settings.passReqToCallback
2124
}
2225

26+
//</ms_docref_azureadb2c_options>
27+
28+
//<ms_docref_init_azuread_lib>
2329
const bearerStrategy = new BearerStrategy(options, (token, done) => {
2430
// Send user info using the second argument
2531
done(null, { }, token);
2632
}
2733
);
28-
34+
//</ms_docref_init_azuread_lib>
2935
const app = express();
3036

3137
app.use(express.json());
@@ -44,7 +50,8 @@ passport.use(bearerStrategy);
4450
// To do list endpoints
4551
app.use('/api/todolist', todolist);
4652

47-
// API endpoint
53+
//<ms_docref_protected_api_endpoint>
54+
// API endpoint, one must present a bearer accessToken to access this endpoint
4855
app.get('/hello',
4956
passport.authenticate('oauth-bearer', {session: false}),
5057
(req, res) => {
@@ -55,9 +62,12 @@ app.get('/hello',
5562
res.status(200).json({'name': req.authInfo['name']});
5663
}
5764
);
65+
//</ms_docref_protected_api_endpoint>
5866

59-
// API anonymous endpoint
67+
//<ms_docref_anonymous_api_endpoint>
68+
// API anonymous endpoint, returns a date to the caller.
6069
app.get('/public', (req, res) => res.send( {'date': new Date() } ));
70+
//</ms_docref_anonymous_api_endpoint>
6171

6272
const port = process.env.PORT || 5000;
6373

0 commit comments

Comments
 (0)