Skip to content

Commit

Permalink
Add origin header only for none auth method
Browse files Browse the repository at this point in the history
  • Loading branch information
mbilski committed Jul 16, 2024
1 parent d3362cb commit f6c72a2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 44 deletions.
32 changes: 16 additions & 16 deletions data/cert.pem
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
-----BEGIN CERTIFICATE-----
MIIC6jCCAdKgAwIBAgIGAYqYVSPRMA0GCSqGSIb3DQEBCwUAMDYxNDAyBgNVBAMM
K1FyWlhsQkNKYzU4VjhmSmo1UVNtY0FXaC1rWVoxZHI1RGVkYTR5VnQxM0EwHhcN
MjMwOTE1MTAxMzUxWhcNMjQwNzExMTAxMzUxWjA2MTQwMgYDVQQDDCtRclpYbEJD
SmM1OFY4ZkpqNVFTbWNBV2gta1laMWRyNURlZGE0eVZ0MTNBMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs0Ytx/nN9H4T2STYI3XIENOxzrHGWi4Tk6dz
5bhRgWRWphJp7PiMZF+bw2liHRnmjdG2Eq2d2XiAdZ93JyE8InrEJGLH/5be9goe
dPo2J9BsHH/mcVn7Tp7W7qDCd/DYLy15C8bOzpPz4KA9jr33vsFn862z3JcVBvrm
a6ixgvoRJvPqVf9ByvZ0++XYu3Lv06UxAF76oIt14H2KHVRTpjklCUEx5oh6tJ0K
slCbhvSQ3N9XiBqjMBakYP0YFcbK0uxR0ywXUC5TT1vJVjryCEXbRBcAB/WGw7KZ
WqKY/lrJ5FWsJFfu2MqqG9ClVCN8tvVGTwO88f9n7sCNOqO5NwIDAQABMA0GCSqG
SIb3DQEBCwUAA4IBAQCWOM3qh41ErNWiCseBApao9b/PDt7kog4TW2Nss6JzAd7f
PQJ6ZJ5GoY58tiToY+HbUGc0jtnARv9mR0JzGIdM2AHkwK5rlWoGCKMyJK8ErPkJ
6S8o7WJXarGVF4YrcWB5/wgOBgzLSdgXbw+hbw9pSXNZGmpYadiXqZmCkutbSuaK
j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zbZX4wTRDQrpDC/86WSFU7/7vAxv22
XVx1nvTHI4NKcbqjs+y1jShp9Cp9Yppl2qb7eaOXhAf6Y8zz9ooV3VZSzsDKfVlU
9TZ1hWO9Ai/wBHFlLTQSAn9rP0I0uyEU6DKCMVre
-----END CERTIFICATE-----
52 changes: 26 additions & 26 deletions data/key.pem
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCzRi3H+c30fhPZ
JNgjdcgQ07HOscZaLhOTp3PluFGBZFamEmns+IxkX5vDaWIdGeaN0bYSrZ3ZeIB1
n3cnITwiesQkYsf/lt72Ch50+jYn0Gwcf+ZxWftOntbuoMJ38NgvLXkLxs7Ok/Pg
oD2Ovfe+wWfzrbPclxUG+uZrqLGC+hEm8+pV/0HK9nT75di7cu/TpTEAXvqgi3Xg
fYodVFOmOSUJQTHmiHq0nQqyUJuG9JDc31eIGqMwFqRg/RgVxsrS7FHTLBdQLlNP
W8lWOvIIRdtEFwAH9YbDsplaopj+WsnkVawkV+7Yyqob0KVUI3y29UZPA7zx/2fu
wI06o7k3AgMBAAECggEAYqmo4HnWo0wP2F2ypjFYHgqjvMGSDGd3Vre9zRuXn8J8
/YD80vInMcZ8jxscaC+s9zgHIFh0mw76g8FzbhGYatFtySikMUHzCy2efXqG+3p1
RWoOhSukZyx71XCcFi5yi+RWzehoQMCkY2dM+ZYLFuySLUXXyvtLE0BaN73rk8zo
bmYZLjrHXWXOfYatCgksjzhEy2A0KDWEFzefW9wbdPuELwKzwdBbawz7R10UHpGN
bivaCU5FUq5TinRTs9bN0L9/VONPxEAKk7uwChYiDHlkqja9SZrVsTYCNUt+YafT
Tm/xXzKdc75NB1jbWtAz00BDuRZZXSifXOvV1yNIAQKBgQDbIuKlcEVjFwwTyple
y5+KfZqpT83qkkSrZGelaxGuH2PHQLiZ13LbWclD9bwzbw80SM32CdgLcDOUe546
2vLp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dbG0VI
OyyfcHb80mXi9vDeCbKv0B/jEh0zqb/gjygyZ3K2LR0V2r0Pn9kb2dW12RsKH4qF
Dj72apukT7LanPVTcrgzn5dF6UdeqD8Yxvnu4CllAoGBANwFKGpjXk9DNso06O/n
s5AQ4NFl3oQ0czG9rUHkEC6LhGrMj9RrJ9z+N7yNYXYyhN14GFIElwUSVCiYYm8+
MPU0bh0cSa9nAVc7cP90M3YsZDDuE5DYvgtccKuuCaXgUgbLE/9aCnV+mxF20rxf
mf4/qYy9yV4eqtMdy/qhqdx1
-----END PRIVATE KEY-----
8 changes: 7 additions & 1 deletion internal/oauth2/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package oauth2
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
)
Expand Down Expand Up @@ -46,15 +47,20 @@ func (e *Error) Error() string {
func ParseError(resp *http.Response) error {
var (
payload Error
body []byte
err error
)

payload.StatusCode = resp.StatusCode
payload.TraceID = resp.Header.Get("X-Trace-ID")

if err = json.NewDecoder(resp.Body).Decode(&payload); err != nil {
if body, err = io.ReadAll(resp.Body); err != nil {
return err
}

if err = json.Unmarshal(body, &payload); err != nil {
return fmt.Errorf("failed to parse error response (%s): %w", string(body), err)
}

return &payload
}
2 changes: 1 addition & 1 deletion internal/oauth2/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func RequestToken(
req.SetBasicAuth(cconfig.ClientID, cconfig.ClientSecret)
}

if cconfig.RedirectURL != "" {
if cconfig.RedirectURL != "" && cconfig.AuthMethod == NoneAuthMethod {
if redirectURL, err = url.Parse(cconfig.RedirectURL); err != nil {
return request, response, err
}
Expand Down

0 comments on commit f6c72a2

Please sign in to comment.