Indefero

Indefero Commit Details


Date:2011-09-25 18:36:04 (13 years 2 months ago)
Author:Thomas Keller
Branch:develop, release-1.3
Commit:920432025f6d8c2bc197bbf411fa77123f4005da
Parents: 7ff298af79f43a23d40633f608ef6749810eb3de
Message:Change post-commit webhooks to issue PUTs instead of POST requests and generalize the HTTP header name for the auth digest; introduce an option to restore the old behaviour and document that; place a big warning in NEWS.mdtext about this change.

This change has been sponsored by Scilab.
Changes:

File differences

NEWS.mdtext
66
77
88
9
10
11
12
13
14
15
16
17
918
1019
1120
ATTENTION: You need Pluf [324ae60b](http://projects.ceondo.com/p/pluf/source/commit/324ae60b)
or newer to properly run this version of Indefero!
## Changes
- Indefero's post-commit web hook now by default issues HTTP PUT instead of
HTTP POST requests and carries the authentication digest in the new
`Web-Hook-Hmac` header. The old behaviour can be re-enabled by setting the
`$cfg['webhook_processing']` flag to "compat", we urge you to change the
implementations of this web hook as this setting is likely to be removed
in future versions of Indefero.
## New Features
- Indefero's issue tracker can now bi-directionally link issues with variable, configurable
src/IDF/Commit.php
287287
288288
289289
290
291
292
293
294
295
290296
291297
292298
......
299305
300306
301307
302
308
303309
304310
305311
$url = str_replace(array('%p', '%r'),
array($project->shortname, $this->scm_id),
$conf->getVal('webhook_url', ''));
// trigger a POST instead of the standard PUT if we're asked for
$method = 'PUT';
if (Pluf::f('webhook_processing', '') === 'compat') {
$method = 'POST';
}
$payload = array('to_send' => array(
'project' => $project->shortname,
'rev' => $this->scm_id,
'project_id' => $project->id,
'authkey' => $project->getWebHookKey(),
'url' => $url,
'method' => 'POST',
'method' => $method,
);
$item = new IDF_Queue();
$item->type = 'new_commit';
src/IDF/Views/Project.php
594594
595595
596596
597
598
599
600
597601
598602
599603
......
603607
604608
605609
610
606611
607612
608613
'mtn' => __('monotone'),
);
$repository_type = $options[$scm];
$hook_request_method = 'PUT';
if (Pluf::f('webhook_processing','') === 'compat') {
$hook_request_method = 'POST';
}
return Pluf_Shortcuts_RenderToResponse('idf/admin/source.html',
array(
'remote_svn' => $remote_svn,
'page_title' => $title,
'form' => $form,
'hookkey' => $prj->getWebHookKey(),
'hook_request_method' => $hook_request_method,
),
$request);
}
src/IDF/Webhook.php
3939
4040
4141
42
43
44
45
46
4247
4348
49
4450
4551
4652
4753
4854
49
55
5056
5157
5258
public static function processNotification($payload)
{
$data = json_encode($payload['to_send']);
$sign_header = 'Web-Hook-Hmac';
// use the old signature header if we're asked for
if (Pluf::f('webhook_processing', '') === 'compat') {
$sign_header = 'Post-Commit-Hook-Hmac';
}
$sign = hash_hmac('md5', $data, $payload['authkey']);
$params = array('http' => array(
// fall-back to POST for old queue items
'method' => empty($payload['method']) ? 'POST' : $payload['method'],
'content' => $data,
'user_agent' => 'Indefero Hook Sender (http://www.indefero.net)',
'max_redirects' => 0,
'timeout' => 15,
'header'=> 'Post-Commit-Hook-Hmac: '.$sign."\r\n"
'header'=> $sign_header.': '.$sign."\r\n"
.'Content-Type: application/json'."\r\n",
)
);
src/IDF/conf/idf.php-dist
495495
496496
497497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
498513
499514
# always have precedence.
# $cfg['max_upload_size'] = 2097152; // Size in bytes
# Older versions of Indefero submitted a POST request to a configured
# post-commit web hook when new revisions arrived, whereas a PUT request
# would have been more appropriate. Also, the payload's HMAC digest was
# submitted as value of the HTTP header 'Post-Commit-Hook-Hmac' during
# such a request. Since newer versions of Indefero use the same authentication
# mechanism (based on the same secret key) for other web hooks of the same
# project as well, the name of this HTTP header was no longer appropriate
# and as such changed to simply 'Web-Hook-Hmac'.
#
# Setting the following configuration option to 'compat' now restores the
# old behaviour in both cases. Please notice however that this compatibility
# option is likely to go away in the next major version of Indefero, so you
# should really change the other end of your web hooks!
$cfg['webhook_processing'] = 'compat';
return $cfg;
src/IDF/templates/idf/admin/source.html
6767
6868
6969
70
71
72
70
71
72
7373
7474
7575
<br>
<div class="issue-submit-info">
{blocktrans}<p>The webhook URL setting specifies an URL to which a HTTP POST
request is sent after each repository commit. If this field is empty,
notifications are disabled.</p>
{blocktrans}<p>The webhook URL setting specifies an URL to which a HTTP
<strong>{$hook_request_method}</strong> request is sent after each repository
commit. If this field is empty, notifications are disabled.</p>
<p>Only properly-escaped <strong>HTTP</strong> URLs are supported, for example:</p>

Archive Download the corresponding diff file

Page rendered in 0.09349s using 13 queries.