mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: check for valid regex in git auth configs (#10020)
This commit is contained in:
@@ -2180,6 +2180,9 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
var externalAuthConfig *externalauth.Config
|
var externalAuthConfig *externalauth.Config
|
||||||
for _, gitAuth := range api.ExternalAuthConfigs {
|
for _, gitAuth := range api.ExternalAuthConfigs {
|
||||||
|
if gitAuth.Regex == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
matches := gitAuth.Regex.MatchString(gitURL)
|
matches := gitAuth.Regex.MatchString(gitURL)
|
||||||
if !matches {
|
if !matches {
|
||||||
continue
|
continue
|
||||||
@@ -2191,6 +2194,9 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
|
|||||||
if len(api.ExternalAuthConfigs) > 0 {
|
if len(api.ExternalAuthConfigs) > 0 {
|
||||||
regexURLs := make([]string, 0, len(api.ExternalAuthConfigs))
|
regexURLs := make([]string, 0, len(api.ExternalAuthConfigs))
|
||||||
for _, extAuth := range api.ExternalAuthConfigs {
|
for _, extAuth := range api.ExternalAuthConfigs {
|
||||||
|
if extAuth.Regex == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
regexURLs = append(regexURLs, fmt.Sprintf("%s=%q", extAuth.ID, extAuth.Regex.String()))
|
regexURLs = append(regexURLs, fmt.Sprintf("%s=%q", extAuth.ID, extAuth.Regex.String()))
|
||||||
}
|
}
|
||||||
detail = fmt.Sprintf("The configured external auth provider have regex filters that do not match the git url. Provider url regexs: %s", strings.Join(regexURLs, ","))
|
detail = fmt.Sprintf("The configured external auth provider have regex filters that do not match the git url. Provider url regexs: %s", strings.Join(regexURLs, ","))
|
||||||
|
|||||||
Reference in New Issue
Block a user