-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
286 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ composer.lock | |
.cache | ||
.docs | ||
.gitmodules | ||
.phpunit.result.cache | ||
|
||
# IntelliJ | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Google\Auth\Jwt; | ||
|
||
use Firebase\JWT\JWT; | ||
use Firebase\JWT\JWK; | ||
|
||
class FirebaseJwtClient implements JwtClientInterface | ||
{ | ||
private $jwt; | ||
private $jwk; | ||
|
||
public function __construct(JWT $jwt, JWK $jwk) | ||
{ | ||
$this->jwt = $jwt; | ||
$this->jwk = $jwk; | ||
} | ||
|
||
public function encode( | ||
array $payload, | ||
string $signingKey, | ||
string $signingAlg, | ||
string $keyId | ||
): string { | ||
return $this->jwt->encode($payload, $signingKey, $signingAlg, $keyId); | ||
} | ||
|
||
public function decode(string $jwt, array $keys, array $allowedAlgs): array | ||
{ | ||
return (array) $this->jwt->decode($jwt, $keys, $allowedAlgs); | ||
} | ||
|
||
public function parseKeySet(array $keySet): array | ||
{ | ||
return $this->jwk->parseKeySet($keySet); | ||
} | ||
} |
23 changes: 18 additions & 5 deletions
23
src/HttpHandler/Guzzle7HttpHandler.php → src/Auth/Jwt/JwtClientInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
<?php | ||
/** | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
namespace Google\Auth\HttpHandler; | ||
|
||
class Guzzle7HttpHandler extends Guzzle6HttpHandler | ||
declare(strict_types=1); | ||
|
||
namespace Google\Auth\Jwt; | ||
|
||
interface JwtClientInterface | ||
{ | ||
} | ||
public function encode( | ||
array $payload, | ||
string $signingKey, | ||
string $signingAlg, | ||
string $keyId | ||
): string; | ||
|
||
public function decode(string $jwt, array $keys, array $allowedAlgs): array; | ||
|
||
public function parseKeySet(array $keySey): array; | ||
} |
Oops, something went wrong.