return error when trying to use accountID path variable with PAT

This commit is contained in:
Pascal Fischer
2025-04-02 16:03:33 +02:00
parent 09243a0fe0
commit de457788ba

View File

@@ -142,6 +142,12 @@ func (m *AuthMiddleware) checkPATFromRequest(r *http.Request, auth []string) (*h
return r, fmt.Errorf("token expired")
}
if impersonate, ok := r.URL.Query()["account"]; ok && len(impersonate) == 1 {
if user.AccountID != impersonate[0] {
return r, fmt.Errorf("token is not valid for this account")
}
}
err = m.authManager.MarkPATUsed(ctx, pat.ID)
if err != nil {
return r, err