Skip to content

How to bind environment variables to a yaml list of dictionaries #1933

Closed Answered by yohanleb
yohanleb asked this question in Q&A
Discussion options

You must be logged in to vote

Using a map and setting the providers empty by default solved the issue.

yaml config

auth:
  providers:

Go structs

type AuthConfiguration struct {
	Providers map[string]ProviderConfiguration `mapstructure:"providers" validate:"dive"`
}

type ProviderConfiguration struct {
	Name         string `mapstructure:"name" validate:"required"`
	ClientId     string `mapstructure:"client_id" validate:"required"`
	ClientSecret string `mapstructure:"client_secret" validate:"required"`
	Issuer       string `mapstructure:"issuer" validate:"required"`
}

Env

AUTH_PROVIDERS=google,authelia

AUTH_PROVIDER_GOOGLE_NAME=Google
AUTH_PROVIDER_GOOGLE_CLIENT_ID=clientid.apps.googleusercontent.com
AUTH_PROVIDER_GO…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@yohanleb
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by yohanleb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants