Skip to content

Commit 1f7a33a

Browse files
Configuration: document the 'credentials' option (#4035)
1 parent 47b9380 commit 1f7a33a

File tree

20 files changed

+615
-119
lines changed

20 files changed

+615
-119
lines changed

doc/book/admin/access_control.rst

Lines changed: 61 additions & 61 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Credentials
2+
3+
A sample application demonstrating how configure user credentials in a YAML configuration.
4+
5+
## Running
6+
7+
Start the application by executing the following command in the [config](../../../config) directory:
8+
9+
```console
10+
$ tt start credentials
11+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
credentials:
2+
users:
3+
dbadmin:
4+
password: 'T0p_Secret_P@$$w0rd'
5+
roles: [ super ]
6+
sampleuser:
7+
password: '123456'
8+
roles: [ writers_space_reader ]
9+
privileges:
10+
- permissions: [ read, write ]
11+
spaces: [ books ]
12+
roles:
13+
writers_space_reader:
14+
privileges:
15+
- permissions: [ read ]
16+
spaces: [ writers ]
17+
18+
groups:
19+
group001:
20+
replicasets:
21+
replicaset001:
22+
instances:
23+
instance001:
24+
iproto:
25+
listen:
26+
- uri: '127.0.0.1:3301'
27+
28+
# Load sample data
29+
app:
30+
file: 'myapp.lua'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
function create_spaces()
2+
box.schema.space.create('writers')
3+
box.space.writers:format({
4+
{ name = 'id', type = 'unsigned' },
5+
{ name = 'name', type = 'string' }
6+
})
7+
box.space.writers:create_index('primary', { parts = { 'id' } })
8+
9+
box.schema.space.create('books')
10+
box.space.books:format({
11+
{ name = 'id', type = 'unsigned' },
12+
{ name = 'title', type = 'string' },
13+
{ name = 'author_id', foreign_key = { space = 'writers', field = 'id' } },
14+
})
15+
box.space.books:create_index('primary', { parts = { 'id' } })
16+
end
17+
18+
function load_data()
19+
box.space.writers:insert { 1, 'Leo Tolstoy' }
20+
box.space.writers:insert { 2, 'Fyodor Dostoevsky' }
21+
box.space.writers:insert { 3, 'Alexander Pushkin' }
22+
23+
box.space.books:insert { 1, 'War and Peace', 1 }
24+
box.space.books:insert { 2, 'Anna Karenina', 1 }
25+
box.space.books:insert { 3, 'Resurrection', 1 }
26+
box.space.books:insert { 4, 'Crime and Punishment', 2 }
27+
box.space.books:insert { 5, 'The Idiot', 2 }
28+
box.space.books:insert { 6, 'The Brothers Karamazov', 2 }
29+
box.space.books:insert { 7, 'Eugene Onegin', 3 }
30+
box.space.books:insert { 8, 'The Captain\'s Daughter', 3 }
31+
box.space.books:insert { 9, 'Boris Godunov', 3 }
32+
box.space.books:insert { 10, 'Ruslan and Ludmila', 3 }
33+
end
34+
35+
create_spaces()
36+
load_data()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Credentials: environment variables
2+
3+
A sample application demonstrating how set passwords in a YAML configuration using environment variables.
4+
5+
## Running
6+
7+
Before starting instances, set the `DBADMIN_PASSWORD` and `SAMPLEUSER_PASSWORD` environment variables, for example:
8+
9+
```console
10+
$ export DBADMIN_PASSWORD='T0p_Secret_P@$$w0rd'
11+
$ export SAMPLEUSER_PASSWORD='123456'
12+
```
13+
14+
Then, start the application by executing the following command in the [config](../../../config) directory:
15+
16+
```console
17+
$ tt start credentials_context_env
18+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
config:
2+
context:
3+
dbadmin_password:
4+
from: env
5+
env: DBADMIN_PASSWORD
6+
sampleuser_password:
7+
from: env
8+
env: SAMPLEUSER_PASSWORD
9+
10+
credentials:
11+
users:
12+
dbadmin:
13+
password: '{{ context.dbadmin_password }}'
14+
sampleuser:
15+
password: '{{ context.sampleuser_password }}'
16+
17+
groups:
18+
group001:
19+
replicasets:
20+
replicaset001:
21+
instances:
22+
instance001:
23+
iproto:
24+
listen:
25+
- uri: '127.0.0.1:3301'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Credentials: files
2+
3+
A sample application demonstrating how load passwords to a YAML configuration from files.
4+
5+
## Running
6+
7+
Start the application by executing the following command in the [config](../../../config) directory:
8+
9+
```console
10+
$ tt start credentials_context_file
11+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
config:
2+
context:
3+
dbadmin_password:
4+
from: file
5+
file: secrets/dbadmin_password.txt
6+
rstrip: true
7+
sampleuser_password:
8+
from: file
9+
file: secrets/sampleuser_password.txt
10+
rstrip: true
11+
12+
credentials:
13+
users:
14+
dbadmin:
15+
password: '{{ context.dbadmin_password }}'
16+
sampleuser:
17+
password: '{{ context.sampleuser_password }}'
18+
19+
groups:
20+
group001:
21+
replicasets:
22+
replicaset001:
23+
instances:
24+
instance001:
25+
iproto:
26+
listen:
27+
- uri: '127.0.0.1:3301'

0 commit comments

Comments
 (0)