tcplugins / tcWebHooks

WebHooks plugin for Teamcity. Supports many build states and payload formats.
https://netwolfuk.wordpress.com/category/teamcity/tcplugins/tcwebhooks/
157 stars 30 forks source link

Impossible to save WebHook configuration for non system admin users #208

Closed benventive closed 1 year ago

benventive commented 1 year ago

Expected Behavior

When editing a webhook configuration with the rights to edit a project, we should be able to save it properly.

Current Behavior

When editing a webhook configuration with a user that is not a System Administrator, an error shows up indicating that the user has no write permission on the project. When doing this as a System Administrator, this works perfectly.

Steps to Reproduce (for bugs)

Using a user with the "Edit Project" permission but who is not part of the System Administrators

  1. Navigate to any project
  2. Add or edit a webhook
  3. Save

Notice the following message appearing: image

I went digging through the code and it seems to be coming from the recently added validator.

I tried commenting out the check for the permission on the project and it works as expected. I'm not familiar with debugging plugins so I couldn't go further than that. Hope this helps!

Thanks for the great work

Your Environment

Example Configuration (xml)

netwolfuk commented 1 year ago

Hi @benventive. Thanks so much for taking the time to dig through the code and report this bug.

I'll take some time on the weekend to spin up exact versions of what you're running and look into it. There is a lot of change in alpha10, and it looks like I missed something so I'll check it.

It doesn't look like there is any code that will have fixed this in rc1, so I'll check it there too. I keep forgetting to test this stuff as a non-admin. Sorry!

netwolfuk commented 1 year ago

One other thing that might be interesting, is whether the same issue happens if the REST API is installed, and one edits the webhook from the Build Config page. In that instance the REST API is used, and it uses a different validator (I think)

image

netwolfuk commented 1 year ago

Thanks @benventive I was able to reproduce this on the main edit page, but the issue does not appear on the REST API. I am testing on tcWebHooks 1.2.0-rc1 and TeamCity 2022.10.1

netwolfuk commented 1 year ago

Bugfix released @benventive

https://github.com/tcplugins/tcWebHooks/releases/tag/v1.2.0-rc2

netwolfuk commented 1 year ago

Now both the REST API and the UI use the same logic for checking the permissions. Unfortunately not the same code, but at the logic is now consistent.