cloudapi: add EnsureJobChannel() middleware to verify job channel

Add `EnsureJobChannel()` middleware method, intended for `compose/<id>`
endpoints. Its purpose is to ensure that the tenant channel set in
the request `echo.Context` matches the tenant channel associated with
the compose. In case of mismatch, `404` is returned.

Add `JobChannel()` method to the worker server implementation for
requesting channel associated with the job.
This commit is contained in:
Tomas Hozza 2022-06-06 09:05:41 +02:00 committed by Tom Gundersen
parent c5e1c15cca
commit fc7d090498
2 changed files with 37 additions and 0 deletions

View file

@ -410,6 +410,11 @@ func (s *Server) OSBuildKojiJob(id uuid.UUID, job *OSBuildKojiJob) error {
return nil
}
func (s *Server) JobChannel(id uuid.UUID) (string, error) {
_, _, _, channel, err := s.jobs.Job(id)
return channel, err
}
// JobType returns the type of the job
func (s *Server) JobType(id uuid.UUID) (string, error) {
jobType, _, _, _, err := s.jobs.Job(id)