Skip to content

Commit 1ff64ec

Browse files
committed
updated bootstrap and added retelimit
1 parent 21aa284 commit 1ff64ec

File tree

5 files changed

+55
-10
lines changed

5 files changed

+55
-10
lines changed

1-Authentication/1-sign-in/App/index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
77
<title>Microsoft identity platform</title>
88
<link rel="SHORTCUT ICON" href="./favicon.svg" type="image/x-icon">
9+
<link rel="stylesheet" href="./styles.css">
10+
911

1012
<!-- msal.min.js can be used in the place of msal.js; included msal.js to make debug easy -->
1113
<script id="load-msal" src="https://alcdn.msauth.net/browser/2.31.0/js/msal-browser.js"
1214
integrity="sha384-BO4qQ2RTxj2akCJc7t6IdU9aRg6do4LGIkVVa01Hm33jxM+v2G+4q+vZjmOCywYq"
1315
crossorigin="anonymous"></script>
1416

15-
<!-- adding Bootstrap 4 for UI components -->
16-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
17+
<!-- adding Bootstrap 5 for UI components -->
18+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
1719
</head>
1820

1921
<body>
20-
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
22+
<nav class="navbar navbar-expand-lg navbar-dark bg-primary navbarStyle">
2123
<a class="navbar-brand" href="/">Microsoft identity platform</a>
22-
<div class="btn-group ml-auto dropleft">
24+
<div class="collapse navbar-collapse justify-content-end">
2325
<button type="button" id="signIn" class="btn btn-secondary" onclick="signIn()">Sign-in</button>
2426
<button type="button" id="signOut" class="btn btn-success d-none" onclick="signOut()">Sign-out</button>
2527
</div>
@@ -50,12 +52,10 @@ <h5 id="welcome-div" class="card-header text-center d-none"></h5>
5052
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
5153
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
5254
</script>
53-
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js"
54-
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
55-
</script>
56-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js"
57-
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
58-
</script>
55+
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
56+
57+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
58+
5959

6060
<!-- importing app scripts (load order is important) -->
6161
<script type="text/javascript" src="./authConfig.js"></script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.navbarStyle {
2+
padding: .5rem 1rem !important;
3+
}

1-Authentication/1-sign-in/package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1-Authentication/1-sign-in/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"homepage": "https://github.com/Azure-Samples/ms-identity-javascript-tutorial#readme",
3131
"dependencies": {
3232
"express": "^4.18.2",
33+
"express-rate-limit": "^6.7.0",
3334
"morgan": "^1.10.0"
3435
},
3536
"devDependencies": {

1-Authentication/1-sign-in/server.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,34 @@ const express = require('express');
22
const morgan = require('morgan');
33
const path = require('path');
44

5+
const rateLimit = require('express-rate-limit');
6+
7+
58
const DEFAULT_PORT = process.env.PORT || 3000;
69

710
// initialize express.
811
const app = express();
912

13+
14+
/**
15+
* HTTP request handlers should not perform expensive operations such as accessing the file system,
16+
* executing an operating system command or interacting with a database without limiting the rate at
17+
* which requests are accepted. Otherwise, the application becomes vulnerable to denial-of-service attacks
18+
* where an attacker can cause the application to crash or become unresponsive by issuing a large number of
19+
* requests at the same time. For more information, visit: https://cheatsheetseries.owasp.org/cheatsheets/Denial_of_Service_Cheat_Sheet.html
20+
*/
21+
const limiter = rateLimit({
22+
windowMs: 15 * 60 * 1000, // 15 minutes
23+
max: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes)
24+
standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
25+
legacyHeaders: false, // Disable the `X-RateLimit-*` headers
26+
});
27+
28+
29+
// Apply the rate limiting middleware to all requests
30+
app.use(limiter);
31+
32+
1033
// Configure morgan module to log all requests.
1134
app.use(morgan('dev'));
1235

0 commit comments

Comments
 (0)