Skip to content

Commit 4cabad8

Browse files
committed
extract client types into a shared module
1 parent b5deeca commit 4cabad8

File tree

3 files changed

+182
-311
lines changed

3 files changed

+182
-311
lines changed

common/client_types.proto

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
syntax = "proto3";
2+
package defguard.client_types;
3+
4+
/*
5+
* Shared message and enum definitions used by Defguard desktop clients (desktop app and CLI).
6+
*
7+
* This module exists to decouple the desktop client from any specific proxy protocol version.
8+
* The client only needs a stable, version-independent set of types for:
9+
* - Enrollment and device configuration (DeviceConfigResponse and its dependencies)
10+
* - Periodic configuration polling (InstanceInfoRequest/Response)
11+
* - Platform info reporting (ClientPlatformInfo)
12+
*
13+
* Both v1 and v2 proxy protocol definitions import this file and reference these types in
14+
* their CoreRequest/CoreResponse envelopes, ensuring that a single client build can
15+
* communicate with proxies running either protocol version without any code changes.
16+
*
17+
* Types that are proxy-version-specific (e.g. MFA flows, gRPC envelope messages,
18+
* setup/certificate provisioning) are intentionally NOT included here.
19+
*/
20+
21+
// Enrollment & Desktop Client activation
22+
23+
message EnrollmentStartRequest {
24+
string token = 1;
25+
}
26+
27+
message AdminInfo {
28+
string name = 1;
29+
optional string phone_number = 2;
30+
string email = 3;
31+
}
32+
33+
message InitialUserInfo {
34+
string first_name = 1;
35+
string last_name = 2;
36+
string login = 3;
37+
string email = 4;
38+
optional string phone_number = 5;
39+
bool is_active = 6;
40+
repeated string device_names = 7;
41+
bool enrolled = 8;
42+
bool is_admin = 9;
43+
}
44+
45+
message EnrollmentSettings {
46+
// Vpn step is skippable
47+
bool vpn_setup_optional = 1;
48+
// Manual WireGuard setup is disabled
49+
bool only_client_activation = 2;
50+
// Only admins can add devices so vpn step is skipped
51+
bool admin_device_management = 3;
52+
// Enable Email method for MFA setup
53+
bool smtp_configured = 4;
54+
// MFA setup is not skippable
55+
bool mfa_required = 5;
56+
}
57+
58+
message EnrollmentStartResponse {
59+
AdminInfo admin = 1;
60+
InitialUserInfo user = 2;
61+
int64 deadline_timestamp = 3;
62+
string final_page_content = 5;
63+
InstanceInfo instance = 7;
64+
EnrollmentSettings settings = 8;
65+
}
66+
67+
message NewDevice {
68+
string name = 1;
69+
string pubkey = 2;
70+
optional string token = 3;
71+
}
72+
73+
message Device {
74+
int64 id = 1;
75+
string name = 2;
76+
string pubkey = 3;
77+
int64 user_id = 4;
78+
int64 created_at = 5;
79+
}
80+
81+
// Device configuration
82+
83+
enum LocationMfaMode {
84+
LOCATION_MFA_MODE_UNSPECIFIED = 0;
85+
LOCATION_MFA_MODE_DISABLED = 1;
86+
LOCATION_MFA_MODE_INTERNAL = 2;
87+
LOCATION_MFA_MODE_EXTERNAL = 3;
88+
}
89+
90+
enum ServiceLocationMode {
91+
SERVICE_LOCATION_MODE_UNSPECIFIED = 0;
92+
SERVICE_LOCATION_MODE_DISABLED = 1;
93+
SERVICE_LOCATION_MODE_PRELOGON = 2;
94+
SERVICE_LOCATION_MODE_ALWAYSON = 3;
95+
}
96+
97+
message DeviceConfig {
98+
int64 network_id = 1;
99+
string network_name = 2;
100+
string config = 3;
101+
string endpoint = 4;
102+
string assigned_ip = 5;
103+
// network pubkey
104+
string pubkey = 6;
105+
string allowed_ips = 7;
106+
optional string dns = 8;
107+
// DEPRECATED(1.5): superseded by location_mfa_mode
108+
bool mfa_enabled = 9 [deprecated = true];
109+
int32 keepalive_interval = 10;
110+
optional LocationMfaMode location_mfa_mode = 11;
111+
optional ServiceLocationMode service_location_mode = 12;
112+
}
113+
114+
enum ClientTrafficPolicy {
115+
NONE = 0;
116+
DISABLE_ALL_TRAFFIC = 1;
117+
FORCE_ALL_TRAFFIC = 2;
118+
}
119+
120+
message InstanceInfo {
121+
string id = 1;
122+
string name = 2;
123+
string url = 3;
124+
string proxy_url = 4;
125+
string username = 5;
126+
bool enterprise_enabled = 6;
127+
// DEPRECATED(1.6): superseded by client_traffic_policy
128+
bool disable_all_traffic = 7 [deprecated = true];
129+
optional string openid_display_name = 8;
130+
optional ClientTrafficPolicy client_traffic_policy = 9;
131+
}
132+
133+
message DeviceConfigResponse {
134+
Device device = 1;
135+
repeated DeviceConfig configs = 2;
136+
InstanceInfo instance = 3;
137+
// polling token used for further client-core communication
138+
optional string token = 4;
139+
}
140+
141+
// Configuration polling
142+
143+
message InstanceInfoRequest {
144+
string token = 1;
145+
}
146+
147+
message InstanceInfoResponse {
148+
DeviceConfigResponse device_config = 1;
149+
}
150+
151+
// Platform info sent as a header with every request to the proxy
152+
153+
message ClientPlatformInfo {
154+
string os_family = 1;
155+
string os_type = 2;
156+
string version = 3;
157+
optional string edition = 4;
158+
optional string codename = 5;
159+
optional string bitness = 6;
160+
optional string architecture = 7;
161+
}

v1/core/proxy.proto

Lines changed: 9 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -2,142 +2,7 @@ syntax = "proto3";
22
package defguard.proxy.v1;
33

44
import "google/protobuf/empty.proto";
5-
6-
// Enrollment & Desktop Client activation
7-
message EnrollmentStartRequest {
8-
string token = 1;
9-
}
10-
11-
message AdminInfo {
12-
string name = 1;
13-
optional string phone_number = 2;
14-
string email = 3;
15-
}
16-
17-
message InitialUserInfo {
18-
string first_name = 1;
19-
string last_name = 2;
20-
string login = 3;
21-
string email = 4;
22-
optional string phone_number = 5;
23-
bool is_active = 6;
24-
repeated string device_names = 7;
25-
bool enrolled = 8;
26-
bool is_admin = 9;
27-
}
28-
29-
message EnrollmentSettings {
30-
// Vpn step is skippable
31-
bool vpn_setup_optional = 1;
32-
// Manual WireGuard setup is disabled
33-
bool only_client_activation = 2;
34-
// Only admins can add devices so vpn step is skipped
35-
bool admin_device_management = 3;
36-
// Enable Email method for MFA setup
37-
bool smtp_configured = 4;
38-
// MFA setup is not skippable
39-
bool mfa_required = 5;
40-
}
41-
42-
message EnrollmentStartResponse {
43-
AdminInfo admin = 1;
44-
InitialUserInfo user = 2;
45-
int64 deadline_timestamp = 3;
46-
string final_page_content = 5;
47-
InstanceInfo instance = 7;
48-
EnrollmentSettings settings = 8;
49-
}
50-
51-
message ActivateUserRequest {
52-
optional string phone_number = 1;
53-
string password = 2;
54-
optional string token = 3;
55-
}
56-
57-
message NewDevice {
58-
string name = 1;
59-
string pubkey = 2;
60-
optional string token = 3;
61-
}
62-
63-
message Device {
64-
int64 id = 1;
65-
string name = 2;
66-
string pubkey = 3;
67-
int64 user_id = 4;
68-
int64 created_at = 5;
69-
}
70-
71-
enum LocationMfaMode {
72-
LOCATION_MFA_MODE_UNSPECIFIED = 0;
73-
LOCATION_MFA_MODE_DISABLED = 1;
74-
LOCATION_MFA_MODE_INTERNAL = 2;
75-
LOCATION_MFA_MODE_EXTERNAL = 3;
76-
}
77-
78-
enum ServiceLocationMode {
79-
SERVICE_LOCATION_MODE_UNSPECIFIED = 0;
80-
SERVICE_LOCATION_MODE_DISABLED = 1;
81-
SERVICE_LOCATION_MODE_PRELOGON = 2;
82-
SERVICE_LOCATION_MODE_ALWAYSON = 3;
83-
}
84-
85-
message DeviceConfig {
86-
int64 network_id = 1;
87-
string network_name = 2;
88-
string config = 3;
89-
string endpoint = 4;
90-
string assigned_ip = 5;
91-
// network pubkey
92-
string pubkey = 6;
93-
string allowed_ips = 7;
94-
optional string dns = 8;
95-
// DEPRECATED(1.5): superseeded by location_mfa_mode
96-
bool mfa_enabled = 9 [deprecated = true];
97-
int32 keepalive_interval = 10;
98-
optional LocationMfaMode location_mfa_mode = 11;
99-
optional ServiceLocationMode service_location_mode = 12;
100-
}
101-
102-
enum ClientTrafficPolicy {
103-
NONE = 0;
104-
DISABLE_ALL_TRAFFIC = 1;
105-
FORCE_ALL_TRAFFIC = 2;
106-
}
107-
108-
message InstanceInfo {
109-
string id = 1;
110-
string name = 2;
111-
string url = 3;
112-
string proxy_url = 4;
113-
string username = 5;
114-
bool enterprise_enabled = 6;
115-
// DEPRECATED(1.6): superseeded by client_traffic_policy
116-
bool disable_all_traffic = 7 [deprecated = true];
117-
optional string openid_display_name = 8;
118-
optional ClientTrafficPolicy client_traffic_policy = 9;
119-
}
120-
121-
message DeviceConfigResponse {
122-
Device device = 1;
123-
repeated DeviceConfig configs = 2;
124-
InstanceInfo instance = 3;
125-
// polling token used for further client-core communication
126-
optional string token = 4;
127-
}
128-
129-
message InstanceInfoRequest {
130-
string token = 1;
131-
}
132-
133-
message InstanceInfoResponse {
134-
DeviceConfigResponse device_config = 1;
135-
}
136-
137-
message ExistingDevice {
138-
string pubkey = 1;
139-
optional string token = 2;
140-
}
5+
import "common/client_types.proto";
1416

1427
// Password Reset
1438
message PasswordResetStartRequest {
@@ -227,16 +92,6 @@ message ClientMfaOidcAuthenticateRequest {
22792
string nonce = 4;
22893
}
22994

230-
message ClientPlatformInfo {
231-
string os_family = 1;
232-
string os_type = 2;
233-
string version = 3;
234-
optional string edition = 4;
235-
optional string codename = 5;
236-
optional string bitness = 6;
237-
optional string architecture = 7;
238-
}
239-
24095
// Common client info
24196
message DeviceInfo {
24297
string ip_address = 1;
@@ -290,13 +145,13 @@ message CoreResponse {
290145
uint64 id = 1;
291146
oneof payload {
292147
google.protobuf.Empty empty = 2;
293-
EnrollmentStartResponse enrollment_start = 3;
294-
DeviceConfigResponse device_config = 4;
148+
defguard.client_types.EnrollmentStartResponse enrollment_start = 3;
149+
defguard.client_types.DeviceConfigResponse device_config = 4;
295150
PasswordResetStartResponse password_reset_start = 5;
296151
ClientMfaStartResponse client_mfa_start = 6;
297152
ClientMfaFinishResponse client_mfa_finish = 7;
298153
CoreError core_error = 8;
299-
InstanceInfoResponse instance_info = 9;
154+
defguard.client_types.InstanceInfoResponse instance_info = 9;
300155
AuthInfoResponse auth_info = 13;
301156
AuthCallbackResponse auth_callback = 14;
302157
ClientMfaTokenValidationResponse client_mfa_token_validation = 15;
@@ -312,16 +167,16 @@ message CoreRequest {
312167
uint64 id = 1;
313168
DeviceInfo device_info = 2;
314169
oneof payload {
315-
EnrollmentStartRequest enrollment_start = 3;
316-
ActivateUserRequest activate_user = 4;
317-
NewDevice new_device = 5;
318-
ExistingDevice existing_device = 6;
170+
defguard.client_types.EnrollmentStartRequest enrollment_start = 3;
171+
defguard.client_types.ActivateUserRequest activate_user = 4;
172+
defguard.client_types.NewDevice new_device = 5;
173+
defguard.client_types.ExistingDevice existing_device = 6;
319174
PasswordResetInitializeRequest password_reset_init = 7;
320175
PasswordResetStartRequest password_reset_start = 8;
321176
PasswordResetRequest password_reset = 9;
322177
ClientMfaStartRequest client_mfa_start = 10;
323178
ClientMfaFinishRequest client_mfa_finish = 11;
324-
InstanceInfoRequest instance_info = 12;
179+
defguard.client_types.InstanceInfoRequest instance_info = 12;
325180
AuthInfoRequest auth_info = 13;
326181
AuthCallbackRequest auth_callback = 14;
327182
ClientMfaOidcAuthenticateRequest client_mfa_oidc_authenticate = 15;

0 commit comments

Comments
 (0)