mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-11 16:05:49 +01:00
Merge pull request #1169 from McFoggy/issue-1168
correct empty security token usage, fixes #1168
This commit is contained in:
@@ -109,10 +109,10 @@ trait WebHookService {
|
|||||||
def postContent = new UrlEncodedFormEntity(params, "UTF-8")
|
def postContent = new UrlEncodedFormEntity(params, "UTF-8")
|
||||||
httpPost.setEntity(postContent)
|
httpPost.setEntity(postContent)
|
||||||
|
|
||||||
if (!webHook.token.isEmpty) {
|
if (webHook.token.exists(_.trim.nonEmpty)) {
|
||||||
// TODO find a better way and see how to extract content from postContent
|
// TODO find a better way and see how to extract content from postContent
|
||||||
val contentAsBytes = URLEncodedUtils.format(params, "UTF-8").getBytes("UTF-8")
|
val contentAsBytes = URLEncodedUtils.format(params, "UTF-8").getBytes("UTF-8")
|
||||||
httpPost.addHeader("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, webHook.token.orNull, contentAsBytes))
|
httpPost.addHeader("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, webHook.token.get, contentAsBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
val res = httpClient.execute(httpPost)
|
val res = httpClient.execute(httpPost)
|
||||||
|
|||||||
@@ -136,9 +136,13 @@ $(function(){
|
|||||||
$("#test-modal-url").text(url)
|
$("#test-modal-url").text(url)
|
||||||
$("#test-report-modal").modal('show')
|
$("#test-report-modal").modal('show')
|
||||||
$("#test-report").hide();
|
$("#test-report").hide();
|
||||||
|
var targetUrl = '@url(repository)/settings/hooks/test?url=' + encodeURIComponent(url) + '&token=';
|
||||||
|
if (token) {
|
||||||
|
targetUrl = targetUrl + encodeURIComponent(token);
|
||||||
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:'POST',
|
method:'POST',
|
||||||
url:'@url(repository)/settings/hooks/test?url=' + encodeURIComponent(url) + '&token=' + encodeURIComponent(token),
|
url:targetUrl,
|
||||||
success: function(e){
|
success: function(e){
|
||||||
//console.log(e);
|
//console.log(e);
|
||||||
$('#test-report-tab a:first').tab('show');
|
$('#test-report-tab a:first').tab('show');
|
||||||
|
|||||||
Reference in New Issue
Block a user