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: examples/official-site/sqlpage/migrations/07_authentication.sql
+19-2Lines changed: 19 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ INSERT INTO parameter (
23
23
VALUES (
24
24
'authentication',
25
25
'link',
26
-
'The URL to redirect the user to if they are not logged in.',
26
+
'The URL to redirect the user to if they are not logged in. If this parameter is not specified, the user will stay on the current page, but be asked to log in using a popup in their browser (HTTP basic authentication).',
27
27
'TEXT',
28
28
TRUE,
29
29
TRUE
@@ -50,11 +50,28 @@ INSERT INTO example (component, description)
50
50
VALUES (
51
51
'authentication',
52
52
'
53
+
54
+
### Usage with HTTP basic authentication
55
+
56
+
The most basic usage of the authentication component is to let SQLPage handle the authentication through HTTP basic authentication.
57
+
This is the simplest way to password-protect a page, but it is not very user-friendly, because the browser will show an unstyled popup asking for the username and password.
58
+
The username and password entered by the user will be accessible in your SQL code using the
59
+
[`sqlpage.basic_auth_username()`](functions.sql?function=basic_auth_username) and
''$argon2id$v=19$m=16,t=2,p=1$TERTd0lIcUpraWFTcmRQYw$+bjtag7Xjb6p1dsuYOkngw'' AS password_hash, -- generated using https://argon2.online/
65
+
sqlpage.basic_auth_password() AS password; -- this is the password that the user entered in the browser popup
66
+
```
67
+
68
+
### Usage with a login form
69
+
53
70
The most basic usage of the authentication component is to simply check if the user has sent the correct password, and if not, redirect them to a login page:
54
71
55
72
```sql
56
73
SELECT ''authentication'' AS component,
57
-
''/login'' AS link,
74
+
''login.sql'' AS link,
58
75
''$argon2id$v=19$m=16,t=2,p=1$TERTd0lIcUpraWFTcmRQYw$+bjtag7Xjb6p1dsuYOkngw'' AS password_hash, -- generated using https://argon2.online/
59
76
:password AS password; -- this is the password that the user sent through our form
0 commit comments