mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: Allow custom Git OAuth URLs (#4758)
Fixes an issue reported in Discord where custom endpoints weren't working.
This commit is contained in:
@@ -462,7 +462,8 @@ func readSliceFromViper[T any](vip *viper.Viper, key string, value any) []T {
|
||||
if prop == "-" {
|
||||
prop = fve.Tag.Get("yaml")
|
||||
}
|
||||
value := vip.Get(fmt.Sprintf("%s.%d.%s", key, entry, prop))
|
||||
configKey := fmt.Sprintf("%s.%d.%s", key, entry, prop)
|
||||
value := vip.Get(configKey)
|
||||
if value == nil {
|
||||
continue
|
||||
}
|
||||
@@ -470,6 +471,11 @@ func readSliceFromViper[T any](vip *viper.Viper, key string, value any) []T {
|
||||
newType := reflect.Indirect(reflect.New(elementType))
|
||||
instance = &newType
|
||||
}
|
||||
switch instance.Field(i).Type().String() {
|
||||
case "[]string":
|
||||
value = vip.GetStringSlice(configKey)
|
||||
default:
|
||||
}
|
||||
instance.Field(i).Set(reflect.ValueOf(value))
|
||||
}
|
||||
if instance == nil {
|
||||
|
||||
@@ -158,6 +158,7 @@ func TestConfig(t *testing.T) {
|
||||
"CODER_GITAUTH_0_AUTH_URL": "https://auth.com",
|
||||
"CODER_GITAUTH_0_TOKEN_URL": "https://token.com",
|
||||
"CODER_GITAUTH_0_REGEX": "github.com",
|
||||
"CODER_GITAUTH_0_SCOPES": "read write",
|
||||
|
||||
"CODER_GITAUTH_1_ID": "another",
|
||||
"CODER_GITAUTH_1_TYPE": "gitlab",
|
||||
@@ -177,6 +178,7 @@ func TestConfig(t *testing.T) {
|
||||
AuthURL: "https://auth.com",
|
||||
TokenURL: "https://token.com",
|
||||
Regex: "github.com",
|
||||
Scopes: []string{"read", "write"},
|
||||
}, {
|
||||
ID: "another",
|
||||
Type: "gitlab",
|
||||
|
||||
Reference in New Issue
Block a user