Page MenuHomeDevCentral

No OneTemporary

diff --git a/app/Http/Controllers/Gate/DockerHubGateController.php b/app/Http/Controllers/Gate/DockerHubGateController.php
index 61e6e22..a876cef 100644
--- a/app/Http/Controllers/Gate/DockerHubGateController.php
+++ b/app/Http/Controllers/Gate/DockerHubGateController.php
@@ -1,88 +1,88 @@
<?php
namespace Nasqueron\Notifications\Http\Controllers\Gate;
use Nasqueron\Notifications\Events\DockerHubPayloadEvent;
use Symfony\Component\HttpFoundation\Response;
use Event;
use Request;
class DockerHubGateController extends GateController {
///
/// Private members
///
/**
* The request content, as a structured data
*
* @var \stdClass
*/
private $payload;
/**
* The request content
*
* @var string
*/
private $rawRequestContent;
///
/// Constants
///
/**
* The name of the service this gate accepts payload from.
*/
const SERVICE_NAME = 'DockerHub';
///
/// Request processing
///
/**
* Handles POST requests
*
- * @param Request $request the HTTP request
+ * @param string $door The door, matching the project for this payload
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost ($door) : Response {
+ public function onPost (string $door) : Response {
// Parses the request and check if it's legit
$this->door = $door;
$this->extractPayload();
// Process the request
$this->logRequest();
$this->onPayload();
// Output
return parent::renderReport();
}
/**
* Extracts payload from the request
*/
- protected function extractPayload () {
+ protected function extractPayload () : void {
$request = Request::instance();
$this->rawRequestContent = $request->getContent();
$this->payload = json_decode($this->rawRequestContent);
}
///
/// Payload processing
///
- protected function onPayload () {
+ protected function onPayload () : void {
$this->initializeReport();
Event::fire(new DockerHubPayloadEvent(
$this->door,
$this->payload
));
}
}
diff --git a/app/Http/Controllers/Gate/GitHubGateController.php b/app/Http/Controllers/Gate/GitHubGateController.php
index 4b1ee0b..acc559e 100644
--- a/app/Http/Controllers/Gate/GitHubGateController.php
+++ b/app/Http/Controllers/Gate/GitHubGateController.php
@@ -1,194 +1,194 @@
<?php
namespace Nasqueron\Notifications\Http\Controllers\Gate;
use Nasqueron\Notifications\Events\GitHubPayloadEvent;
use Keruald\GitHub\XHubSignature;
use Symfony\Component\HttpFoundation\Response;
use Event;
use Request;
class GitHubGateController extends GateController {
///
/// Private members
///
/**
* The request signature, allowing to determine if the payload is legit
*
* @var string
*/
private $signature;
/**
* The GitHub event triggering this request
*
* @var string
*/
private $event;
/**
* The request delivery GUID
*
* @var string
*/
private $delivery;
/**
* The request content, as a structured data
*
* @var \stdClass
*/
private $payload;
/**
* The request content
*
* @var string
*/
private $rawRequestContent;
///
/// Constants
///
/**
* The name of the service this gate accepts payload from.
*/
const SERVICE_NAME = 'GitHub';
///
/// Request processing
///
/**
* Handles POST requests
*
- * @param Request $request the HTTP request
+ * @param string $door The door, matching the project for this payload
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost ($door) : Response {
+ public function onPost (string $door) : Response {
// Parses the request and check if it's legit
$this->door = $door;
$this->extractHeaders();
$this->extractPayload();
if (!$this->isLegitRequest()) {
abort(403, 'Unauthorized action.');
}
if (!$this->isValidRequest()) {
abort(400, 'Bad request.');
}
// Process the request
$this->logGateRequest();
$this->onPayload();
// Output
return parent::renderReport();
}
/**
* Extracts headers from the request
*/
- protected function extractHeaders () {
+ protected function extractHeaders () : void {
$this->signature = $this->getSignature();
$this->event = Request::header('X-Github-Event');
$this->delivery = Request::header('X-Github-Delivery');
}
/**
* Gets the signature from an X-Hub-Signature header
*
- * @param string the signature part of the header
+ * @return string The signature part of the header
*/
- private function getSignature () {
+ private function getSignature () : string {
$headerSignature = Request::header('X-Hub-Signature');
return XHubSignature::parseSignature($headerSignature);
}
/**
* Extracts payload from the request
*/
- protected function extractPayload () {
+ protected function extractPayload () : void {
$request = Request::instance();
$this->rawRequestContent = $request->getContent();
$this->payload = json_decode($this->rawRequestContent);
}
/**
* Determines if the request is valid, ie contains the mandatory headers
* and a payload.
*
* @return bool true if the request looks valid; otherwise, false.
*/
- protected function isValidRequest () {
+ protected function isValidRequest () : bool {
if (empty($this->event)) {
return false;
}
if (empty($this->delivery)) {
return false;
}
if (empty($this->payload) || !is_object($this->payload)) {
return false;
}
return true;
}
/**
* Determines if the request is legit.
*
* @return bool true if the request looks legit; otherwise, false.
*/
- protected function isLegitRequest () {
+ protected function isLegitRequest () : bool {
$secret = $this->getSecret();
// If the secret is not defined, request legitimation is bypassed
if (empty($secret)) {
return true;
}
// If the secret is defined, but signature is missing from the
// request, we don't need to perform any other validation.
if (empty($this->signature)) {
return false;
}
return XHubSignature::validatePayload(
$secret,
$this->rawRequestContent,
$this->signature
);
}
/**
* Logs the request
*/
protected function logGateRequest () {
$this->logRequest([
'delivery' => $this->delivery,
'event' => $this->event,
]);
}
///
/// Payload processing
///
protected function onPayload () {
$this->initializeReport();
Event::fire(new GitHubPayloadEvent(
$this->door,
$this->event,
$this->payload
));
}
}
diff --git a/app/Http/Controllers/Gate/JenkinsGateController.php b/app/Http/Controllers/Gate/JenkinsGateController.php
index 596566a..c17205a 100644
--- a/app/Http/Controllers/Gate/JenkinsGateController.php
+++ b/app/Http/Controllers/Gate/JenkinsGateController.php
@@ -1,88 +1,88 @@
<?php
namespace Nasqueron\Notifications\Http\Controllers\Gate;
use Nasqueron\Notifications\Events\JenkinsPayloadEvent;
use Symfony\Component\HttpFoundation\Response;
use Event;
use Request;
class JenkinsGateController extends GateController {
///
/// Private members
///
/**
* The request content, as a structured data
*
* @var \stdClass
*/
private $payload;
/**
* The request content
*
* @var string
*/
private $rawRequestContent;
///
/// Constants
///
/**
* The name of the service this gate accepts payload from.
*/
const SERVICE_NAME = 'Jenkins';
///
/// Request processing
///
/**
* Handles POST requests
*
- * @param Request $request the HTTP request
+ * @param string $door The door, matching the project for this payload
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost ($door) : Response {
+ public function onPost (string $door) : Response {
// Parses the request and check if it's legit
$this->door = $door;
$this->extractPayload();
// Process the request
$this->logRequest();
$this->onPayload();
// Output
return parent::renderReport();
}
/**
* Extracts payload from the request
*/
protected function extractPayload () {
$request = Request::instance();
$this->rawRequestContent = $request->getContent();
$this->payload = json_decode($this->rawRequestContent);
}
///
/// Payload processing
///
protected function onPayload () {
$this->initializeReport();
Event::fire(new JenkinsPayloadEvent(
$this->door,
$this->payload
));
}
}
diff --git a/app/Http/Controllers/Gate/PhabricatorGateController.php b/app/Http/Controllers/Gate/PhabricatorGateController.php
index d69a25a..76368dc 100644
--- a/app/Http/Controllers/Gate/PhabricatorGateController.php
+++ b/app/Http/Controllers/Gate/PhabricatorGateController.php
@@ -1,78 +1,78 @@
<?php
namespace Nasqueron\Notifications\Http\Controllers\Gate;
use Nasqueron\Notifications\Events\PhabricatorPayloadEvent;
use Symfony\Component\HttpFoundation\Response;
use Event;
use Request;
class PhabricatorGateController extends GateController {
///
/// Private members
///
/**
* The request content, as a structured data
*
* @var array
*/
private $payload;
///
/// Constants
///
/**
* The name of the service this gate accepts payload from.
*/
const SERVICE_NAME = 'Phabricator';
///
/// Requests processing
///
/**
* Handles POST requests
*
- * @param Request $request the HTTP request
+ * @param string $door The door, matching the project for this payload
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost ($door) : Response {
+ public function onPost (string $door) : Response {
$this->door = $door;
if (!$this->doesServiceExist()) {
abort(404, 'Unknown Phabricator instance.');
}
$this->extractPayload();
$this->logRequest();
$this->onPayload();
return parent::renderReport();
}
/**
* Extracts payload from the request
*/
- protected function extractPayload () {
+ protected function extractPayload () : void {
$this->payload = Request::all();
}
///
/// Payload processing
///
- protected function onPayload () {
+ protected function onPayload () : void {
$this->initializeReport();
Event::fire(new PhabricatorPayloadEvent(
$this->door,
$this->payload
));
}
}
diff --git a/composer.json b/composer.json
index a7fbd88..6d7fe24 100644
--- a/composer.json
+++ b/composer.json
@@ -1,57 +1,57 @@
{
"name": "nasqueron/notifications",
"description": "Nasqueron notifications center",
"keywords": [
"nasqueron",
"activemq",
"AMQP",
"notifications"
],
"license": "BSD-2-Clause",
"type": "project",
"require": {
"php": ">=7.1.0",
"laravel/framework": "5.2.*",
"guzzlehttp/guzzle": "^6.2",
"keruald/dockerhub": "^0.0.3",
- "keruald/github": "^0.2.0",
+ "keruald/github": "^0.2.1",
"keruald/broker": "^0.4.1",
"keruald/mailgun": "^0.0.1",
"netresearch/jsonmapper": "~0.1.0",
"sentry/sentry": "^0.13.0"
},
"require-dev": {
"etsy/phan": "dev-master",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpmd/phpmd" : "@stable",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"squizlabs/php_codesniffer": "2.*",
"symfony/css-selector": "~3.0",
"symfony/dom-crawler": "~3.0"
},
"autoload": {
"psr-4": {
"Nasqueron\\Notifications\\": "app/",
"Nasqueron\\Notifications\\Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"phpmd": [
"vendor/bin/phpmd app/ xml ruleset.xml"
],
"test": [
"phpunit --no-coverage"
]
},
"config": {
"preferred-install": "dist"
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Nov 24, 23:59 (12 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2259234
Default Alt Text
(13 KB)

Event Timeline