feat: add http as sms provider (#8540)

# Which Problems Are Solved

Send SMS messages as a HTTP call to a relay, for own logic on handling
different SMS providers.

# How the Problems Are Solved

Add HTTP as SMS provider type and handling of webhook messages in the
notification handlers.

# Additional Changes

Clean up old Twilio events, which were supposed to handle the general
SMS providers with deactivate, activate and remove.

# Additional Context

Partially closes #8270

---------

Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Stefan Benz
2024-09-06 15:11:36 +02:00
committed by GitHub
parent d2e0ac07f1
commit 5bdf1a4547
26 changed files with 2536 additions and 593 deletions

View File

@@ -690,6 +690,40 @@ service AdminService {
};
}
rpc AddSMSProviderHTTP(AddSMSProviderHTTPRequest) returns (AddSMSProviderHTTPResponse) {
option (google.api.http) = {
post: "/sms/http";
body: "*"
};
option (zitadel.v1.auth_option) = {
permission: "iam.write";
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "SMS Provider";
summary: "Add HTTP SMS Provider";
description: "Configure a new SMS provider of the type HTTP. A provider has to be activated to be able to send notifications."
};
}
rpc UpdateSMSProviderHTTP(UpdateSMSProviderHTTPRequest) returns (UpdateSMSProviderHTTPResponse) {
option (google.api.http) = {
put: "/sms/http/{id}";
body: "*"
};
option (zitadel.v1.auth_option) = {
permission: "iam.write";
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "SMS Provider";
summary: "Update HTTP SMS Provider";
description: "Change the configuration of an SMS provider of the type HTTP. A provider has to be activated to be able to send notifications."
};
}
rpc ActivateSMSProvider(ActivateSMSProviderRequest) returns (ActivateSMSProviderResponse) {
option (google.api.http) = {
post: "/sms/{id}/_activate";
@@ -4507,6 +4541,14 @@ message AddSMSProviderTwilioRequest {
max_length: 200;
}
];
string description = 4 [
(validate.rules).string = {min_len: 0, max_len: 200},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"provider description\"";
min_length: 0;
max_length: 200;
}
];
}
message AddSMSProviderTwilioResponse {
@@ -4534,6 +4576,14 @@ message UpdateSMSProviderTwilioRequest {
max_length: 200;
}
];
string description = 4 [
(validate.rules).string = {min_len: 0, max_len: 200},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"provider description\"";
min_length: 0;
max_length: 200;
}
];
}
message UpdateSMSProviderTwilioResponse {
@@ -4549,6 +4599,56 @@ message UpdateSMSProviderTwilioTokenResponse {
zitadel.v1.ObjectDetails details = 1;
}
message AddSMSProviderHTTPRequest {
string endpoint = 1 [
(validate.rules).string = {min_len: 1, max_len: 2048},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"http://relay.example.com/provider\"";
min_length: 1;
max_length: 2048;
}
];
string description = 2 [
(validate.rules).string = {min_len: 0, max_len: 200},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"provider description\"";
min_length: 0;
max_length: 200;
}
];
}
message AddSMSProviderHTTPResponse {
zitadel.v1.ObjectDetails details = 1;
string id = 2;
}
message UpdateSMSProviderHTTPRequest {
string id = 1 [(validate.rules).string = {min_len: 1, max_len: 200}];
string endpoint = 2 [
(validate.rules).string = {min_len: 1, max_len: 2048},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"http://relay.example.com/provider\"";
min_length: 1;
max_length: 2048;
}
];
string description = 3 [
(validate.rules).string = {min_len: 0, max_len: 200},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"provider description\"";
min_length: 0;
max_length: 200;
}
];
}
message UpdateSMSProviderHTTPResponse {
zitadel.v1.ObjectDetails details = 1;
}
message ActivateSMSProviderRequest {
string id = 1 [(validate.rules).string = {min_len: 1, max_len: 200}];
}

View File

@@ -7,7 +7,7 @@ import "protoc-gen-openapiv2/options/annotations.proto";
package zitadel.settings.v1;
option go_package ="github.com/zitadel/zitadel/pkg/grpc/settings";
option go_package = "github.com/zitadel/zitadel/pkg/grpc/settings";
message SecretGenerator {
SecretGeneratorType generator_type = 1;
@@ -99,9 +99,11 @@ message SMSProvider {
zitadel.v1.ObjectDetails details = 1;
string id = 2;
SMSProviderConfigState state = 3;
string description = 6;
oneof config {
TwilioConfig twilio = 4;
HTTPConfig http = 5;
}
}
@@ -110,6 +112,10 @@ message TwilioConfig {
string sender_number = 2;
}
message HTTPConfig {
string endpoint = 1;
}
enum SMSProviderConfigState {
SMS_PROVIDER_CONFIG_STATE_UNSPECIFIED = 0;
SMS_PROVIDER_CONFIG_ACTIVE = 1;
@@ -117,8 +123,8 @@ enum SMSProviderConfigState {
}
message DebugNotificationProvider {
zitadel.v1.ObjectDetails details = 1;
bool compact = 2;
zitadel.v1.ObjectDetails details = 1;
bool compact = 2;
}
message OIDCSettings {