Ensure other repositories are given as ssh URL
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2023-04-21 13:47:18 +02:00
parent 1ab2df8228
commit 79814fba21

View File

@ -115,6 +115,11 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
}
}
if uri.Scheme != "ssh" && uri.Scheme != "git+ssh" {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "Unrecognized URL scheme. You need to provide a SSH repository URL."})
return
}
if strings.Contains(uri.Host, "epita.fr") {
if !strings.HasPrefix(uri.Path, fmt.Sprintf("/%s/", u.Login)) {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "repository URL forbidden"})