diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-12-07 15:12:58 +0100 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-12-08 19:25:42 +0100 |
| commit | 02fb645b277e714e90ec328825110ddd0aba6398 (patch) | |
| tree | d3231fbf4a27a4a0c85eba40dd625b00a939daa9 | |
| parent | 790afc80bff8d76555448773e021386d8e6d1586 (diff) | |
API: Only check if scheme is https
| -rw-r--r-- | internal/server/api.go | 9 | ||||
| -rw-r--r-- | internal/server/api_test.go | 26 |
2 files changed, 4 insertions, 31 deletions
diff --git a/internal/server/api.go b/internal/server/api.go index 546c02a..99d6f72 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -27,18 +27,15 @@ func validateEndpoints(endpoints Endpoints) error { if err != nil { return errors.WrapPrefix(err, "failed to parse API token endpoint", 0) } + if pAPI.Scheme != "https" { + return errors.Errorf("API scheme: '%v', is not equal to 'https'", pAPI.Scheme) + } if pAPI.Scheme != pAuth.Scheme { return errors.Errorf("API scheme: '%v', is not equal to authorization scheme: '%v'", pAPI.Scheme, pAuth.Scheme) } if pAPI.Scheme != pToken.Scheme { return errors.Errorf("API scheme: '%v', is not equal to token scheme: '%v'", pAPI.Scheme, pToken.Scheme) } - if pAPI.Host != pAuth.Host { - return errors.Errorf("API host: '%v', is not equal to authorization host: '%v'", pAPI.Host, pAuth.Host) - } - if pAPI.Host != pToken.Host { - return errors.Errorf("API host: '%v', is not equal to token host: '%v'", pAPI.Host, pToken.Host) - } return nil } diff --git a/internal/server/api_test.go b/internal/server/api_test.go index b1e3550..07510b0 100644 --- a/internal/server/api_test.go +++ b/internal/server/api_test.go @@ -55,7 +55,7 @@ func Test_APIGetEndpoints(t *testing.T) { Authorization: "https://example.com/2", Token: "https://example.com/3", }, - err: errors.New("API scheme: 'http', is not equal to authorization scheme: 'https'"), + err: errors.New("API scheme: 'http', is not equal to 'https'"), }, { epl: EndpointList{ @@ -65,30 +65,6 @@ func Test_APIGetEndpoints(t *testing.T) { }, err: errors.New("API scheme: 'https', is not equal to token scheme: 'ftp'"), }, - { - epl: EndpointList{ - API: "https://malicious.com/1", - Authorization: "https://example.com/2", - Token: "https://example.com/3", - }, - err: errors.New("API host: 'malicious.com', is not equal to authorization host: 'example.com'"), - }, - { - epl: EndpointList{ - API: "https://example.com/1", - Authorization: "https://example.com/2", - Token: "https://malicious.com/3", - }, - err: errors.New("API host: 'example.com', is not equal to token host: 'malicious.com'"), - }, - { - epl: EndpointList{ - API: "https://example.com/1", - Authorization: "https://malicious.com/2", - Token: "https://example.com/3", - }, - err: errors.New("API host: 'example.com', is not equal to authorization host: 'malicious.com'"), - }, } for _, tc := range testCases { |
