File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,12 @@ class Admin
62
62
'specific ' ,
63
63
];
64
64
65
+ private static $ postMethodMap = [
66
+ 'server_reload ' ,
67
+ 'server_shutdown ' ,
68
+ 'close_session ' ,
69
+ ];
70
+
65
71
public static function init (Server $ server )
66
72
{
67
73
$ accepted_process_types = SWOOLE_SERVER_COMMAND_MASTER |
@@ -423,17 +429,25 @@ public static function start(Server $server)
423
429
$ resp ->header ('Access-Control-Allow-Methods ' , 'GET, POST, OPTIONS ' );
424
430
$ resp ->header ('Access-Control-Allow-Headers ' , 'X-ACCESS-TOKEN ' );
425
431
426
- if ($ req ->getMethod () == 'GET ' ) {
432
+ $ method = $ req ->getMethod ();
433
+
434
+ $ cmd = $ path_array ->get (1 )->toString ();
435
+
436
+ if (in_array ($ cmd , self ::$ postMethodMap ) && $ method != 'POST ' ) {
437
+ $ resp ->status (403 );
438
+ $ resp ->end (self ::json ('Bad request method ' , 4003 ));
439
+ return ;
440
+ }
441
+
442
+ if ($ method == 'GET ' ) {
427
443
$ data = $ req ->get ;
428
444
} else {
429
445
$ data = $ req ->post ;
430
446
}
431
447
432
- $ cmd = $ path_array ->get (1 )->toString ();
433
-
434
448
if ($ cmd === 'multi ' ) {
435
449
$ body = json_decode ($ req ->getContent (), true );
436
- if (empty ($ body ) || !is_array ($ body ) || $ req -> getMethod () != 'POST ' ) {
450
+ if (empty ($ body ) || !is_array ($ body ) || $ method != 'POST ' ) {
437
451
goto _bad_process;
438
452
}
439
453
You can’t perform that action at this time.
0 commit comments