Skip to content

Commit 282c6fc

Browse files
committed
refactor: Update authentication documentation for clarity and completeness
- Revise the authentication section to enhance readability and structure. - Introduce Single Sign-On (OIDC) details and emphasize security best practices. - Consolidate information on built-in username/password and session management.
1 parent db536ba commit 282c6fc

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

examples/official-site/safety.sql

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,37 @@ parameter of the [`shell`](documentation.sql?component=shell#component) componen
8686
8787
## Authentication
8888
89-
SQLPage provides an [authentication](/documentation.sql?component=authentication#component) component that allows you to
90-
restrict access to some pages of your website to authenticated users.
91-
92-
It also provides useful built-in functions such as
93-
[`sqlpage.basic_auth_username()`](/functions.sql?function=basic_auth_username#function),
94-
[`sqlpage.basic_auth_password()`](/functions.sql?function=basic_auth_password#function) and
95-
[`sqlpage.hash_password()`](/functions.sql?function=hash_password#function)
96-
to help you implement your authentication system entirely in SQL.
97-
98-
The components and functions provided by SQLPage are designed to be used by non-technical users,
99-
and to respect [security best practices](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html) by default.
100-
Passwords are [hashed with a salt](https://en.wikipedia.org/wiki/Salt_(cryptography)) using the
101-
[argon2](https://en.wikipedia.org/wiki/Argon2) algorithm.
102-
103-
However, if you implement your own session management system using the [`cookie` component](/documentation.sql?component=cookie#component),
104-
you should be careful to follow the [OWASP session management best practices](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#cookies).
105-
Implementing your own session management system is not recommended if you are a non-technical user and don''t have a good understanding of web security.
89+
Use either the built-in username/password or Single Sign-On; both follow safe defaults.
90+
91+
### Built-in username/password
92+
93+
SQLPage provides an [authentication](/documentation.sql?component=authentication#component) component to protect pages,
94+
with helpers like [`sqlpage.basic_auth_username()`](/functions.sql?function=basic_auth_username#function),
95+
[`sqlpage.basic_auth_password()`](/functions.sql?function=basic_auth_password#function), and
96+
[`sqlpage.hash_password()`](/functions.sql?function=hash_password#function).
97+
Passwords are salted and hashed with [argon2](https://en.wikipedia.org/wiki/Argon2),
98+
following [best practices](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html).
99+
100+
### Session management
101+
102+
If you implement your own sessions using the [`cookie` component](/documentation.sql?component=cookie#component),
103+
follow the [OWASP recommendations](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#cookies).
104+
Avoid rolling your own unless you fully understand web security.
105+
106+
### Single Sign-On (OIDC)
107+
108+
When OIDC is enabled, SQLPage validates a signed identity token on every request
109+
before any of your SQL runs. Without a successful login, requests are redirected
110+
to your identity provider and your application code never executes.
111+
This keeps attackers outside your SSO realm from reaching your app,
112+
even if a vulnerability exists in your own code.
113+
114+
By default, all pages are protected. You can scope access using the
115+
`oidc_protected_paths` and `oidc_public_paths` settings. See the
116+
[configuration documentation](https://github.com/sqlpage/SQLPage/blob/main/configuration.md#openid-connect-oidc-authentication).
117+
Once authenticated, access user claims with
118+
[`sqlpage.user_info()`](/functions.sql?function=user_info) or inspect the full token with
119+
[`sqlpage.user_info_token()`](/functions.sql?function=user_info_token).
106120
107121
## Protection against [CSRF attacks](https://en.wikipedia.org/wiki/Cross-site_request_forgery)
108122

0 commit comments

Comments
 (0)