Skip to content

Commit 5fd0aed

Browse files
committed
Proof reading, fix styles and guides order
1 parent c844c81 commit 5fd0aed

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

_guides/2019-09-14-password-breach-lookup-and-other-password-validation-rules.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ They are based on the [NIST SP800-63b recommendations](https://pages.nist.gov/80
1818

1919
## Passwords obtained from previous breaches
2020

21-
To check for breached passwords, we'll use the [haveibeenpwned.com](https://haveibeenpwned.com/).
21+
We'll use [haveibeenpwned.com](https://haveibeenpwned.com/) to check for breached passwords.
2222

2323
For the sake of brevity, we'll use [`ExPwned`](https://hex.pm/packages/ex_pwned) in the following example, but you can use any client or your own [custom module](https://ieftimov.com/post/haveibeenpwned-password-lookup-elixir/) to communicate with the API.
2424

@@ -35,7 +35,7 @@ end
3535

3636
Run `mix deps.get` to install it.
3737

38-
Now let's add the password validation rule to the user module:
38+
Now let's add the password validation rule to our user schema module:
3939

4040
```elixir
4141
defmodule MyApp.Users.User do
@@ -72,7 +72,13 @@ We'll only do a lookup if the password has been changed, and we don't do any loo
7272

7373
## Context-specific words, such as the name of the service, the username, and derivatives thereof
7474

75-
We want to prevent context specific words. If the user id is `[email protected]` (or `john.doe` if username), then the password can't be `[email protected]` or `johndoeexamplecom` (or for username `john.doe00` or `johndoe001`). Likewise, our platform may be called `My Demo App` so we don't want to permit a passwords like `my demo app`, `my_demo_app` or `mydemoapp`.
75+
We want to prevent context specific words to be used as passwords.
76+
77+
The context might be public user details. If the users email is `[email protected]` then the password can't be `[email protected]` or `johndoeexamplecom`. The same rule applies for any user id we may use, such as username. If the username is `john.doe` then `john.doe00` or `johndoe001` can't be used.
78+
79+
Our app may also be part of a website/service/platform and have an identity. As an example, if the service is called `My Demo App` then we don't want to permit passwords like `my demo app`, `my_demo_app` or `mydemoapp`.
80+
81+
We'll add the password validation rule to our user schema module:
7682

7783
```elixir
7884
defmodule MyApp.Users.User do
@@ -116,7 +122,9 @@ We're using the [`String.jaro_distance/2`](https://hexdocs.pm/elixir/String.html
116122

117123
## Repetitive or sequential characters
118124

119-
We want to prevent repetitive passwords such as `aaa`, `1234` or `abcd`. We'll set up the following validations so there may be no more than two repeating or three sequential characters in the password.
125+
We want to prevent repetitive or sequential characters in passwords such as `aaa`, `1234` or `abcd`.
126+
127+
The rule we'll use is that there may be no more than two repeating or three sequential characters in the password. We'll add the validation rule to our user schema module:
120128

121129
```elixir
122130
defmodule MyApp.Users.User do
@@ -183,11 +191,11 @@ defmodule MyApp.Users.User do
183191
end
184192
```
185193

186-
As you can see, you'll be able to modify `@sequences` and add what is appropriate for your app. It may be that you want to support another alphabet or keyboard sequences like `qwerty`.
194+
As you can see, you'll be able to modify `@sequences` and add what is appropriate for your app. It may be that you want to support another alphabet or keyboard layout sequences like `qwerty`.
187195

188196
## Dictionary words
189197

190-
A dictionary lookup is very easy to create, so we will only provide a very simple example:
198+
A dictionary lookup is very easy to create. This is just a very simple example that you can add to your user schema module:
191199

192200
```elixir
193201
defmodule MyApp.Users.User do
@@ -228,15 +236,13 @@ defmodule MyApp.Users.User do
228236
end
229237
```
230238

231-
This will iterate through a plain text file with all dictionary words separated by newlines.
239+
In the above `priv/dictionary.txt` will be processed on compile time. The plain text file contains words separated by newline.
232240

233241
## Require users to change weak password upon sign in
234242

235243
You may want to ensure that users update their password if they have been breached or are too weak. You can do this be requiring users to reset their password upon sign in.
236244

237-
This can be dealt with in a plug, or [custom controller](https://hexdocs.pm/pow/custom_controllers.html).
238-
239-
Here's how a plug method could look:
245+
This can be dealt with in a plug, or [custom controller](https://hexdocs.pm/pow/custom_controllers.html). A plug method could look like this:
240246

241247
```elixir
242248
def check_password(conn, _opts) do
@@ -257,11 +263,15 @@ def check_password(conn, _opts) do
257263
end
258264
```
259265

266+
The user will be redirected to the reset password page, and the connection halted so authentication won't happen. A caveat to this is that the user may not have entered valid credentials, since this runs before any authentication.
267+
260268
## Conclusion
261269

262270
As you can see it is easy to customize and extend the password validation rules of Pow.
263271

264-
The landscape of web security is constantly changing, so it's important that password requirements are neither so restricting that it affects user experience or too lax that it affects security. The above will work for most cases in the current landscape, but you should also consider supporting 2FA authentication, or alternative authentication schemes such as WebAuthn or OAuth. It depends on your requirements and risk tolerance. It's recommended to take your time to assess what is appropriate for your app.
272+
The landscape of web security is constantly changing, so it's important that password requirements are neither so restricting that it affects user experience or too lax that it affects security. The above will work for most cases in the current landscape, but you should also consider supporting 2FA authentication, or alternative authentication schemes such as WebAuthn or OAuth.
273+
274+
It depends on your requirements and risk tolerance. It's recommended to take your time to assess what is appropriate for your app.
265275

266276
## Unit tests
267277

css/site.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
}
7171

7272
.markdown code {
73-
@apply font-mono text-sm inline bg-gray-200 rounded px-1 py-05;
73+
@apply font-mono text-sm inline bg-gray-300 rounded px-1 py-05;
7474
}
7575

7676
.markdown pre {

guides.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h1 class="leading-tight border-b text-4xl font-semibold mb-4 mt-6 pb-2 text-gra
1111
</div>
1212

1313
<ul>
14-
{% for guide in site.guides %}
14+
{% for guide in site.guides reversed %}
1515
<li class="mb-8 leading-normal border-l-4 border-blue-600 pl-4">
1616
<a href="{{ guide.url }}" class="text-gray-700 hover:text-gray-900">
1717
<h3 class="block text-xl font-bold">{{ guide.title }}</h3>

0 commit comments

Comments
 (0)