Skip to content

Adjust JWK Generate RSA Public Key Format #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2e5281c
Adds ES256 to supported algorithms (#239)
beamerblvd Nov 5, 2019
5f68890
Fixes tests, adds PHP 7.3 (#257)
bshaffer Nov 5, 2019
264e5c7
Whitespace style fix (#255)
Krisell Nov 12, 2019
8228431
Comment typo fix (#253)
stembrain Nov 12, 2019
bc324de
Clearer variable name in README (#229)
glaand Nov 12, 2019
20f3729
Use json_last_error without unnecessary existence check (#263)
Krisell Dec 17, 2019
23192ac
Add php 7.4 to travis (#266)
Feb 11, 2020
ccc74fb
docs: add resource type as 2nd param in decode method (#205)
win0err Feb 19, 2020
ecb25af
tests: update PHPUnit test classes (#193)
bshaffer Feb 19, 2020
78ec50c
docs: fix missed param name (#207)
rtm-ctrlz Feb 19, 2020
4566062
feat: add support for ES256 algorithm (#256)
bshaffer Feb 24, 2020
9eb9f98
fix: added keywords to composer.json (#243) (#271)
NiMeDia Feb 29, 2020
5cd7ae0
remove ignore_bit_strings (#276)
bshaffer Mar 5, 2020
51034b4
test: allow for later versions of phpunit (#277)
phil-davis Mar 16, 2020
b0def5f
feat: adds JWK support (#273)
EricTendian Mar 21, 2020
27ee05f
test: use keys for testing JWK (#283)
bshaffer Mar 21, 2020
3811d69
chore: code cleanup (#278)
phil-davis Mar 23, 2020
feb0e82
chore: fixes cs and adds cs checking to travis (#284)
bshaffer Mar 25, 2020
c4de650
Adjust JWK Generate RSA Public Key Format
albinwong May 18, 2020
1fae8c4
docs: add JWK usage to README (#307)
bshaffer Oct 26, 2020
e3ad034
Merge branch 'master' into master
albinwong Nov 3, 2020
f42c911
fix: add missing use statement in JWK (#303)
pendenga Feb 12, 2021
7b4f4d2
chore: add phpdoc @throws in JWT::decode (#320)
bborrel Mar 5, 2021
099e6af
Merge branch 'master' into master
bshaffer Mar 5, 2021
474047d
chore: remove leading backslashes in imports (#301)
kewlashu Mar 5, 2021
8ddb395
chore: remove travis, add github actions (#331)
bshaffer May 17, 2021
d7cd1db
fix: allow for null d values in RSA JWK (#330)
bshaffer May 17, 2021
06b808e
Merge branch 'master' into master
bshaffer May 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/run-tests.sh export-ignore
18 changes: 18 additions & 0 deletions .github/actions/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh -l

apt-get update && \
apt-get install -y --no-install-recommends \
git \
zip \
curl \
unzip \
wget

curl --silent --show-error https://getcomposer.org/installer | php
php composer.phar self-update

echo "---Installing dependencies ---"
php composer.phar update

echo "---Running unit tests ---"
vendor/bin/phpunit
66 changes: 66 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test Suite
on:
push:
branches:
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0" ]
name: PHP ${{matrix.php }} Unit Test
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 10
max_attempts: 3
command: composer install
- name: Run Script
run: vendor/bin/phpunit

# use dockerfiles for old versions of php (setup-php times out for those).
test_php55:
name: "PHP 5.5 Unit Test"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Unit Tests
uses: docker://php:5.5-cli
with:
entrypoint: ./.github/actions/entrypoint.sh

test_php54:
name: "PHP 5.4 Unit Test"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Unit Tests
uses: docker://php:5.4-cli
with:
entrypoint: ./.github/actions/entrypoint.sh

style:
runs-on: ubuntu-latest
name: PHP Style Check
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.0"
- name: Run Script
run: |
composer require friendsofphp/php-cs-fixer
vendor/bin/php-cs-fixer fix --diff --dry-run .
vendor/bin/php-cs-fixer fix --rules=native_function_invocation --allow-risky=yes --diff src
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Example
use \Firebase\JWT\JWT;

$key = "example_key";
$token = array(
$payload = array(
"iss" => "http://example.org",
"aud" => "http://example.com",
"iat" => 1356999524,
Expand All @@ -36,7 +36,7 @@ $token = array(
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
* for a list of spec-compliant algorithms.
*/
$jwt = JWT::encode($token, $key);
$jwt = JWT::encode($payload, $key);
$decoded = JWT::decode($jwt, $key, array('HS256'));

print_r($decoded);
Expand Down Expand Up @@ -93,14 +93,14 @@ ehde/zUxo6UvS7UrBQIDAQAB
-----END PUBLIC KEY-----
EOD;

$token = array(
$payload = array(
"iss" => "example.org",
"aud" => "example.com",
"iat" => 1356999524,
"nbf" => 1357000000
);

$jwt = JWT::encode($token, $privateKey, 'RS256');
$jwt = JWT::encode($payload, $privateKey, 'RS256');
echo "Encode:\n" . print_r($jwt, true) . "\n";

$decoded = JWT::decode($jwt, $publicKey, array('RS256'));
Expand All @@ -115,6 +115,19 @@ echo "Decode:\n" . print_r($decoded_array, true) . "\n";
?>
```

Using JWKs
----------

```php
// Set of keys. The "keys" key is required. For example, the JSON response to
// this endpoint: https://www.gstatic.com/iap/verify/public_key-jwk
$jwks = ['keys' => []];

// JWK::parseKeySet($jwks) returns an associative array of **kid** to private
// key. Pass this as the second parameter to JWT::decode.
JWT::decode($payload, JWK::parseKeySet($jwks), $supportedAlgorithm);
```

Changelog
---------

Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "firebase/php-jwt",
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
"homepage": "https://github.com/firebase/php-jwt",
"keywords": [
"php",
"jwt"
],
"authors": [
{
"name": "Neuman Vong",
Expand All @@ -24,6 +28,6 @@
}
},
"require-dev": {
"phpunit/phpunit": " 4.8.35"
"phpunit/phpunit": ">=4.8 <=9"
}
}
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
<testsuites>
Expand Down
37 changes: 0 additions & 37 deletions run-tests.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/BeforeValidException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

namespace Firebase\JWT;

class BeforeValidException extends \UnexpectedValueException
{

}
2 changes: 1 addition & 1 deletion src/ExpiredException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

namespace Firebase\JWT;

class ExpiredException extends \UnexpectedValueException
{

}
Loading