Skip to content

Commit 6b10923

Browse files
wojcik91Maciej Wójcik
and
Maciej Wójcik
authored
feat: add enrollment service (#276)
* make stats filtering consistent * add enrollment service to grpc router * add enrollment table * add enrollment struct * implement adding enrollment session * validate enrollment session * implement remaining endpoints * make password optional * make password optional when creating user * add manual enrollment trigger endpoint skeleton * trigger enrollment when creating a user without password * add toggle for sending notification * handle LDAP sync during enrollment * add enrollment timeout settings to main config * return token when starting enrollment * implement manual enrollment start * add enrollment service url to config * update protos * send enrollment start email * send welcome email * add enrollment settings columns * update settings struct * add initial enrollment settings page * pass configured message in email * convert welcome message to html * allow creating user without password * add enrollment test * initial polish translation --------- Co-authored-by: Maciej Wójcik <[email protected]>
1 parent 878f75e commit 6b10923

40 files changed

+2122
-428
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: end-of-file-fixer
77
- id: check-added-large-files
88
- repo: https://github.com/doublify/pre-commit-rust
9-
rev: master
9+
rev: v1.0
1010
hooks:
1111
- id: fmt
1212
- id: clippy

Cargo.lock

+37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ lettre = { version = "0.10.4", features = ["tokio1", "tokio1-native-tls"] }
7272
serde_json = "1.0.104"
7373
humantime = "2.1"
7474
tera = "1.19"
75+
pulldown-cmark = "0.9"
7576

7677
[dev-dependencies]
7778
matches = "0.1"

build.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
88
"proto/core/vpn.proto",
99
"proto/worker/worker.proto",
1010
"proto/wireguard/gateway.proto",
11+
"proto/enrollment/enrollment.proto",
12+
],
13+
&[
14+
"proto/core",
15+
"proto/worker",
16+
"proto/wireguard",
17+
"proto/enrollment",
1118
],
12-
&["proto/core", "proto/worker", "proto/wireguard"],
1319
)?;
1420
println!("cargo:rerun-if-changed=proto");
1521
println!("cargo:rerun-if-changed=migrations");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
DROP TABLE enrollment;
2+
3+
ALTER TABLE "user" ALTER COLUMN password_hash SET NOT NULL;
4+
5+
ALTER TABLE settings DROP COLUMN enrollment_vpn_step_optional;
6+
ALTER TABLE settings DROP COLUMN enrollment_welcome_message;
7+
ALTER TABLE settings DROP COLUMN enrollment_welcome_email;
8+
ALTER TABLE settings DROP COLUMN enrollment_use_welcome_message_as_email;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CREATE TABLE enrollment (
2+
id text PRIMARY KEY NOT NULL,
3+
user_id bigint NOT NULL,
4+
admin_id bigint NOT NULL,
5+
created_at timestamp without time zone NOT NULL,
6+
expires_at timestamp without time zone NOT NULL,
7+
used_at timestamp without time zone,
8+
FOREIGN KEY(user_id) REFERENCES "user"(id) ON DELETE CASCADE,
9+
FOREIGN KEY(admin_id) REFERENCES "user"(id)
10+
);
11+
12+
ALTER TABLE "user" ALTER COLUMN password_hash DROP NOT NULL;
13+
14+
ALTER TABLE settings ADD COLUMN enrollment_vpn_step_optional boolean NOT NULL default true;
15+
ALTER TABLE settings ADD COLUMN enrollment_welcome_message text NULL;
16+
ALTER TABLE settings ADD COLUMN enrollment_welcome_email text NULL;
17+
ALTER TABLE settings ADD COLUMN enrollment_use_welcome_message_as_email boolean NOT NULL default true;

proto

0 commit comments

Comments
 (0)