File tree 2 files changed +26
-3
lines changed
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,28 @@ func serve(cmd *cobra.Command, args []string) error {
153
153
logger .Infof ("config storage: %s" , c .Storage .Type )
154
154
155
155
if len (c .StaticClients ) > 0 {
156
- for _ , client := range c .StaticClients {
156
+ for i , client := range c .StaticClients {
157
+ if client .Name == "" {
158
+ return fmt .Errorf ("invalid config: Name field is required for a client" )
159
+ }
160
+ if client .ID == "" && client .IDEnv == "" {
161
+ return fmt .Errorf ("invalid config: ID or IDEnv field is required for a client" )
162
+ }
163
+ if client .IDEnv != "" {
164
+ if client .ID != "" {
165
+ return fmt .Errorf ("invalid config: ID and IDEnv fields are exclusive for client %q" , client .ID )
166
+ }
167
+ c .StaticClients [i ].ID = os .Getenv (client .IDEnv )
168
+ }
169
+ if client .Secret == "" && client .SecretEnv == "" {
170
+ return fmt .Errorf ("invalid config: Secret or SecretEnv field is required for client %q" , client .ID )
171
+ }
172
+ if client .SecretEnv != "" {
173
+ if client .Secret != "" {
174
+ return fmt .Errorf ("invalid config: Secret and SecretEnv fields are exclusive for client %q" , client .ID )
175
+ }
176
+ c .StaticClients [i ].Secret = os .Getenv (client .SecretEnv )
177
+ }
157
178
logger .Infof ("config static client: %s" , client .Name )
158
179
}
159
180
s = storage .WithStaticClients (s , c .StaticClients )
Original file line number Diff line number Diff line change @@ -113,8 +113,10 @@ type Storage interface {
113
113
// * Public clients: https://developers.google.com/api-client-library/python/auth/installed-app
114
114
type Client struct {
115
115
// Client ID and secret used to identify the client.
116
- ID string `json:"id" yaml:"id"`
117
- Secret string `json:"secret" yaml:"secret"`
116
+ ID string `json:"id" yaml:"id"`
117
+ IDEnv string `json:"idEnv" yaml:"idEnv"`
118
+ Secret string `json:"secret" yaml:"secret"`
119
+ SecretEnv string `json:"secretEnv" yaml:"secretEnv"`
118
120
119
121
// A registered set of redirect URIs. When redirecting from dex to the client, the URI
120
122
// requested to redirect to MUST match one of these values, unless the client is "public".
You can’t perform that action at this time.
0 commit comments