Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 8a5064d

Browse files
committed
Add security considerations for credential-treatment adapter
1 parent ef8e1c1 commit 8a5064d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

docs/book/adapter/dbtable/callback-check.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ As an example, many websites require a user to activate their account before
214214
allowing them to login for the first time. We can add that criteria as follows:
215215

216216
```php
217-
// Create a basic adapter, with only an MD5() credential treatment:
217+
// Create a basic adapter
218218
$adapter = new AuthAdapter(
219219
$db,
220220
'users',

docs/book/adapter/dbtable/credential-treatment.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,27 @@ if an identity is returned, authentication succeeds. Credential
77
treatments depends on your RDBMS, and while simple hashing function such as
88
`md5` and `sha1` are generally available, it is recommended not to use them and
99
rather use the RDBMS specific function such as
10-
[`PASSWORD(?)` for MySQL](http://dev.mysql.com/doc/refman/5.7/en/password-hashing.html).
10+
[`PASSWORD(?)` for MySQL](http://dev.mysql.com/doc/refman/5.7/en/password-hashing.html) or
11+
[`crypt()` for PostgreSQL](https://www.postgresql.org/docs/11/pgcrypto.html#id-1.11.7.34.6).
1112
More details are available in the next section.
1213

14+
## Security considerations
15+
16+
Passing passwords to database in plaintext for insert or verification is
17+
generally not recommended.
18+
Sql statements can and usually are logged by the database, passwords in them
19+
become visible to anyone with access to the logs or monitoring tools that
20+
consume those logs.
21+
22+
Safer way is to hash passwords and verify them against stored hash on the
23+
application side. This way password never needs to leave application and only
24+
hashed value exchanged with database.
25+
26+
As such, this adapter is not recommended for new applications and existing
27+
applications should consider migrating to using PHP provided password handling
28+
functions `password_hash()` and `password_verify()`. See
29+
[CallbackCheckAdapter](callback-check.md) for more info.
30+
1331
## Configuration Options
1432

1533
The available configuration options include:

0 commit comments

Comments
 (0)