-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template editing should be available for non-administrative users #131
Comments
I agree. That was always the end goal. It just turns out the UX is quite tricky to surface to the user. Now that the statistics model is more complete, I could add the payload to the history page. If you're interested in helping solve it, I'm happy to have a discussion here or on gitter. |
Btw. I was referring to the project level template. I was imagining it being able to be overridden at a project level. But it introduces a few issues. Does the template override the top level one for all subprojects? Your first option is probably easier to implement, but I think it requires some manually defined permissions. I'm not sure if I can programmatically create extra permission types. |
I asked TeamCity support. It's not possible to extend permissions to include our own. So option 1 is out. |
Another consideration: what happens if a project level template does not support a specific build event? Does the webhook fail to fire, or is the template resolved from a parent template? |
Hey @netwolfuk , I was about to open a new issue when I stumbled on this one. I was actually going to request the same kind of change, but only in the context of testing a given template (i.e. using these endpoints) Would this specific change be "less-tricky" to implement compared to the full-on create/edit/delete operations? If so, it would be a good starting point. |
Hi @pgrefviau. Is what you want already available via the Test tab on the webhook edit dialog? |
I managed to get it working from cURL, although it's a bit of a pain.
The request payload looks like this:
And the response is:
Error handling is atrocious :-( If it fails, you get a HTMLified java stracktrace from teamcity's default error handler, but it might be of some use to you. edit: |
I've been thinking about this some more. When project template support is added, I'm wondering if we just say that templates can't be overridden at the project level. With this model, if you want a project template, it needs to have its own template id. Then we don't need to worry about inheritance issues and my concerns above are negated. It would still be possible to copy existing templates (assuming it belongs to a project you have read access to) or create a new template from scratch. Templates would be available to webhooks in the associated project and any subprojects. |
Yes. That's the template editing screen. The reason I did it that way was because I was too lazy to figure out all the the edge cases for permissions. Eg, I'd only need to show projects the user is permitted to execute webhooks on, otherwise there's a chance they could execute a webhook to their own URL with a template or build which someone may have baked some sensitive data into. I guess it depends on what she was wanting to test. But it does raise a good point with regards to implementing project level templates. |
This allows a WebHook Template to be created and associated with a project rather then just _Root. Now group admins can create templates for use with their own webhooks. This addresses issue #131 Note: WebHook Template Ids must be unique across a teamcity instance, even if the user creating the template is not aware and is not permissioned to see an existing template with that ID. - Uses templateId rather than templateName when referring to ID. - Added projectId field and getProjectId method to templates. - Added validators and permissions - Fixed up permissions for template editing in REST API - Added Templates to WebHook Project tab - Added Templates list to Webhook Project Config tab. - Added Project Name and link to Templates page. - WebHooks now resolve project specific templates when building payload.
This is available in 1.2.0 alpha 4. I'll leave this ticket open (but tagged as waiting for release) and will close it when 1.2.0 final is released. Please do try it out. The alpha is stable. 1.2.0 final might be quite a while away yet. |
1.2.0 alpha 4 is here: https://github.com/tcplugins/tcWebHooks/releases/tag/v1.2.0-alpha.4 |
Hey! Sorry to resurrect an old issue; we noticed that when non-administrators tried copying a template from the root project to a different destination project, they saw 405s, but when they created a template directly in the destination project, it worked fine! |
Hi @liam-mackie Thanks for commmenting. Can you let me know which version of the tcWebHooks plugin you're using? I'll have a look and check if I can reproduce it locally. |
Hmm. I am seeing a similar thing. I get a I made a change this week so that getting an existing template requires edit project. I suspect I need to re-think that because of this feature. If you say you get a 405, I am guessing that it's trying to POST the template but to the wrong URL. Can you please have a look at the browser JS console's network tab and check the URL that it's trying to post to? That would help nail down where the issue could be. And let me know the version you're using and I'll downgrade to the same so that we are comparing the same code. Thanks! |
Hi @liam-mackie Thanks for your comment. I looked at your profile and assumed you work with @matt-richardson and are therefore probably running the very recent 1.2.0 alpha. I installed alpha9 and have found two bugs that are present when using templates with a non-admin user.
Edit: It looks like I was dreaming. It's not possible to override a template in a sub-project. I looked at the code, and the TemplateManager has a single It does introduce a subtle bug. Say, we defined a template in MyProject1 with the same ID as a bundled template. It would be overriden for that project, but no other project would get a chance to override it. I think I need to make a change to only allow overriding a bundled template if the new version is associated with the |
Hi @liam-mackie I've just pushed a fix for the permissions, which should fix your issue. If you want to take look at the latest build on this branch |
I'm planning to merge this and release as 1.2.0-alpha.10 on the weekend. I'm hoping it's the last alpha before release candidate. |
Sorry about the poor replies, I didn't get any emails about your replies for some reason! shakes fist at gmail Yes, we are on 1.2.0 Alpha! Thanks so much for the swift fix! Excited for the RC! I will install alpha.10 on our prerelease TeamCity server in the coming days and test that it's been fixed! Once the RC is released, I'll update as well! Thanks again for the fix and your time, it's much appreciated! |
No worries. I'm not getting emails either. shakes fist at mail client. I found a bug last night, but still hoping to get a release out this weekend. |
Alpha 10 released https://github.com/tcplugins/tcWebHooks/releases |
Release candidate 1 released https://github.com/tcplugins/tcWebHooks/releases/tag/v1.2.0-rc1 |
This allows a WebHook Template to be created and associated with a project rather then just _Root. Now group admins can create templates for use with their own webhooks. This addresses issue #131 Note: WebHook Template Ids must be unique across a teamcity instance, even if the user creating the template is not aware and is not permissioned to see an existing template with that ID. - Uses templateId rather than templateName when referring to ID. - Added projectId field and getProjectId method to templates. - Added validators and permissions - Fixed up permissions for template editing in REST API - Added Templates to WebHook Project tab - Added Templates list to Webhook Project Config tab. - Added Project Name and link to Templates page. - WebHooks now resolve project specific templates when building payload.
Expected Behavior
Non-administrators should be able to create and edit a Webhook Template
Current Behavior
Creating, editing, or deleting Webhook Templates requires full administrative rights to the TeamCity instance. This discourages administrators from providing self service to Webhook Templates, because it would give a user too much power over TeamCity.
Solution Ideas
Create a custom permission for creating, editing, and deleting Webhook Templates
The simplest solution would be to have a new kind of permission that would grant access to Webhook Templates and nothing else. However, this is an all-or-nothing permission that would allow them to break existing webhooks.
Associate Templates with a Project
To allow users more autonomy without allowing them to break important global webhooks, the Templates could be associated with the project hierarchy, and then administrative permissions to a project would control whether the users had permission to modify the Templates or not.
Your Environment
The text was updated successfully, but these errors were encountered: