fix: allow setting the issue from environment variables
This commit is contained in:
parent
c8958a8f44
commit
65a3a49864
1 changed files with 7 additions and 0 deletions
|
@ -22,6 +22,8 @@ const (
|
||||||
varServerPort envVar = "SERVER_PORT"
|
varServerPort envVar = "SERVER_PORT"
|
||||||
varServerSocket envVar = "SERVER_SOCK_PATH"
|
varServerSocket envVar = "SERVER_SOCK_PATH"
|
||||||
|
|
||||||
|
varIssuer envVar = "ISSUER"
|
||||||
|
|
||||||
varStorageType envVar = "STORAGE_TYPE"
|
varStorageType envVar = "STORAGE_TYPE"
|
||||||
varStorageFile envVar = "STORAGE_FILEPATH"
|
varStorageFile envVar = "STORAGE_FILEPATH"
|
||||||
varStorageHost envVar = "STORAGE_HOST"
|
varStorageHost envVar = "STORAGE_HOST"
|
||||||
|
@ -55,6 +57,8 @@ const (
|
||||||
defaultServerPort = 5000
|
defaultServerPort = 5000
|
||||||
defaultServerSocket = ""
|
defaultServerSocket = ""
|
||||||
|
|
||||||
|
defaultIssuer = "locahost"
|
||||||
|
|
||||||
defaultStorageType = Memory
|
defaultStorageType = Memory
|
||||||
defaultStorageFile = "./polyculeconnect.db"
|
defaultStorageFile = "./polyculeconnect.db"
|
||||||
defaultStorageHost = "127.0.0.1"
|
defaultStorageHost = "127.0.0.1"
|
||||||
|
@ -145,6 +149,8 @@ func (ac *AppConfig) getConfFromEnv() {
|
||||||
ac.StorageConfig.Password = getStringFromEnv(varStoragePassword, defaultStoragePassword)
|
ac.StorageConfig.Password = getStringFromEnv(varStoragePassword, defaultStoragePassword)
|
||||||
ac.StorageConfig.Ssl.CaFile = getStringFromEnv(varStorageSSLCaFile, defaultStorageSSLCaFile)
|
ac.StorageConfig.Ssl.CaFile = getStringFromEnv(varStorageSSLCaFile, defaultStorageSSLCaFile)
|
||||||
ac.StorageConfig.Ssl.Mode = getStringFromEnv(varStorageSSLMode, defaultStorageSSLMode)
|
ac.StorageConfig.Ssl.Mode = getStringFromEnv(varStorageSSLMode, defaultStorageSSLMode)
|
||||||
|
|
||||||
|
ac.OpenConnectConfig.Issuer = getStringFromEnv(varIssuer, defaultIssuer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ac *AppConfig) RedirectURI() string {
|
func (ac *AppConfig) RedirectURI() string {
|
||||||
|
@ -154,6 +160,7 @@ func (ac *AppConfig) RedirectURI() string {
|
||||||
func New(filepath string) (*AppConfig, error) {
|
func New(filepath string) (*AppConfig, error) {
|
||||||
var conf AppConfig
|
var conf AppConfig
|
||||||
conf.StorageConfig = &StorageConfig{}
|
conf.StorageConfig = &StorageConfig{}
|
||||||
|
conf.OpenConnectConfig = &OpenConnectConfig{}
|
||||||
content, err := os.ReadFile(filepath)
|
content, err := os.ReadFile(filepath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.Is(err, fs.ErrNotExist) {
|
if !errors.Is(err, fs.ErrNotExist) {
|
||||||
|
|
Loading…
Reference in a new issue