mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 15:29:28 +01:00
fix(runner): check token
This commit is contained in:
parent
1ae8eb1376
commit
5596943433
@ -13,6 +13,8 @@ import (
|
||||
func RunnerMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
token := r.Header.Get("X-API-Token")
|
||||
|
||||
runnerID, err := helpers.GetIntParam("runner_id", w, r)
|
||||
|
||||
if err != nil {
|
||||
@ -26,6 +28,13 @@ func RunnerMiddleware(next http.Handler) http.Handler {
|
||||
|
||||
runner, err := store.GetGlobalRunner(runnerID)
|
||||
|
||||
if runner.Token != token {
|
||||
helpers.WriteJSON(w, http.StatusUnauthorized, map[string]string{
|
||||
"error": "Invalid token",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
helpers.WriteJSON(w, http.StatusNotFound, map[string]string{
|
||||
"error": "Runner not found",
|
||||
|
Loading…
Reference in New Issue
Block a user