Skip to content

Commit cc38422

Browse files
authored
Merge pull request #22 from ReCoded-Org/module5
Module 5 full content
2 parents 55e87d8 + b6d25ed commit cc38422

File tree

33 files changed

+1070
-458
lines changed

33 files changed

+1070
-458
lines changed

module2-databases/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Last revised: 31/10/2021
44

55
## Summary
66
Web applications that persist data between visits inevitably use a database. Students
7-
familiarize themselves with the relational and non-relational databases used in todays
7+
familiarize themselves with the relational and non-relational databases used in today's
88
ecosystem and their query languages: MySQL, PostgreSQL, MongoDB. Students
99
explore the advantages and disadvantages of each technology, understanding the
1010
appropriate use cases for each one.

module4-authentication-and-security/r1.3-authentication-persistence/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,17 @@ When the JWT is passed back to the server in the header, we check the claims, an
188188

189189
## Pros and Cons of JSON Web Tokens
190190

191-
JWTs are becoming more and more ubiquitous. Customer identity and access management (CIAM) providers everywhere are pushing JWTs as the silver bullet for everything. JWTs are pretty cool, but lets talk about some of the downsides of JWTs and some of their strong benefits.
191+
JWTs are becoming more and more ubiquitous. Customer identity and access management (CIAM) providers everywhere are pushing JWTs as the silver bullet for everything. JWTs are pretty cool, but let's talk about some of the downsides of JWTs and some of their strong benefits.
192192

193193
### PRO: JWTs are portable units of identity
194194

195-
That means they contain identity information as JSON and can be passed around to services and applications. Any service or application can verify a JWT itself. The service/application receiving a JWT doesnt need to ask the identity provider that generated the JWT if it is valid or check any database for it. Once a JWT is verified, the service or application can use the data inside it to take action on behalf of the user. Plus, it works across different clients and domains.
195+
That means they contain identity information as JSON and can be passed around to services and applications. Any service or application can verify a JWT itself. The service/application receiving a JWT doesn't need to ask the identity provider that generated the JWT if it is valid or check any database for it. Once a JWT is verified, the service or application can use the data inside it to take action on behalf of the user. Plus, it works across different clients and domains.
196196

197197
### PRO: Token-based Authentication is more Scalable and Efficient
198198

199199
Imagine your app has billions of users, and each of them creates a session. Eventually, the session storage will become pretty big and harder to maintain.
200200

201-
Tokens on the other hand are required to be stored on the users end, they offer a scalable solution.
201+
Tokens on the other hand are required to be stored on the user's end, they offer a scalable solution.
202202

203203
Moreover, the server just needs to create and verify the tokens along with the information, which means that maintaining more users on a website or application at once is possible without any hassle.
204204

@@ -212,9 +212,9 @@ This helps in encouraging more collaboration opportunities between enterprises a
212212

213213
Since tokens like JWT are stateless, only a secret key can validate it when received at a server-side application, which was used to create it.
214214

215-
Hence theyre considered the best and the most secure way of offering authentication.
215+
Hence they're considered the best and the most secure way of offering authentication.
216216

217-
Tokens act as a storage for the users credentials and when the token travels between the server or the web browser, the stored credentials are never compromised.
217+
Tokens act as a storage for the user's credentials and when the token travels between the server or the web browser, the stored credentials are never compromised.
218218

219219
### CON: Compromised Secret Key
220220

@@ -238,13 +238,13 @@ To solve this problem, most applications use refresh tokens. Refresh tokens are
238238

239239
The overall size of a JWT is quite more than that of a normal session token, which makes it longer whenever more data is added to it.
240240

241-
So, if youre adding more claims in the token, it will impact the overall loading speed and thus hamper the user experience.
241+
So, if you're adding more claims in the token, it will impact the overall loading speed and thus hamper the user experience.
242242

243243
This situation can be fixed if the right development practices are followed and minimum but essential data is added to the JWT.
244244

245-
### CON: JWTs arent easily revocable
245+
### CON: JWTs aren't easily revocable
246246

247-
This means that a JWT could be valid even though the users account has been suspended or deleted. Some solutions around this are available but they mostly require trips to the identity provider or the database, which JWT is essentially developed to minimize.
247+
This means that a JWT could be valid even though the user's account has been suspended or deleted. Some solutions around this are available but they mostly require trips to the identity provider or the database, which JWT is essentially developed to minimize.
248248

249249
So if your app has the potential to deactivate or revoke user access frequently, think twice before using JWTs.
250250

module4-authentication-and-security/r1.5-authorization-through-middleware/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This lesson objectives are:
1111

1212
## Middleware
1313

14-
Middleware are functions that have access to the [request object](https://expressjs.com/en/4x/api.html#req) (`req`), the [response object](https://expressjs.com/en/4x/api.html#res) (`res`), and the next middleware function in the applications request-response cycle. The next middleware function is commonly denoted by a variable named `next`.
14+
Middleware are functions that have access to the [request object](https://expressjs.com/en/4x/api.html#req) (`req`), the [response object](https://expressjs.com/en/4x/api.html#res) (`res`), and the next middleware function in the application's request-response cycle. The next middleware function is commonly denoted by a variable named `next`.
1515

1616
```js
1717
const loggerMiddleware = (req, res, next) => {
@@ -115,7 +115,7 @@ app.use(function (err, req, res, next) {
115115

116116
Usually, an error logging service like [sentry](https://sentry.io/) is also contacted in this middleware to log and track the error so you get notified when your app has run into an unhandled exception, with the required request-response details that can help the developers reproduce the error to fix it.
117117

118-
> ⚠️ **Warning**: Error-handling middleware always takes **four** arguments. You must provide four arguments to identify it as an error-handling middleware function. Even if you dont need to use the next object, you must specify it to maintain the signature. Otherwise, the next object will be interpreted as regular middleware and will fail to handle errors.
118+
> ⚠️ **Warning**: Error-handling middleware always takes **four** arguments. You must provide four arguments to identify it as an error-handling middleware function. Even if you don't need to use the next object, you must specify it to maintain the signature. Otherwise, the next object will be interpreted as regular middleware and will fail to handle errors.
119119
120120
## Auth guard middleware
121121

module4-authentication-and-security/r2-auth-schemes/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ Whenever users go to a domain that requires authentication, they are redirected
1919

2020
### How does SSO work?
2121

22-
SSO works based upon a trust relationship set up between an application, known as the service provider, and an identity provider, like [OneLogin](https://www.onelogin.com/) or [Auth0](https://auth0.com/). This trust relationship is often based upon a certificate that is exchanged between the identity provider and the service provider. This certificate can be used to sign identity information that is being sent from the identity provider to the service provider so that the service provider knows it is coming from a trusted source. In SSO, this identity data takes the form of JWTs which contain identifying bits of information about the user like a users email address or a username.
22+
SSO works based upon a trust relationship set up between an application, known as the service provider, and an identity provider, like [OneLogin](https://www.onelogin.com/) or [Auth0](https://auth0.com/). This trust relationship is often based upon a certificate that is exchanged between the identity provider and the service provider. This certificate can be used to sign identity information that is being sent from the identity provider to the service provider so that the service provider knows it is coming from a trusted source. In SSO, this identity data takes the form of JWTs which contain identifying bits of information about the user like a user's email address or a username.
2323

2424
The login flow usually looks like this:
2525

2626
1. A user browses to the application or website they want access to, aka, the Service Provider.
2727
2. The Service Provider sends a token that contains some information about the user, like their email address, to the SSO system, aka, the Identity Provider, as part of a request to authenticate the user.
2828
3. The Identity Provider first checks to see whether the user has already been authenticated, in which case it will grant the user access to the Service Provider application and skip to step 5.
29-
4. If the user hasnt logged in, they will be prompted to do so by providing the credentials required by the Identity Provider. This could simply be a username and password or it might include some other form of authentication like a One-Time Password (OTP).
29+
4. If the user hasn't logged in, they will be prompted to do so by providing the credentials required by the Identity Provider. This could simply be a username and password or it might include some other form of authentication like a One-Time Password (OTP).
3030
5. Once the Identity Provider validates the credentials provided, it will send a token back to the Service Provider confirming a successful authentication.
31-
6. This token is passed through the users browser to the Service Provider.
31+
6. This token is passed through the user's browser to the Service Provider.
3232
7. The token that is received by the Service Provider is validated according to the trust relationship that was set up between the Service Provider and the Identity Provider during the initial configuration.
3333
8. The user is granted access to the Service Provider.
3434

@@ -176,7 +176,7 @@ This scheme was prominent in many apps, like asking for your bank username and p
176176
![Shady Budget Planner](../assets/shady-budget-planner.jpg)
177177
_Image rights belong to [Okta Developers](https://developer.okta.com/blog/2019/10/21/illustrated-guide-to-oauth-and-oidc)_
178178

179-
You should never be required to share your username and password, your credentials, to another service. Theres no guarantee that an organization will keep your credentials safe, or guarantee their service wont access more of your personal information than necessary. It might sound crazy, but some applications still try to get away with this!
179+
You should never be required to share your username and password, your credentials, to another service. There's no guarantee that an organization will keep your credentials safe, or guarantee their service won't access more of your personal information than necessary. It might sound crazy, but some applications still try to get away with this!
180180

181181
To the rescue comes OAuth, an agreed-upon standard to securely allow one service to access data from another.
182182

module4-authentication-and-security/r3-other-security-vulnerabilities-practices/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ In this lesson you will learn about:
1313

1414
## Cross-site request forgery (CSRF)
1515

16-
[CSRF](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html) is an attack that forces an end user to execute unwanted actions on a web application in which theyre currently authenticated. With a little help of social engineering (such as sending a link via email or chat), an attacker may trick the users of a web application into executing actions of the attackers choosing. If the victim is a normal user, a successful CSRF attack can force the user to perform state changing requests like transferring funds, changing their email address, and so forth. If the victim is an administrative account, CSRF can compromise the entire web application.
16+
[CSRF](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html) is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated. With a little help of social engineering (such as sending a link via email or chat), an attacker may trick the users of a web application into executing actions of the attacker's choosing. If the victim is a normal user, a successful CSRF attack can force the user to perform state changing requests like transferring funds, changing their email address, and so forth. If the victim is an administrative account, CSRF can compromise the entire web application.
1717

1818
### How does it work?
1919

module5-testing/README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
1-
# curriculum-backend-readings
1+
# Module 5: Testing
2+
3+
Last revised: 07/12/2021
4+
5+
## Summary
6+
7+
No company can scale beyond a small project without automated testing. Students will
8+
learn about unit and integration testing, in addition to learning best practices
9+
surrounding writing clean, modular, and hermetic tests. This unit will emphasize not
10+
only writing tests as a means to verify robustness of code, but also utilizing test-writing as a developer mindset for writing safe code.
11+
12+
## Outline
13+
14+
- 1 [Introduction to testing [R]](../module5-testing/r1-introduction-to-testing/README.md)
15+
16+
- 1.1 [Testing Philosophy [R]](../module5-testing/r1.1-testing-philosphy/README.md)
17+
18+
- 1.2 [Types of tests [R]](../module5-testing/r1.2-types-of-tests/README.md)
19+
20+
- 2 [Testing in JavaScript [R]](../module5-testing/r2-testing-in-javascript/README.md)
21+
22+
- 2.1 [Testing examples [R]](../module5-testing/r2.1-testing-examples/README.md)
23+
24+
- 2.2 [Mocking [R]](../module5-testing/r2.2-mocking/README.md)
25+
26+
- 2.3 [Test coverage [R]](../module5-testing/r2.3-test-coverage/README.md)
27+
28+
- 2.4 [Static analysis testing [R]](../module5-testing/r2.4-static-analysis-testing/README.md)
29+
30+
- 2.5 [CI/CD [R]](../module5-testing/r2.5-ci-cd/README.md)
31+
32+
- 3 [Testing Pure Functions [L]](../module5-testing/r3-testing-pure-functions/README.md)
33+
34+
- 3.1 [Mocking Practice [L]](../module5-testing/r3.1-mocking-practice/README.md)
35+
36+
- 3.2 [Testing Controllers and API Routes [L]](../module5-testing/r3.2-testing-controllers-routes/README.md)
37+
38+
- 3.3 [Testing Middleware [L]](../module5-testing/r3.3-testing-middleware/README.md)
39+
40+
- 3.4 [Testing Authenticated Code [L]](../module5-testing/r3.4-testing-authenticated-code/README.md)
41+
42+
- 4 [Summary [R]](../module5-testing/r4-summary/README.md)

module5-testing/assets/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.
24.4 KB
Loading
8.54 KB
Loading

module5-testing/assets/pyramid2.jpeg

23.7 KB
Loading

0 commit comments

Comments
 (0)