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: packages/doc/docs/data-privacy/authn.mdx
+160-4
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,8 @@
1
1
# Authentication
2
2
To ensure that only authorized users access your VulcanSQL application, it's essential to identify who sends the request. This process, called authentication, typically involves validating credentials such as tokens, cookies, or other forms of identification.
3
3
4
-
In VulcanSQL, `Authenticators` handle this process, either by validating the credentials themselves or by querying third-party authentication providers. Once the authentication process is complete, additional user attributes are also added to the request for further processing. These attributes can include user names, departments, groups, statuses, and more, depending on the specific authenticator used.
4
+
In VulcanSQL, `Authenticators` handle this process, either by validating the credentials themselves or by querying third-party authentication providers. Once the authentication process is complete, additional user attributes are also added to the request for further processing.
5
+
These attributes can include user names, departments, groups, statuses, and more, and they are used for [authorization](./authz).
5
6
6
7
## Authenticators
7
8
To enable authenticators in VulcanSQL, set `auth.enabled` to true in your `vulcan.yaml` configuration file:
@@ -15,8 +16,163 @@ VulcanSQL offers a range of built-in authenticators, each with its unique method
15
16
16
17
Here is a list of built-in authenticators available in VulcanSQL:
17
18
18
-
* **HTTP Basic**: Authenticate users via HTTP basic authentication. This method requires users to provide a username and password, which are transmitted as headers in each request.
19
-
* **Password File**: Validate users' credentials using a password file. This method involves comparing the provided username and password against a pre-defined list of authorized users stored in a file.
20
-
* **Simple Token**: Authenticate users with a static token. This method involves checking the provided token against a pre-configured token value.
19
+
* [**HTTP Basic**](#http-basic): Authenticate users via HTTP basic authentication. This method requires users to provide a username and password, which are transmitted as headers in each request.
20
+
* [**Password File**](#password-file): Validate users' credentials using a password file. This method involves comparing the provided username and password against a pre-defined list of authorized users stored in a file.
21
+
* [**Simple Token**](#simple-token): Authenticate users with a static token. This method involves checking the provided token against a pre-configured token value.
21
22
22
23
By implementing the appropriate authenticators for your VulcanSQL application, you can ensure that only authorized users access your system and protect sensitive data from unauthorized access.
24
+
25
+
## HTTP Basic
26
+
27
+
With HTTP basic authentication, VulcanSQL authenticates users via [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
28
+
29
+
### Configuration
30
+
31
+
Please fill out the values in your `vulcan.yaml`.
32
+
33
+
```yaml
34
+
auth:
35
+
enabled: true
36
+
options:
37
+
basic:
38
+
# Read users and passwords from a text file.
39
+
htpasswd-file:
40
+
path: passwd.txt # Path to the password file.
41
+
users: # (Optional) Add attributes for users
42
+
- name: eason
43
+
attr:
44
+
department: engineer
45
+
```
46
+
47
+
### Password file
48
+
49
+
You need to create a password file in format `<username>:<md5-password>`, one user per line. For example:
50
+
51
+
:::info
52
+
You can use `echo -n '<password>' | md5sum` to generate an md5 string
53
+
:::
54
+
55
+
```txt
56
+
eason:202cb962ac59075b964b07152d234b70
57
+
andy:202cb962ac59075b964b07152d234b70
58
+
```
59
+
60
+
If you want to add some attributes for these users, you can set them in `vulcan.yaml`. For example,
61
+
62
+
```yaml
63
+
auth:
64
+
enabled: true
65
+
options:
66
+
basic:
67
+
htpasswd-file:
68
+
path: passwd.txt
69
+
users:
70
+
- name: eason
71
+
attr:
72
+
department: engineer
73
+
```
74
+
75
+
This config adds `department=engineer` for user "eason", but adds no attribute to user "andy".
76
+
77
+
### Providing credentials to HTTP Header
78
+
79
+
You need to add a header `Authorization: basic base64(<username>:<password>)` when sending requests, for example, sending requests with username "ivan" and password "123".
This file provides two users "eason and "andy with password "123”.
113
+
114
+
:::info
115
+
To generate bcrypt-password, you can use htpasswd command, for example, to generate user "andy and password "123”:
116
+
117
+
```bash
118
+
htpasswd -bnBC 10 "andy" 123
119
+
```
120
+
:::
121
+
122
+
If you want to add some attributes for these users, you can set them in `vulcan.yaml`. For example,
123
+
124
+
```yaml
125
+
auth:
126
+
enabled: true
127
+
options:
128
+
password-file:
129
+
path: passwd.txt
130
+
users:
131
+
- name: andy
132
+
attr:
133
+
department: engineer
134
+
```
135
+
136
+
This config adds `department=engineer` for user "andy, but adds no attribute to user "eason".
137
+
138
+
### Providing credentials to HTTP Header
139
+
140
+
You need to add a header `Authorization: password-file base64(<username>:<password>)` when sending requests. For example, sending requests with username "andy” and password "123”.
Copy file name to clipboardexpand all lines: packages/doc/docs/data-privacy/authz.mdx
+16
Original file line number
Diff line number
Diff line change
@@ -43,3 +43,19 @@ The configurations for each data source are defined in the `profiles.yaml` file.
43
43
group: 'admin*'
44
44
enabled: 'true'
45
45
```
46
+
47
+
## Set the allowed profiles to each template
48
+
49
+
For every SQL template, we need to tell VulcanSQL what profiles they could use by adding `profiles` property on the schema.
50
+
From top to bottom, users use the first qualified profile. If users can't use any of them, 403 error will be thrown.
51
+
52
+
```yaml
53
+
urlPath: /customer
54
+
profiles:
55
+
- pg-admin
56
+
- pg-non-admin
57
+
```
58
+
59
+
:::info
60
+
For detailed descriptions on `profile` and `profiles` fields, please refer to the [documentation here](../references/api-schema#profiles--profile-field).
0 commit comments