Page MenuHomePhabricator

D624.id1986.diff
No OneTemporary

D624.id1986.diff

diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -18,6 +18,7 @@
"require": {
"magic3w/url-reflection": "dev-master",
- "spitfire/request": "dev-master"
+ "spitfire/request": "^0.1.1",
+ "lcobucci/jwt": "^3.4"
}
}
diff --git a/composer.lock b/composer.lock
--- a/composer.lock
+++ b/composer.lock
@@ -4,19 +4,97 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "997205af2fab313d28388c068c3706de",
+ "content-hash": "7d11b0dfbe31a4b196528f7f695d700b",
"packages": [
+ {
+ "name": "lcobucci/jwt",
+ "version": "3.4.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/lcobucci/jwt.git",
+ "reference": "511629a54465e89a31d3d7e4cf0935feab8b14c1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/lcobucci/jwt/zipball/511629a54465e89a31d3d7e4cf0935feab8b14c1",
+ "reference": "511629a54465e89a31d3d7e4cf0935feab8b14c1",
+ "shasum": ""
+ },
+ "require": {
+ "ext-mbstring": "*",
+ "ext-openssl": "*",
+ "php": "^5.6 || ^7.0"
+ },
+ "require-dev": {
+ "mikey179/vfsstream": "~1.5",
+ "phpmd/phpmd": "~2.2",
+ "phpunit/php-invoker": "~1.1",
+ "phpunit/phpunit": "^5.7 || ^7.3",
+ "squizlabs/php_codesniffer": "~2.3"
+ },
+ "suggest": {
+ "lcobucci/clock": "*"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.1-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Lcobucci\\JWT\\": "src"
+ },
+ "files": [
+ "compat/class-aliases.php",
+ "compat/json-exception-polyfill.php",
+ "compat/lcobucci-clock-polyfill.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Luís Otávio Cobucci Oblonczyk",
+ "email": "lcobucci@gmail.com",
+ "role": "Developer"
+ }
+ ],
+ "description": "A simple library to work with JSON Web Token and JSON Web Signature",
+ "keywords": [
+ "JWS",
+ "jwt"
+ ],
+ "support": {
+ "issues": "https://github.com/lcobucci/jwt/issues",
+ "source": "https://github.com/lcobucci/jwt/tree/3.4.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/lcobucci",
+ "type": "github"
+ },
+ {
+ "url": "https://www.patreon.com/lcobucci",
+ "type": "patreon"
+ }
+ ],
+ "time": "2021-02-16T09:40:01+00:00"
+ },
{
"name": "magic3w/url-reflection",
- "version": "v0.1.0",
+ "version": "dev-master",
"source": {
"type": "git",
"url": "https://phabricator.magic3w.com/source/url-reflection.git",
- "reference": "23bcb67767893f9225befba28cfc3aba30bf1b43"
+ "reference": "341d1ede12d28159101b77c8ae12b544dba15a8c"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
+ "default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
@@ -34,18 +112,18 @@
}
],
"description": "Allows applications to have a URL parsed and retrieve information about it's components",
- "time": "2020-09-11T13:26:04+00:00"
+ "time": "2021-02-11T13:17:34+00:00"
},
{
"name": "spitfire/request",
- "version": "v0.1.0",
+ "version": "v0.1.1",
"source": {
"type": "git",
- "url": "https://phabricator.magic3w.com/source/spitifire-request.git",
- "reference": "d3b3801273b7d65f42e974834a0658d9255caacd"
+ "url": "https://phabricator.magic3w.com/source/spitfire-request.git",
+ "reference": "0e8166d802e0e71dd12365bca0215043c9df37d2"
},
"require": {
- "magic3w/url-reflection": "^0.1.0"
+ "magic3w/url-reflection": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "^9.4"
@@ -67,13 +145,15 @@
}
],
"description": "Spitfire request mechanism",
- "time": "2020-10-15T16:00:20+00:00"
+ "time": "2021-01-21T07:59:55+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
- "stability-flags": [],
+ "stability-flags": {
+ "magic3w/url-reflection": 20
+ },
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
diff --git a/src/SSO.php b/src/SSO.php
--- a/src/SSO.php
+++ b/src/SSO.php
@@ -2,6 +2,9 @@
use CURLFile;
use Exception;
+use Lcobucci\JWT\Configuration;
+use Lcobucci\JWT\Signer\Hmac\Sha256;
+use Lcobucci\JWT\Signer\Key\InMemory;
Use spitfire\io\request\Request;
use magic3w\http\url\reflection\URLReflection;
@@ -12,6 +15,8 @@
private $appId;
private $appSecret;
+ private $jwt;
+
public function __construct($credentials) {
$reflection = URLReflection::fromURL($credentials);
@@ -22,6 +27,8 @@
if (!$this->appSecret) {
throw new Exception('App Secret is missing', 1807021658);
}
+
+ $this->jwt = Configuration::forSymmetricSigner(new Sha256, InMemory::base64Encoded($this->appSecret));
}
/**
@@ -63,7 +70,8 @@
* This mechanism intends to make it simple for the applications to generate new tokens
* for the first scenario, by providing a code and a verifier to the table.
*/
- public function token($code, $verifier, $audience = null) {
+ public function token($code, $verifier, $audience = null)
+ {
$request = URLReflection::fromURL(sprintf('%s/token/create.json', $this->endpoint));
$request->post('code', $code);
$request->post('type', 'code');
@@ -74,7 +82,7 @@
$response = $request->send()->expect(200)->json();
return [
- 'access' => new Token($this, $response->tokens->access->token, $response->tokens->access->expires),
+ 'access' => new Token($this, $this->jwt->parser()->parse($response->tokens->access->token), $response->tokens->access->expires),
'refresh' => new RefreshToken($this, $response->tokens->refresh->token, $response->tokens->refresh->expires)
];
}
diff --git a/src/Token.php b/src/Token.php
--- a/src/Token.php
+++ b/src/Token.php
@@ -9,7 +9,7 @@
private $token;
private $expires;
- public function __construct($sso, $token, $expires) {
+ public function __construct($sso, \Lcobucci\JWT\Token $token, $expires) {
$this->sso = $sso;
$this->token = $token;
$this->expires = $expires;
@@ -35,4 +35,9 @@
public function isAuthenticated() {
return $this->getTokenInfo()->authenticated;
}
+
+ public function audience()
+ {
+
+ }
}

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 13, 3:32 AM (4 w, 12 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6003
Default Alt Text
D624.id1986.diff (7 KB)

Event Timeline