Make listen port configurable (#230)
Co-authored-by: Tobias Hess <tobias.hess@energiekoppler.com>
This commit is contained in:
parent
8be8244b13
commit
6c6f75e80d
@ -162,6 +162,7 @@ Application Options:
|
|||||||
--url-path= Callback URL Path (default: /_oauth) [$URL_PATH]
|
--url-path= Callback URL Path (default: /_oauth) [$URL_PATH]
|
||||||
--secret= Secret used for signing (required) [$SECRET]
|
--secret= Secret used for signing (required) [$SECRET]
|
||||||
--whitelist= Only allow given email addresses, can be set multiple times [$WHITELIST]
|
--whitelist= Only allow given email addresses, can be set multiple times [$WHITELIST]
|
||||||
|
--port= Port to listen on (default: 4181) [$PORT]
|
||||||
--rule.<name>.<param>= Rule definitions, param can be: "action", "rule" or "provider"
|
--rule.<name>.<param>= Rule definitions, param can be: "action", "rule" or "provider"
|
||||||
|
|
||||||
Google Provider:
|
Google Provider:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
internal "github.com/thomseddon/traefik-forward-auth/internal"
|
internal "github.com/thomseddon/traefik-forward-auth/internal"
|
||||||
@ -25,6 +26,6 @@ func main() {
|
|||||||
|
|
||||||
// Start
|
// Start
|
||||||
log.WithField("config", config).Debug("Starting with config")
|
log.WithField("config", config).Debug("Starting with config")
|
||||||
log.Info("Listening on :4181")
|
log.Infof("Listening on :%d", config.Port)
|
||||||
log.Info(http.ListenAndServe(":4181", nil))
|
log.Info(http.ListenAndServe(fmt.Sprintf(":%d", config.Port), nil))
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ type Config struct {
|
|||||||
Path string `long:"url-path" env:"URL_PATH" default:"/_oauth" description:"Callback URL Path"`
|
Path string `long:"url-path" env:"URL_PATH" default:"/_oauth" description:"Callback URL Path"`
|
||||||
SecretString string `long:"secret" env:"SECRET" description:"Secret used for signing (required)" json:"-"`
|
SecretString string `long:"secret" env:"SECRET" description:"Secret used for signing (required)" json:"-"`
|
||||||
Whitelist CommaSeparatedList `long:"whitelist" env:"WHITELIST" env-delim:"," description:"Only allow given email addresses, can be set multiple times"`
|
Whitelist CommaSeparatedList `long:"whitelist" env:"WHITELIST" env-delim:"," description:"Only allow given email addresses, can be set multiple times"`
|
||||||
|
Port int `long:"port" env:"PORT" default:"4181" description:"Port to listen on"`
|
||||||
|
|
||||||
Providers provider.Providers `group:"providers" namespace:"providers" env-namespace:"PROVIDERS"`
|
Providers provider.Providers `group:"providers" namespace:"providers" env-namespace:"PROVIDERS"`
|
||||||
Rules map[string]*Rule `long:"rule.<name>.<param>" description:"Rule definitions, param can be: \"action\", \"rule\" or \"provider\""`
|
Rules map[string]*Rule `long:"rule.<name>.<param>" description:"Rule definitions, param can be: \"action\", \"rule\" or \"provider\""`
|
||||||
|
@ -37,6 +37,7 @@ func TestConfigDefaults(t *testing.T) {
|
|||||||
assert.False(c.MatchWhitelistOrDomain)
|
assert.False(c.MatchWhitelistOrDomain)
|
||||||
assert.Equal("/_oauth", c.Path)
|
assert.Equal("/_oauth", c.Path)
|
||||||
assert.Len(c.Whitelist, 0)
|
assert.Len(c.Whitelist, 0)
|
||||||
|
assert.Equal(c.Port, 4181)
|
||||||
|
|
||||||
assert.Equal("select_account", c.Providers.Google.Prompt)
|
assert.Equal("select_account", c.Providers.Google.Prompt)
|
||||||
}
|
}
|
||||||
@ -51,6 +52,7 @@ func TestConfigParseArgs(t *testing.T) {
|
|||||||
"--rule.1.rule=PathPrefix(`/one`)",
|
"--rule.1.rule=PathPrefix(`/one`)",
|
||||||
"--rule.two.action=auth",
|
"--rule.two.action=auth",
|
||||||
"--rule.two.rule=\"Host(`two.com`) && Path(`/two`)\"",
|
"--rule.two.rule=\"Host(`two.com`) && Path(`/two`)\"",
|
||||||
|
"--port=8000",
|
||||||
})
|
})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@ -58,6 +60,7 @@ func TestConfigParseArgs(t *testing.T) {
|
|||||||
assert.Equal("cookiename", c.CookieName)
|
assert.Equal("cookiename", c.CookieName)
|
||||||
assert.Equal("csrfcookiename", c.CSRFCookieName)
|
assert.Equal("csrfcookiename", c.CSRFCookieName)
|
||||||
assert.Equal("oidc", c.DefaultProvider)
|
assert.Equal("oidc", c.DefaultProvider)
|
||||||
|
assert.Equal(8000, c.Port)
|
||||||
|
|
||||||
// Check rules
|
// Check rules
|
||||||
assert.Equal(map[string]*Rule{
|
assert.Equal(map[string]*Rule{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user