You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/11-authentication.livemd
+59-72Lines changed: 59 additions & 72 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Authentication is the mechanism that helps guard the front door of an applicatio
26
26
27
27
### Description
28
28
29
-
Thinking back to the example above, authentication is establishing an entity is who they say they are. For applications, this means, the user who is attempting to login, is the user who created and has control over the account. But most applications have multiple levels of users, those with maxium access/privileges to move around and modify the application freely, and those with more restricted access.
29
+
Thinking back to the example above, authentication is establishing an entity is who they say they are. For applications, this means, the user who is attempting to login, is the user who created and has control over the account. But most applications have multiple levels of users, those with maximum access/privileges to move around and modify the application freely, and those with more restricted access.
30
30
31
31
Once an entity has been authenticated, then they are granted access but when implemented in an application/system, this often appears to happen in a single step. Users login and if you get a successful response you also get access to the application. Access immediately follows Authentication, but how much access an entity is allowed and the actions they are permitted to, is authorized, to perform are governed by a set of permissions or access controls referred to as Authorization, which is often managed by a token or similar credentials.
32
32
@@ -54,30 +54,37 @@ Authentication mechanism can be simple or complex. Security industry best pract
54
54
55
55
We mentioned earlier how both authorization (access) and sessions can be handled using tokens. Access Tokens are built so that they contain information about what an authenticated user does and does not have access to, for how long, and they can also be used to manage the user's persistence/ongoing interactions with the application in a session.
56
56
57
-
Tokens are long strings of random characters used to identify an entity, session, as a badge for access and are usually generated by some token generating code, service or server. In token-based implementations, at a highlevel the application or service generates tokens, assign token to users after they have been autenticated, check token validity as users access and use application functionality/features, and end/renew sessions by expiring and refresh tokens.
57
+
Tokens are long strings of random characters used to identify an entity, session, as a badge for access and are usually generated by some token generating code, service or server. In token-based implementations, at a highlevel the application or service generates tokens, assign token to users after they have been authenticated, check token validity as users access and use application functionality/features, and end/renew sessions by expiring and refresh tokens.
58
58
59
+
### OAuth
60
+
Open Authorization(OAuth) is a protocol in which a multi-step arrangement generates a token for a specific users, the user presents as a credential in lieu of a password. There is an extra server (authorization/token generating service or server) that after a user authenticates with it, it generates a token, and brokers authentication/authorization between initial entity and a resource.
59
61
62
+
Originally built for authorization, as it's name suggests, it has evolved for use in the authentication and authorization mechanisms. A very good resource that describes the OAuth in context of it's history and current implementations is here: https://www.youtube.com/watch?v=996OiexHze0
60
63
61
-
Common implementations include OAuth:
64
+
Why use OAuth? When users need access to third party services, outside of your environment where you don't want to share your credentials with those third parties. In OAuth protocol/architecture, an authorization service brokers access and grants users an access token to present, in place of credentials.
62
65
63
-
Open Authorization(OAuth) is a protocol in which a multi-step arrangement generates a token for a specific users, the user presents as a credential in lieu of a password. Client-server model, there is an extra server (authorization/token generating service or server) that after a user authenticates with it, it generateds a token, and brokers authentication/authorization between initial entity and a resource.
66
+
### <spanstyle="color:blue;">Example</span>
64
67
65
-
Originally built for authorization, as it's name suggests, it has evolved for use in the authentication and authorization mechanisms. A very good resource that describes the OAuth in context of it's history and current implementations is here: https://www.youtube.com/watch?v=996OiexHze0
68
+
There are four primary entities involved with the OAuth protocol: requesting, service one, service 2, intermediary server that handles issuing tokens that get presented in lieu of credentials. At a very high level, the flow looks something like
66
69
67
-
JSON Web Tokens (abbreviated JWT, pronounced "jot")
68
-
Multi-use tokens for authentication and session.
69
-
Three components, header contains information identifying type of token and algorithm used for the signature, payload/body that contains data about the disposition of the token, signature - which serves as an integrity check to establish if the token has been modified or tampered with.
70
+
-User Authenticated into Application/Service X
71
+
-Application/Service X prompts user if they want to login using social media account credentials
72
+
-User Logs into social media account/other service
Why use JWT? For post authentication authorization Can be signed and encrypted -> trust; low overhead; Integrity of information being transmitted and non-repudiation; JWT checkers validate token; token belongs to user
80
+
```
76
81
77
-
Expiration /Refresh
82
+
### JWT
83
+
JSON Web Tokens (abbreviated JWT, pronounced "jot") are multi-use tokens for authentication and session management. JWTs have three components, header contains information identifying type of token and algorithm used for the signature, payload/body that contains data about the disposition of the token, signature - which serves as an integrity check to establish if the token has been modified or tampered with.
78
84
79
-
Why use OAuth? when Users need access to third party services, outside of your environment where you don't want to share your credentials with those third parties. In OAuth protocol/architecture, an authorization service brokers access and grants users an access token to present, in place of credentials.
85
+
Tokens, like other authentication credentials, etc. must be protected in transit and at rest and can be Base64 encoded and cryptographically signed
80
86
87
+
Why use JWT? For post authentication authorization, JWTs can be signed and encrypted which helps establish trust. These tokens place little stress on the authentication and authorization mechanisms and help with implementing access controls throughout the application.
One of the concepts we'll discuss later, OAuth, a protocol originally designed for authorization, has evolved into providing authentication as well (not intended).
112
-
113
-
User Authenticated into Application/Service X
114
-
Application/Service X prompts user if they want to login using social media account credentials
Authentication is the first step a user must complete to access a secure application/data. For an application, that means something must be sent from
133
-
user->application authentication mechanism
134
-
and from
135
-
application authentication mechanism-> user -
136
-
137
-
Once an entity is authenticated, subsequent activity/interactions need to be tracked/attributed to the same entity. This is done by
138
-
establishing and manage a Session. This allows a user, once authenticated to have access to the application without having to show their credentials every time they want to perform an action.
114
+
Authentication is the first step a user must complete to access a secure application/data. Once an entity is authenticated, subsequent activity/interactions need to be tracked as belonging to the same entity.
139
115
140
-
Sessions save and keep updated the state of a user while the use an application. Opening time and closing time at a museum. A ticket and/or stamp gets you in and you can come and go in areas allowed by public/membership, but once the museum closes, you have to leave and come back another day. If you have a membership or ticket for multiple visits, you have to show your card/ticket at the door again.
116
+
Some applications do this by establishing and managing a session. Other applications are "session-less" and required a different approach for keeping the application's "knowledge" of what a user is doing while they use an application.
141
117
142
-
Sessions do something similar this for applications. Depending on the application, however, they may be
118
+
For session-less applications, once a user authenticates, the server assigns and sends a token to their client. For any following requests, the client sends their token in each request, like with JWTs discussed previously. The server only checks the validity of the token.
143
119
144
-
Session and Sessionless
120
+
In session oriented applications, one the user authenticates, information in subsequent requests are compared to session information kept on the server.
145
121
146
-
Session is being able to come and go so long as you're carrying your membership card.
147
-
148
-
Session-less ... fire and forget purchasing a single day pass for the museam. You don't get a membership card with your name, and if you're paying cash, probably can't track you individually.
122
+
In a way, this is like a museum visit. A session is like showing your membership card or ticket for the day. Generally you can come and go on your day pass (they'll probably stamp you hand if you leave but you can get back in no problem). Once the museum closes, the session is over and you have to leave and come back another day. If you have a membership or ticket for multiple visits, you have to show your card/ticket at the door again.
149
123
124
+
Session-less, sometimes referred to as "fire and forget it" is like purchasing a single day pass with cash. Your name probably isn't in the system and if you come back a month later to buy another day pass, there's no record of you having been there previously. (For simplicity we'll ignore any tracking.) If you have a membership card with your name, however, and if you're paying cash, probably can't track you individually.
150
125
151
126
## Authentication and Security Concerns
152
127
153
-
An application's authentication mechanism is a critical component. If not securely designed, it can provide an attack vector for malicious actors to gain access to legitimate user accounts, privileged application features, and
128
+
An application's authentication mechanism is a critical component. If not securely designed, it can provide an attack vector for malicious actors to gain access to legitimate user accounts, privileged application features, and sensitive data.
154
129
155
-
Authentication, credentials, should never be stored in cleartext, hardcoded in code base,
130
+
-Authentication, credentials, should never be stored in cleartext, nore hardcoded in source code
156
131
Credential Stuffing Attacks
157
132
Security concerns/examples of multi-factor authentication getting hacked
@@ -163,37 +138,49 @@ Authentication Issues, Weaknesses, Failures make an appearance on multiple lists
163
138
OWASP Top 10 for Web Applications A07:2021-Identification and Authentication Failurs (used to be called Broken Authenticication
164
139
165
140
## Prevention and Countermeasures
166
-
Use built and tested authentication mechanisms in your code language framework. Due to the complexity, it is
141
+
Use built and tested authentication mechanisms in your code language framework.
167
142
168
-
## Quiz
169
143
Authentication is a key component of an application but given its integration with some of the other concepts mentioned in this module, it's implementation in your products can become complex. This module touched on some of the highlights but please refer to the references below for extensive explanations of authentication and related.
**Which of the following OWASP Top 10 Web Application Security Risks are related to the abuse of credentials or flaws in mult-factor authentication implementation?**
173
148
149
+
*Uncomment the line with your answer*
174
150
```
175
-
Which of the following OWASP Top 10 Web Application Security Risks are related to the abuse of credentials or flaws in mult-factor authentication implementation?
176
-
1)A02:2021-Cryptographic Failures
177
-
2)A05:2021-Security Misconfiguration
178
-
3)A07:2021-Identification and Authentication Failures
179
-
4)A08:2017-Insecure Deserialization
151
+
152
+
# A02:2021-Cryptographic Failures
153
+
# A05:2021-Security Misconfiguration
154
+
# A07:2021-Identification and Authentication Failures
155
+
# A08:2017-Insecure Deserialization
156
+
157
+
IO.puts(answer)
180
158
181
159
```
182
160
161
+
**Which two are examples of a credential that can be used in an application's authentication process?**
162
+
163
+
*Uncomment the line with your answer*
164
+
183
165
```
184
-
Which two are examples of a credential that can be used in an application's authentication process?
185
-
1)token
186
-
2)api call
187
-
3)session
188
-
4)username and password
166
+
# token
167
+
# api call
168
+
# session
169
+
# username and password
170
+
171
+
IO.puts(answer)
189
172
190
173
```
174
+
175
+
**Which statement best characterizes how an entity trying to be properly authenticated goes about it?**
176
+
191
177
```
192
-
Which statement best characterizes how an entity trying to be properly authenticated goes about it?
193
-
1)Hello, I just came from X street and would like to enter your establishment. I am who I say I am and I can show you proof. May I enter?
194
-
2)Let me in, now! Let me in , now! Let me in, now!!!!!
195
-
3)Trust me, I'm harmless
196
-
4)Yes, I know that id doesn't look like me but my friend said I can use it so it's ok
178
+
*Uncomment the line with your answer*
179
+
180
+
# Hello, I just came from X street and would like to enter your establishment. I am who I say I am and I can show you proof. May I enter?
181
+
# Let me in, now! Let me in , now! Let me in, now!!!!!
182
+
# Trust me, I'm harmless
183
+
# Yes, I know that id doesn't look like me but my friend said I can use it so it's ok
0 commit comments