Skip to content

Commit 39947f1

Browse files
authored
Merge pull request #155 from authorizerdev/fix/gateway-based-setup
fix: setting the cookie for proxy setup
2 parents fe73c2f + 4fa9f79 commit 39947f1

File tree

6 files changed

+36
-17
lines changed

6 files changed

+36
-17
lines changed

app/package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "Lakhan Samani",
1212
"license": "ISC",
1313
"dependencies": {
14-
"@authorizerdev/authorizer-react": "latest",
14+
"@authorizerdev/authorizer-react": "^0.17.0",
1515
"@types/react": "^17.0.15",
1616
"@types/react-dom": "^17.0.9",
1717
"esbuild": "^0.12.17",

dashboard/src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const queryClient = createClient({
1010
fetchOptions: () => {
1111
return {
1212
credentials: 'include',
13+
headers: {
14+
'x-authorizer-url': window.location.origin,
15+
},
1316
};
1417
},
1518
requestPolicy: 'network-only',

server/constants/env.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const (
1616
// EnvKeyEnvPath key for cli arg variable ENV_PATH
1717
EnvKeyEnvPath = "ENV_PATH"
1818
// EnvKeyAuthorizerURL key for env variable AUTHORIZER_URL
19-
// TODO: remove support AUTHORIZER_URL env
2019
EnvKeyAuthorizerURL = "AUTHORIZER_URL"
2120
// EnvKeyPort key for env variable PORT
2221
EnvKeyPort = "PORT"

server/env/env.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ func InitAllEnv() error {
113113
envData.StringEnv[constants.EnvKeyAppURL] = os.Getenv(constants.EnvKeyAppURL)
114114
}
115115

116+
if envData.StringEnv[constants.EnvKeyAuthorizerURL] == "" {
117+
envData.StringEnv[constants.EnvKeyAuthorizerURL] = os.Getenv(constants.EnvKeyAuthorizerURL)
118+
}
119+
116120
if envData.StringEnv[constants.EnvKeyPort] == "" {
117121
envData.StringEnv[constants.EnvKeyPort] = os.Getenv(constants.EnvKeyPort)
118122
if envData.StringEnv[constants.EnvKeyPort] == "" {

server/utils/urls.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,20 @@ import (
1010
)
1111

1212
// GetHost returns hostname from request context
13+
// if X-Authorizer-URL header is set it is given highest priority
14+
// if EnvKeyAuthorizerURL is set it is given second highest priority.
15+
// if above 2 are not set the requesting host name is used
1316
func GetHost(c *gin.Context) string {
17+
authorizerURL := c.Request.Header.Get("X-Authorizer-URL")
18+
if authorizerURL != "" {
19+
return authorizerURL
20+
}
21+
22+
authorizerURL = envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAuthorizerURL)
23+
if authorizerURL != "" {
24+
return authorizerURL
25+
}
26+
1427
scheme := c.Request.Header.Get("X-Forwarded-Proto")
1528
if scheme != "https" {
1629
scheme = "http"

0 commit comments

Comments
 (0)