List of commits:
Subject Hash Author Date (UTC)
Big Amazon fixes f185636cf44652a2da9779ab21979807b91cf48f Catalin(ux) M. BOIE 2016-12-07 20:38:54
Typos, some additions for hints, TODO a0b3ff70ddcdfa28770b6467b03332b70cf38067 Catalin(ux) M. BOIE 2016-12-07 20:37:47
events.php missed apikeys include e6370414e0bef923fb5d1f639b8a7738fb8d1641 Catalin(ux) M. BOIE 2016-12-07 20:34:05
Improved the functional tests 935c1f0f62aba1ca75fce124a33593e7e900a83a Catalin(ux) M. BOIE 2016-12-07 20:33:33
Put passwords next to username to allow browser to cache username and not e-mail 4e2d12ca5ce8f5420c3d51469386eda84724256a Catalin(ux) M. BOIE 2016-12-07 20:32:23
Raise the limits for the queries to 50 529edd633de2059eefd12afeb67847bbb72c4eed Catalin(ux) M. BOIE 2016-12-07 20:29:06
Added Gogs.io into comparison and added more criteria 09bb2d793e67f732ff275ba72e42c71d54fd51d6 Catalin(ux) M. BOIE 2016-12-07 20:28:20
If session expires and the user presses logout, do not give errors 5871b5cd6efae48655000b980f641b39ccc4a146 Catalin(ux) M. BOIE 2016-12-07 20:11:31
No need for AllowOverride All 4b0cf4ec9663f0aa3cf4f8d55dfb4f7f3fd8614d Catalin(ux) M. BOIE 2016-11-20 08:17:15
Use getmyuid instead of posix_getuid to not depend on another extention f6d6dcce4d565281e3d47079974b6d6a91a36ae4 Catalin(ux) M. BOIE 2016-11-20 07:15:04
CSS adjustments 264821ffdde5ad2d9c196844ecd13fd689b7e353 Catalin(ux) M. BOIE 2016-11-19 14:13:02
Some rewording in Donate page 58626a058176945e165ab0230bd1093e025a07ac Catalin(ux) M. BOIE 2016-11-19 14:08:20
Bump version to 0.64 b414b4d454c2f37010d213cd23662f01b7fb3951 Catalin(ux) M. BOIE 2016-11-19 13:25:15
Do not set ServerName if it unknown; else will not match 1b58474438fff06932d666f04f75581bfea7361b Catalin(ux) M. BOIE 2016-11-19 13:24:23
The build process nedds php 681151c53be2922e9f2cedc20be5add1587e013d Catalin(ux) M. BOIE 2016-11-17 22:37:46
Bump version to 0.63 cefea42530ef6ed4ddf8d2f36020b8e2d5dbf467 Catalin(ux) M. BOIE 2016-11-17 18:39:51
TODO updates b11fde8c1548fe9b0968b4193ace5418516ef043 Catalin(ux) M. BOIE 2016-11-17 18:39:08
Do not show "My repositories" and "Suggestion" menus if admin c2338a8b03a77618e7de86ebcc2ce80b4d4b5268 Catalin(ux) M. BOIE 2016-11-17 17:29:46
Update comparison 5fc0290369207bcb063f5fad355a90e31b93c975 Catalin(ux) M. BOIE 2016-11-16 21:49:18
Added GNU Ethical Repository Criteria Evaluations results in compare.csv e3cff3f25926df5d9860b95a82c928d527cb01eb Catalin(ux) M. BOIE 2016-11-15 20:59:41
Commit f185636cf44652a2da9779ab21979807b91cf48f - Big Amazon fixes
Author: Catalin(ux) M. BOIE
Author date (UTC): 2016-12-07 20:38
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2016-12-07 20:38
Parent(s): a0b3ff70ddcdfa28770b6467b03332b70cf38067
Signing key:
Tree: b2bbcef8860d72240b346719b8d2df08b9d087de
File Lines added Lines deleted
inc/wh/amazon.inc.php 129 46
inc/wh/build.inc.php 8 0
inc/wh/cloud.inc.php 8 0
inc/wh/http.inc.php 8 7
inc/wh/lambda.inc.php 15 2
File inc/wh/amazon.inc.php changed (mode: 100644) (index 5c4c32c..749260e)
... ... function rg_amazon_auth($a)
11 11
12 12 $ret = array('ok' => 0); $ret = array('ok' => 0);
13 13 while (1) { while (1) {
14 if (!isset($a['service']))
15 $service = '';
16 else
17 $service = $a['service'];
18
19 // Must be ordered!
20 $ret['query_string'] = '';
21 if (!isset($a['query_string'])) {
22 $ret['query_string'] = '';
23 } else if (is_array($a['query_string'])) {
24 ksort($a['query_string']);
25 $add = '';
26 foreach ($a['query_string'] as $k => $v) {
27 $ret['query_string'] .= $add
28 . urlencode($k) . '='
29 . urlencode($v);
30 $add = '&';
31 }
32 } else {
33 $ret['query_string'] = $a['query_string'];
34 }
35
36 if (strcmp($a['method'], 'GET') == 0) {
37 $qs = $ret['query_string'];
38 $ret['query_string'] = '';
39 } else {
40 $qs = '';
41 }
42
43 rg_log('DEBUG: ret[query_string]=' . $ret['query_string']);
44
45 if (!empty($a['content'])) {
46 $a['x-amz-content-sha256'] = hash('sha256', $a['content'], TRUE);
47 rg_log('DEBUG: a[content] is set to: ' . $a['content']);
48 $a['iheaders']['x-amz-content-sha256'] =
49 bin2hex($a['x-amz-content-sha256']);
50 } else {
51 $a['x-amz-content-sha256'] = hash('sha256',
52 $ret['query_string'], TRUE);
53 rg_log('DEBUG: a[content] is not set');
54 }
55 rg_log_ml('DEBUG: a[iheaders]: ' . print_r($a['iheaders'], TRUE));
56
14 57 $iheaders_final = array(); $iheaders_final = array();
15 58 $iheaders_list = array(); $iheaders_list = array();
16 59 foreach ($a['iheaders'] as $head => $val) { foreach ($a['iheaders'] as $head => $val) {
 
... ... function rg_amazon_auth($a)
23 66 $iheaders_list = implode(';', $iheaders_list); $iheaders_list = implode(';', $iheaders_list);
24 67 $iheaders_final = implode("\n", $iheaders_final) . "\n\n"; $iheaders_final = implode("\n", $iheaders_final) . "\n\n";
25 68
69 $ret['iheaders'] = $a['iheaders'];
70
26 71 $canonical_request = $a['method'] . "\n" $canonical_request = $a['method'] . "\n"
27 . '/' . urlencode($a['file']) . "\n"
28 . "\n"
72 . $a['url'] . urlencode($a['file']) . "\n"
73 . $qs . "\n"
29 74 . $iheaders_final . $iheaders_final
30 75 . $iheaders_list . "\n" . $iheaders_list . "\n"
31 76 . bin2hex($a['x-amz-content-sha256']); . bin2hex($a['x-amz-content-sha256']);
32 rg_log_ml('canonical_request:' . "\n" . $canonical_request
77 rg_log_ml('DEBUG: canonical_request:' . "\n" . $canonical_request
33 78 . "\n" . '==='); . "\n" . '===');
34 79
35 80 $string_to_sign = 'AWS4-HMAC-SHA256' . "\n" $string_to_sign = 'AWS4-HMAC-SHA256' . "\n"
36 81 . $a['x-amz-date'] . "\n" . $a['x-amz-date'] . "\n"
37 82 . gmdate('Ymd', $a['ts']) . gmdate('Ymd', $a['ts'])
38 83 . '/' . $a['region'] . '/' . $a['region']
39 . '/' . $a['service']
84 . '/' . $service
40 85 . '/' . 'aws4_request' . '/' . 'aws4_request'
41 86 . "\n" . "\n"
42 87 . hash('sha256', $canonical_request); . hash('sha256', $canonical_request);
43 88 rg_log_ml('string_to_sign:' . "\n" . $string_to_sign rg_log_ml('string_to_sign:' . "\n" . $string_to_sign
44 89 . "\n" . '==='); . "\n" . '===');
45 90
91 rg_log('DEBUG: secret_access_key=' . $a['secret_access_key'] . '.');
46 92 $date_key = hash_hmac('sha256', gmdate('Ymd', $a['ts']), $date_key = hash_hmac('sha256', gmdate('Ymd', $a['ts']),
47 93 'AWS4' . $a['secret_access_key'], TRUE); 'AWS4' . $a['secret_access_key'], TRUE);
94 rg_log('DEBUG: date_key=' . bin2hex($date_key));
48 95 $date_region_key = hash_hmac('sha256', $a['region'], $date_region_key = hash_hmac('sha256', $a['region'],
49 96 $date_key, TRUE); $date_key, TRUE);
97 rg_log('DEBUG: date_region_key=' . bin2hex($date_region_key));
50 98 $date_region_service_key = hash_hmac('sha256', $date_region_service_key = hash_hmac('sha256',
51 $a['service'], $date_region_key, TRUE);
99 $service, $date_region_key, TRUE);
100 rg_log('DEBUG: service=' . $service . ' date_region_service_key=' . bin2hex($date_region_service_key));
52 101 $signing_key = hash_hmac('sha256', 'aws4_request', $signing_key = hash_hmac('sha256', 'aws4_request',
53 102 $date_region_service_key, TRUE); $date_region_service_key, TRUE);
103 rg_log('DEBUG: signing_key=' . bin2hex($signing_key));
54 104 $signature = hash_hmac('sha256', $string_to_sign, $signing_key); $signature = hash_hmac('sha256', $string_to_sign, $signing_key);
55 105 rg_log('DEBUG: signature=' . $signature); rg_log('DEBUG: signature=' . $signature);
56 106
57 107 $cred = $a['access_key_id'] $cred = $a['access_key_id']
58 . '/' . gmdate('Ymd')
108 . '/' . gmdate('Ymd', $a['ts'])
59 109 . '/' . $a['region'] . '/' . $a['region']
60 . '/' . $a['service']
110 . '/' . $service
61 111 . '/aws4_request'; . '/aws4_request';
62 112
63 113 $ret['data'] = 'AWS4-HMAC-SHA256' $ret['data'] = 'AWS4-HMAC-SHA256'
 
... ... function rg_amazon_auth($a)
74 124 } }
75 125
76 126 /* /*
77 * Make a generic request to the amazon
127 * Generic curl helper
78 128 */ */
79 function rg_amazon_req($a)
129 function rg_amazon_curl($url, $method, $headers, $data)
80 130 { {
81 rg_prof_start('amazon_req');
82 rg_log_enter('amazon_req');
83 rg_log_ml('DEBUG: a:' . print_r($a, TRUE));
131 rg_log_ml('amazon_curl: data: START' . "\n"
132 . print_r($data, TRUE) . "\n" . 'END');
84 133
85 134 $ret = array('ok' => 0); $ret = array('ok' => 0);
86 135 while (1) { while (1) {
87 $url = 'https://' . $a['host'] . '/' . urlencode($a['file']);
136 if (strcmp($method, 'GET') == 0) {
137 if (!strstr($url, '?'))
138 $url .= '?';
139 $url .= $data;
140 }
141
88 142 $c = curl_init($url); $c = curl_init($url);
89 143 if ($c === FALSE) { if ($c === FALSE) {
90 144 $ret['error'] = 'cannot init curl'; $ret['error'] = 'cannot init curl';
91 145 break; break;
92 146 } }
93 147
94 $a['region'] = trim(strtolower($a['region']));
95
96 $a['ts'] = time();
97 $a['x-amz-date'] = gmdate('Ymd', $a['ts'])
98 . 'T' . gmdate('His', $a['ts']) . 'Z';
99 $a['x-amz-content-sha256'] = hash('sha256', $a['content'], TRUE);
100 $a['host'] = trim(strtolower($a['host']));
101 $a['service'] = trim(strtolower($a['service']));
102
103 if (!isset($a['iheaders']))
104 $a['iheaders'] = array();
105 $a['iheaders']['Host'] = $a['host'];
106 $a['iheaders']['x-amz-date'] = $a['x-amz-date'];
107 $a['iheaders']['x-amz-content-sha256'] = bin2hex($a['x-amz-content-sha256']);
108
109 $auth = rg_amazon_auth($a);
110 if ($auth['ok'] != 1) {
111 $ret['error'] = $auth['error'];
112 break;
148 curl_setopt($c, CURLOPT_CUSTOMREQUEST, $method);
149 if (strcmp($method, 'GET') != 0) {
150 curl_setopt($c, CURLOPT_POST, 1);
151 curl_setopt($c, CURLOPT_POSTFIELDS, $data);
113 152 } }
114
115 $headers = array();
116 if (isset($a['content_type']))
117 $headers[] = 'Content-Type: ' . $a['content_type'];
118 $headers[] = 'Authorization: ' . $auth['data'];
119 foreach ($a['iheaders'] as $head => $val)
120 $headers[] = $head . ': ' . $val;
121 //rg_log_ml('HEADERS:' . print_r($headers, TRUE));
122
123 curl_setopt($c, CURLOPT_CUSTOMREQUEST, $a['method']);
124 //curl_setopt($c, CURLOPT_POST, 1);
125 curl_setopt($c, CURLOPT_POSTFIELDS, $a['content']);
126 153 curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE);
127 154 curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
128 155 //curl_setopt($c, CURLOPT_HEADER, 1); //curl_setopt($c, CURLOPT_HEADER, 1);
 
... ... function rg_amazon_req($a)
172 199 } }
173 200 curl_close($c); curl_close($c);
174 201
202 return $ret;
203 }
204
205 /*
206 * Make a generic request to the amazon
207 */
208 function rg_amazon_req($a)
209 {
210 rg_prof_start('amazon_req');
211 rg_log_enter('amazon_req');
212 rg_log_ml('DEBUG: a:' . print_r($a, TRUE));
213
214 $ret = array('ok' => 0);
215 while (1) {
216 if (!isset($a['url']))
217 $a['url'] = '/';
218 if (!isset($a['file']))
219 $a['file'] = '';
220 if (!empty($a['file']))
221 $a['file'] = $a['file'];
222
223 $url = 'https://' . $a['host'] . $a['url'] . $a['file'];
224
225 $a['region'] = trim(strtolower($a['region']));
226
227 if (!isset($a['ts']))
228 $a['ts'] = time();
229 $a['x-amz-date'] = gmdate('Ymd', $a['ts'])
230 . 'T' . gmdate('His', $a['ts']) . 'Z';
231 $a['host'] = trim(strtolower($a['host']));
232 $a['service'] = trim(strtolower($a['service']));
233
234 if (!isset($a['iheaders']))
235 $a['iheaders'] = array();
236 $a['iheaders']['Host'] = $a['host'];
237 $a['iheaders']['x-amz-date'] = $a['x-amz-date'];
238
239 $auth = rg_amazon_auth($a);
240 if ($auth['ok'] != 1) {
241 $ret['error'] = $auth['error'];
242 break;
243 }
244
245 $headers = array();
246 if (isset($a['content_type']))
247 $headers[] = 'Content-Type: ' . $a['content_type'];
248 $headers[] = 'Authorization: ' . $auth['data'];
249 foreach ($auth['iheaders'] as $head => $val)
250 $headers[] = $head . ': ' . $val;
251 rg_log_ml('DEBUG: HEADERS:' . print_r($headers, TRUE));
252
253 $ret = rg_amazon_curl($url, $a['method'], $headers,
254 $a['content']);
255 break;
256 }
257
175 258 rg_log_exit(); rg_log_exit();
176 259 rg_prof_end('amazon_req'); rg_prof_end('amazon_req');
177 260 return $ret; return $ret;
 
... ... function rg_amazon_codedeploy_create($a)
237 320 while (1) { while (1) {
238 321 $a['service'] = 'codedeploy'; $a['service'] = 'codedeploy';
239 322 $a['method'] = 'POST'; $a['method'] = 'POST';
240 $a['file'] = '';
241 323 $a['host'] = $a['service'] . '.' . $a['region'] . '.amazonaws.com'; $a['host'] = $a['service'] . '.' . $a['region'] . '.amazonaws.com';
242 324 $a['iheaders'] = array('x-amz-target' => 'CodeDeploy_20141006.CreateDeployment'); $a['iheaders'] = array('x-amz-target' => 'CodeDeploy_20141006.CreateDeployment');
243 325 $a['content'] = $json; $a['content'] = $json;
 
... ... function rg_amazon_lambda_invoke($a)
268 350 while (1) { while (1) {
269 351 $a['service'] = 'lambda'; $a['service'] = 'lambda';
270 352 $a['method'] = 'POST'; $a['method'] = 'POST';
271 $a['file'] = '2015-03-31/functions/' . $a['function']
353 $a['url'] = '/2015-03-31/functions/' . $a['function']
272 354 . '/invocations'; . '/invocations';
273 355 $a['host'] = $a['service'] . '.' . $a['region'] . '.amazonaws.com'; $a['host'] = $a['service'] . '.' . $a['region'] . '.amazonaws.com';
274 356 $a['iheaders'] = array( $a['iheaders'] = array(
275 357 'x-Amz-Client-Context' => '', 'x-Amz-Client-Context' => '',
276 358 'x-Amz-Invocation-Type' => $a['invocation_type'], 'x-Amz-Invocation-Type' => $a['invocation_type'],
277 359 'x-Amz-Log-Type' => 'Tail'); 'x-Amz-Log-Type' => 'Tail');
360 $a['content'] = $a['payload'];
278 361
279 362 $ret = rg_amazon_req($a); $ret = rg_amazon_req($a);
280 363 break; break;
File inc/wh/build.inc.php changed (mode: 100644) (index 8f4c9b7..0f42ec4)
... ... function rg_wh_build_send($db, $event)
123 123 if (strchr($wh['flags'], 'D')) if (strchr($wh['flags'], 'D'))
124 124 continue; continue;
125 125
126 // If the web hook does not contain our type, skip it
127 if (!strchr($wh['idata']['events'], $event['wh_event'])) {
128 rg_log('DEBUG: ' . $event['wh_event']
129 . ' is not present in '
130 . $wh['idata']['events']);
131 continue;
132 }
133
126 134 if (isset($event['ri']['name']) if (isset($event['ri']['name'])
127 135 && !rg_repo_compare_refs($wh['repo'], $event['ri']['name'])) { && !rg_repo_compare_refs($wh['repo'], $event['ri']['name'])) {
128 136 rg_log('hook is not for this repo'); rg_log('hook is not for this repo');
File inc/wh/cloud.inc.php changed (mode: 100644) (index d3fec88..870ed66)
... ... function rg_wh_cloud_send($db, $event)
115 115 if (strchr($wh['flags'], 'D')) if (strchr($wh['flags'], 'D'))
116 116 continue; continue;
117 117
118 // If the web hook does not contain our type, skip it
119 if (!strchr($wh['idata']['events'], $event['wh_event'])) {
120 rg_log('DEBUG: ' . $event['wh_event']
121 . ' is not present in '
122 . $wh['idata']['events']);
123 continue;
124 }
125
118 126 if (!rg_repo_compare_refs($wh['repo'], $event['ri']['name'])) { if (!rg_repo_compare_refs($wh['repo'], $event['ri']['name'])) {
119 127 rg_log('hook is not for this ref'); rg_log('hook is not for this ref');
120 128 continue; continue;
File inc/wh/http.inc.php changed (mode: 100644) (index 90091f1..d6182c3)
... ... function rg_wh_http_send($db, $event)
170 170 if (strchr($wh['flags'], 'D')) if (strchr($wh['flags'], 'D'))
171 171 continue; continue;
172 172
173 // If the web hook does not contain our type, skip it
174 if (!strchr($wh['idata']['events'], $event['wh_event'])) {
175 rg_log('DEBUG: ' . $event['wh_event']
176 . ' is not present in '
177 . $wh['idata']['events']);
178 continue;
179 }
180
173 181 if (isset($event['ri']['name']) if (isset($event['ri']['name'])
174 182 && !rg_wh_repo_match($wh['repo'], $event['ri']['name'])) { && !rg_wh_repo_match($wh['repo'], $event['ri']['name'])) {
175 183 rg_log('hook is not for this repo'); rg_log('hook is not for this repo');
 
... ... function rg_wh_http_send($db, $event)
182 190 continue; continue;
183 191 } }
184 192
185 // If the web hook does not contain our type, skip it
186 if (!strchr($wh['idata']['events'], $event['wh_event'])) {
187 rg_log($event['wh_event'] . ' is not present in '
188 . $wh['idata']['events']);
189 continue;
190 }
191
192 193 if (!isset($wh['idata']['itype'])) { if (!isset($wh['idata']['itype'])) {
193 194 rg_log_ml('wh: ' . print_r($wh, TRUE)); rg_log_ml('wh: ' . print_r($wh, TRUE));
194 195 rg_internal_error('DEBUG: itype is not present'); rg_internal_error('DEBUG: itype is not present');
File inc/wh/lambda.inc.php changed (mode: 100644) (index 8dc3396..0452b33)
... ... function rg_wh_lambda_send_one($db, $event)
49 49 rg_wh_set_last_output($db, $event['ui']['uid'], $wh['id'], rg_wh_set_last_output($db, $event['ui']['uid'], $wh['id'],
50 50 substr($last_output, 0, 4096)); substr($last_output, 0, 4096));
51 51
52 if ($wh['idata']['debug'] == 1)
53 rg_cache_set('DEBUG::' . $event['ui']['uid']
54 . '::webhooks::' . $wh['id'], $last_output,
55 RG_SOCKET_NO_WAIT);
56
52 57 rg_prof_end('wh_lambda_send_one'); rg_prof_end('wh_lambda_send_one');
53 58 return $ret; return $ret;
54 59 } }
 
... ... function rg_wh_lambda_send($db, $event)
77 82 if (strchr($wh['flags'], 'D')) if (strchr($wh['flags'], 'D'))
78 83 continue; continue;
79 84
85 // If the web hook does not contain our type, skip it
86 if (!strchr($wh['idata']['events'], $event['wh_event'])) {
87 rg_log('DEBUG: ' . $event['wh_event']
88 . ' is not present in '
89 . $wh['idata']['events']);
90 continue;
91 }
92
80 93 if (isset($event['ri']['name']) if (isset($event['ri']['name'])
81 94 && !rg_repo_compare_refs($wh['repo'], $event['ri']['name'])) { && !rg_repo_compare_refs($wh['repo'], $event['ri']['name'])) {
82 rg_log('hook is not for this repo');
95 rg_log('DEBUG: hook is not for this repo');
83 96 continue; continue;
84 97 } }
85 98
86 99 if (isset($event['refname']) if (isset($event['refname'])
87 100 && !rg_repo_compare_refs($wh['refname'], $event['refname'])) { && !rg_repo_compare_refs($wh['refname'], $event['refname'])) {
88 rg_log('hook is not for this ref');
101 rg_log('DEBUG: hook is not for this ref');
89 102 continue; continue;
90 103 } }
91 104
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main