File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -45,13 +45,19 @@ func router(next http.Handler) http.Handler {
4545 }
4646 case "api" :
4747 if apiTokenEnabled {
48+ // Accept Authorization header or the legacy/custom X-Authorization
4849 token := r .Header .Get ("Authorization" )
50+ if token == "" {
51+ token = r .Header .Get ("X-Authorization" )
52+ }
4953 if token != apiToken {
5054 logger .Info ("Request to %s from %s \033 [31m(invalid token)\033 [0m" , r .URL .Path , r .Header .Get ("X-Forwarded-For" ))
5155 http .Error (w , http .StatusText (403 ), http .StatusForbidden )
5256 return
5357 }
58+ // Remove any provided auth headers so we can inject the Tesla Bearer token cleanly
5459 r .Header .Del ("Authorization" )
60+ r .Header .Del ("X-Authorization" )
5561 }
5662
5763 r .Header .Add ("Authorization" , "Bearer " + tesla .AccessToken )
You can’t perform that action at this time.
0 commit comments