mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
auth: strip port from domain if present
app.UseProxyHost being enabled means app.ExternalDomain sometimes returns a domain/IP with a port attached. This is now removed, so the refresh cookie is set correctly.
This commit is contained in:
11
config.go
11
config.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -81,6 +82,16 @@ func (app *appContext) ExternalDomain(gc *gin.Context) string {
|
||||
return gc.Request.Host
|
||||
}
|
||||
|
||||
// ExternalDomainNoPort attempts to return app.ExternalDomain() with the port removed. If the internally-used method fails, it is assumed the domain has no port anyway.
|
||||
func (app *appContext) ExternalDomainNoPort(gc *gin.Context) string {
|
||||
domain := app.ExternalDomain(gc)
|
||||
host, _, err := net.SplitHostPort(domain)
|
||||
if err != nil {
|
||||
return domain
|
||||
}
|
||||
return host
|
||||
}
|
||||
|
||||
// ExternalURI returns the External URI of jfa-go's root directory (by default, where the admin page is), using the fixed app.externalURI value unless app.UseProxyHost is true and gc is not nil.
|
||||
// When nil is passed, app.externalURI is returned.
|
||||
func (app *appContext) ExternalURI(gc *gin.Context) string {
|
||||
|
||||
Reference in New Issue
Block a user