Skip to content

Commit 431c2cf

Browse files
committed
Make the signing key optional
1 parent 46589e9 commit 431c2cf

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

api/pkg/requests/request.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package requests
22

33
import (
4+
"net/url"
45
"strconv"
56
"strings"
67
"unicode"
@@ -42,6 +43,18 @@ func (input *request) sanitizeBool(value string) string {
4243
return value
4344
}
4445

46+
func (input *request) sanitizeURL(value string) string {
47+
value = strings.TrimSpace(value)
48+
website, err := url.Parse(value)
49+
if err != nil {
50+
return value
51+
}
52+
if website.Scheme == "" {
53+
return "https://" + value
54+
}
55+
return value
56+
}
57+
4558
func (input *request) sanitizeStringPointer(value string) *string {
4659
value = strings.TrimSpace(value)
4760
if value == "" {

api/pkg/requests/webhook_store_request.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ type WebhookStore struct {
1818

1919
// Sanitize sets defaults to WebhookStore
2020
func (input *WebhookStore) Sanitize() WebhookStore {
21-
input.URL = strings.TrimSpace(input.URL)
21+
input.URL = input.sanitizeURL(input.URL)
22+
input.SigningKey = strings.TrimSpace(input.SigningKey)
2223
input.Events = input.removeStringDuplicates(input.Events)
2324

2425
var phoneNumbers []string

api/pkg/validators/webhook_handler_validator.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func (validator *WebhookHandlerValidator) ValidateStore(ctx context.Context, use
7070
Data: &request,
7171
Rules: govalidator.MapData{
7272
"signing_key": []string{
73-
"required",
7473
"min:1",
7574
"max:255",
7675
},

web/pages/settings/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
class="mt-6"
430430
persistent-placeholder
431431
persistent-hint
432-
label="Signing Key"
432+
label="Signing Key (optional)"
433433
placeholder="******************"
434434
:error="errorMessages.has('signing_key')"
435435
:error-messages="errorMessages.get('signing_key')"

0 commit comments

Comments
 (0)