mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-22 19:18:01 +02:00
core/zero: add support for managed mode from config file
This commit is contained in:
parent
eb729a53f8
commit
78f2793d38
4 changed files with 68 additions and 9 deletions
|
@ -1,6 +1,10 @@
|
|||
package cmd
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
// PomeriumZeroTokenEnv is the environment variable name for the API token.
|
||||
|
@ -8,6 +12,20 @@ const (
|
|||
PomeriumZeroTokenEnv = "POMERIUM_ZERO_TOKEN"
|
||||
)
|
||||
|
||||
func getToken() string {
|
||||
return os.Getenv(PomeriumZeroTokenEnv)
|
||||
func getToken(configFile string) string {
|
||||
if token, ok := os.LookupEnv(PomeriumZeroTokenEnv); ok {
|
||||
return token
|
||||
}
|
||||
|
||||
if configFile != "" {
|
||||
// load the token from the config file
|
||||
v := viper.New()
|
||||
v.SetConfigFile(configFile)
|
||||
if v.ReadInConfig() == nil {
|
||||
return v.GetString("pomerium_zero_token")
|
||||
}
|
||||
}
|
||||
|
||||
// we will fallback to normal pomerium if empty
|
||||
return ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue