fix :authority header not working
This commit is contained in:
@@ -4,7 +4,7 @@ metadata:
|
|||||||
name: {{ include "webapp.name" . }}-config
|
name: {{ include "webapp.name" . }}-config
|
||||||
namespace: {{ .Release.Namespace }}
|
namespace: {{ .Release.Namespace }}
|
||||||
data:
|
data:
|
||||||
OAUTH_ALLOWED_HTTP2_AUTHORITY: webapp.arcodange.duckdns.org
|
OAUTH_ALLOWED_HOST: webapp.arcodange.duckdns.org
|
||||||
OAUTH_DEVICE_CODE_ALLOWED_IPS: 90.16.102.250,
|
OAUTH_DEVICE_CODE_ALLOWED_IPS: 90.16.102.250,
|
||||||
DATABASE_URL: postgres://pgbouncer_auth:pgbouncer_auth@pgbouncer.tools/postgres?sslmode=disable
|
DATABASE_URL: postgres://pgbouncer_auth:pgbouncer_auth@pgbouncer.tools/postgres?sslmode=disable
|
||||||
# DATABASE_URL: postgres://username:password@localhost/dbname?sslmode=disable
|
# DATABASE_URL: postgres://username:password@localhost/dbname?sslmode=disable
|
||||||
12
main.go
12
main.go
@@ -21,7 +21,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
db *sql.DB // Global database connection
|
db *sql.DB // Global database connection
|
||||||
c = cache.New(5*time.Minute, 10*time.Minute)
|
c = cache.New(5*time.Minute, 10*time.Minute)
|
||||||
oauthAllowedHttp2Authority = os.Getenv("OAUTH_ALLOWED_HTTP2_AUTHORITY") // URL authorized for device code
|
oauthAllowedHost = os.Getenv("OAUTH_ALLOWED_HOST") // URL authorized for device code
|
||||||
oauthDeviceCodeAllowedIPs = strings.Split(os.Getenv("OAUTH_DEVICE_CODE_ALLOWED_IPS"), ",") // IPS autorisées pour /retrieve
|
oauthDeviceCodeAllowedIPs = strings.Split(os.Getenv("OAUTH_DEVICE_CODE_ALLOWED_IPS"), ",") // IPS autorisées pour /retrieve
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -150,12 +150,12 @@ func oauth2_callback(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// Vérifier le référent (ou origine)
|
// Vérifier le référent (ou origine)
|
||||||
|
|
||||||
authorityHeader := r.Header.Get(":authority")
|
hostHeader := strings.Trim(r.Header.Get("X-Forwarded-Host"), "[]")
|
||||||
if oauthAllowedHttp2Authority != "" && authorityHeader != oauthAllowedHttp2Authority {
|
if oauthAllowedHost != "" && hostHeader != oauthAllowedHost {
|
||||||
fmt.Println(":authority: "+authorityHeader)
|
fmt.Fprintln(os.Stderr, "X-Forwarded-Host: "+hostHeader)
|
||||||
fmt.Println("received headers")
|
fmt.Fprintln(os.Stderr, "received headers")
|
||||||
for key, value := range r.Header {
|
for key, value := range r.Header {
|
||||||
fmt.Printf("%s='%s'\n", key, value)
|
fmt.Fprintf(os.Stderr, "%s='%s'\n", key, value)
|
||||||
}
|
}
|
||||||
http.Error(w, "Access denied: invalid referer or origin", http.StatusForbidden)
|
http.Error(w, "Access denied: invalid referer or origin", http.StatusForbidden)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user