Skip to content

Commit 2e9c7e6

Browse files
committed
ch1 first cut
1 parent ad6e735 commit 2e9c7e6

52 files changed

Lines changed: 5074 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODE_OF_CONDUCT.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Microsoft Open Source Code of Conduct
2+
3+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4+
5+
Resources:
6+
7+
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8+
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9+
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns

.github/ISSUE_TEMPLATE.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!-- IF SUFFICIENT INFORMATION IS NOT PROVIDED VIA THE FOLLOWING TEMPLATE THE ISSUE MIGHT BE CLOSED WITHOUT FURTHER CONSIDERATION -->
2+
3+
# Issue
4+
5+
> Please provide us with the following information:
6+
7+
## This issue is for the sample
8+
9+
<!-- mark with an `x` -->
10+
11+
```console
12+
- [ ] 1-1) Sign-in with Azure AD
13+
- [ ] 1-2) Sign-in with Azure AD B2C
14+
- [ ] 2-1) Acquire a Token and call Microsoft Graph
15+
- [ ] 2-2) Protect and call a web API on Azure AD
16+
- [ ] 2-3) Protect and call a web API on Azure AD B2C
17+
- [ ] 4) Deploy to Azure Storage and App Service
18+
```
19+
20+
## This issue is for a
21+
22+
<!-- mark with an `x` -->
23+
24+
```console
25+
- [ ] bug report -> please search issues before submitting
26+
- [ ] question
27+
- [ ] feature request
28+
- [ ] documentation issue or request
29+
```
30+
31+
### Minimal steps to reproduce
32+
33+
>
34+
35+
### Any log messages given by the failure
36+
37+
>
38+
39+
### Expected/desired behavior
40+
41+
>
42+
43+
### Library version
44+
45+
>
46+
47+
### Browser and version
48+
49+
> Chrome, Edge, Firefox, Safari?
50+
51+
### Mention any other details that might be useful
52+
53+
>
54+
55+
Thanks! We'll be in touch soon.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Pull Request
2+
3+
## Purpose
4+
5+
<!-- Describe the intention of the changes being proposed. What problem does it solve or functionality does it add? -->
6+
7+
* ...
8+
9+
## Does this introduce a breaking change
10+
11+
<!-- mark with an `x` -->
12+
13+
```console
14+
[ ] Yes
15+
[ ] No
16+
```
17+
18+
## Pull request type
19+
20+
What kind of change does this Pull Request introduce?
21+
22+
<!-- mark with an `x` -->
23+
24+
```console
25+
[ ] Bugfix
26+
[ ] Feature
27+
[ ] Code style update (formatting, local variables)
28+
[ ] Documentation content changes
29+
[ ] Other... Please describe:
30+
```
31+
32+
## How to test
33+
34+
* Get the code
35+
36+
```console
37+
git clone [repo-address]
38+
cd [repo-name]
39+
git checkout [branch-name]
40+
npm install
41+
```
42+
43+
* Test the code
44+
45+
<!-- Add steps to run the tests suite and/or manually test -->
46+
47+
```console
48+
49+
```
50+
51+
## What to check
52+
53+
ex: verify that the following are valid:
54+
55+
* ...
56+
57+
## Other Information
58+
<!-- Add any other helpful information that may be needed here. -->
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
const express = require('express');
6+
const session = require('express-session');
7+
const bodyParser = require('body-parser');
8+
const path = require('path');
9+
10+
const router = require('./routes/router');
11+
12+
const SERVER_PORT = process.env.PORT || 5000;
13+
14+
const app = express();
15+
16+
app.set('views', path.join(__dirname, './views'));
17+
app.set('view engine', 'ejs');
18+
19+
app.use('/css', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/css')));
20+
app.use('/js', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/js')));
21+
22+
app.use(bodyParser.urlencoded({extended: false}));
23+
24+
app.use(express.static(path.join(__dirname, './public')));
25+
26+
app.use(session({secret: 'vancouver', resave: false, saveUninitialized: false}));
27+
28+
app.use(router);
29+
30+
app.listen(SERVER_PORT, () => console.log(`Msal Node Auth Code Sample app listening on port ${SERVER_PORT}!`));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
exports.getHomePage = (req, res, next) => {
2+
const isAuthenticated = req.session.isAuthenticated;
3+
res.render('home', { isAuthenticated: isAuthenticated });
4+
}
5+
6+
exports.getProfile = (req, res, next) => {
7+
const isAuthenticated = req.session.isAuthenticated;
8+
const claims = req.session.idTokenClaims;
9+
10+
res.render('profile', {isAuthenticated: isAuthenticated, claims: claims});
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Not Permitted
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Page Not Found
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
h1 {
2+
color: red;
3+
}
4+
5+
#card-div {
6+
min-width: 40%;
7+
margin: 5% auto 5% auto;
8+
}
9+
10+
#form-area-div {
11+
width: 55%;
12+
margin: 5% auto 5% auto;
13+
}
14+
15+
.table-area-div {
16+
width: 70%;
17+
margin: 5% auto 5% auto;
18+
}
19+
20+
.footer {
21+
position: fixed;
22+
left: 0;
23+
bottom: 0;
24+
width: 100%;
25+
text-align: center;
26+
}
27+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const express = require('express');
2+
3+
const identity = require('../utils/identity');
4+
const mainController = require('../controllers/mainController');
5+
6+
// initialize router
7+
const router = express.Router();
8+
9+
// app routes
10+
router.get('/', (req, res, next) => res.redirect('/home'));
11+
router.get('/home', mainController.getHomePage);
12+
13+
// authentication routes
14+
router.get('/signin', identity.signIn);
15+
router.get('/signout', identity.signOut);
16+
router.get('/redirect', identity.handleRedirect);
17+
18+
// protected routes
19+
router.get('/profile', identity.isAuthenticated, identity.getToken, mainController.getProfile); // get token for this route to call web API
20+
21+
// 404
22+
router.get('*', (req, res) => res.status(404).redirect('/404.html'));
23+
24+
module.exports = router;

0 commit comments

Comments
 (0)