Skip to content

Commit 1d7fc9a

Browse files
committed
chore: update todo
1 parent 6b4eb97 commit 1d7fc9a

3 files changed

Lines changed: 10 additions & 20 deletions

File tree

internal/cookie/cookie.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ func SetSession(gc *gin.Context, sessionID string, appCookieSecure bool) {
2626
// For more information check:
2727
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
2828
// https://github.com/gin-gonic/gin/blob/master/context.go#L86
29-
// TODO add ability to sameSite = none / strict from dashboard
29+
// TODO add ability to configure sameSite (none / lax / strict) via config
3030
if !appCookieSecure {
3131
gc.SetSameSite(http.SameSiteLaxMode)
3232
} else {
3333
gc.SetSameSite(http.SameSiteNoneMode)
3434
}
35-
// TODO allow configuring from dashboard
35+
// TODO allow configuring cookie max-age via config
3636
year := 60 * 60 * 24 * 365
3737

3838
gc.SetCookie(constants.AppCookieName+"_session", sessionID, year, "/", host, secure, httpOnly)

internal/cookie/mfa_session.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"github.com/authorizerdev/authorizer/internal/parsers"
1111
)
1212

13-
// TODO set app cookie as per config
14-
1513
// SetMfaSession sets the mfa session cookie in the response
1614
func SetMfaSession(gc *gin.Context, sessionID string, appCookieSecure bool) {
1715
secure := appCookieSecure
@@ -28,13 +26,13 @@ func SetMfaSession(gc *gin.Context, sessionID string, appCookieSecure bool) {
2826
// For more information check:
2927
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
3028
// https://github.com/gin-gonic/gin/blob/master/context.go#L86
31-
// TODO add ability to sameSite = none / strict from dashboard
29+
// TODO add ability to configure sameSite (none / lax / strict) via config
3230
if !appCookieSecure {
3331
gc.SetSameSite(http.SameSiteLaxMode)
3432
} else {
3533
gc.SetSameSite(http.SameSiteNoneMode)
3634
}
37-
// TODO allow configuring from dashboard
35+
// TODO allow configuring cookie max-age via config
3836
age := 60
3937

4038
gc.SetCookie(constants.MfaCookieName+"_session", sessionID, age, "/", host, secure, httpOnly)

internal/parsers/url.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,9 @@ import (
77
"github.com/gin-gonic/gin"
88
)
99

10-
// GetHost returns hostname from request context
11-
// if EnvKeyAuthorizerURL is set it is given highest priority.
12-
// if X-Authorizer-URL header is set it is given second highest priority
13-
// if above 2 are not set the requesting host name is used
10+
// GetHost returns the authorizer host URL from the request context.
11+
// Priority: X-Authorizer-URL header, then scheme (X-Forwarded-Proto) + host (X-Forwarded-Host or Request.Host).
1412
func GetHost(c *gin.Context) string {
15-
// TODO see how we can do based on config
16-
// authorizerURL, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyAuthorizerURL)
17-
// if err != nil {
18-
// authorizerURL = ""
19-
// }
20-
// if authorizerURL != "" {
21-
// return strings.TrimSuffix(authorizerURL, "/")
22-
// }
23-
2413
authorizerURL := c.Request.Header.Get("X-Authorizer-URL")
2514
if authorizerURL != "" {
2615
return strings.TrimSuffix(authorizerURL, "/")
@@ -30,7 +19,10 @@ func GetHost(c *gin.Context) string {
3019
if scheme != "https" {
3120
scheme = "http"
3221
}
33-
host := c.Request.Host
22+
host := c.Request.Header.Get("X-Forwarded-Host")
23+
if host == "" {
24+
host = c.Request.Host
25+
}
3426
return strings.TrimSuffix(scheme+"://"+host, "/")
3527
}
3628

0 commit comments

Comments
 (0)