Skip to content

Commit 2514998

Browse files
committed
Don't handle a missing source as an error
1 parent 08174a6 commit 2514998

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

runner-autoscaler/pkg/srv.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,24 @@ func (s *Autoscaler) verifySignature(ctx *gin.Context) ([]byte, Source, error) {
202202
if source, ok := s.conf.RegisteredSources[src]; ok {
203203
if calcSignature := calcSigHex([]byte(source.Secret), body); calcSignature == signature[7:] {
204204
return body, source, nil
205+
} else {
206+
log.Warnf("%s signature did not match", ctx.RemoteIP())
207+
return nil, Source{}, ctx.AbortWithError(http.StatusUnauthorized, fmt.Errorf("unauthorized"))
205208
}
206209
} else {
207-
log.Errorf("Source with name %s not registered", src)
210+
log.Infof("Source with name %s not registered - ignoring", src)
211+
ctx.Status(http.StatusOK) // not considered an error
212+
return nil, Source{}, fmt.Errorf("unknown webhook source")
208213
}
209214
} else {
210-
log.Error("Missing src query parameter")
215+
log.Errorf("Missing %s query parameter", s.conf.SourceQueryParam)
216+
return nil, Source{}, ctx.AbortWithError(http.StatusBadRequest, fmt.Errorf("missing %s query parameter", s.conf.SourceQueryParam))
211217
}
212218
}
219+
} else {
220+
log.Warnf("%s did not provide a signature", ctx.RemoteIP())
221+
return nil, Source{}, ctx.AbortWithError(http.StatusUnauthorized, fmt.Errorf("unauthorized"))
213222
}
214-
215-
log.Warnf("%s is unauthorized", ctx.RemoteIP())
216-
ctx.AbortWithStatus(http.StatusUnauthorized)
217-
return nil, Source{}, fmt.Errorf("unauthorized")
218223
}
219224

220225
func (s *Autoscaler) GetInstanceState(ctx context.Context, instanceName string) (State, error) {

0 commit comments

Comments
 (0)