Skip to content

Conversation

@Spomky
Copy link
Member

@Spomky Spomky commented Jul 6, 2019

Q A
Branch? v2.1
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets none
License MIT

This new package adds tools to easily create and load JWS or JWE.
Example:

<?php

require_once('vendor/autoload.php'):

use Webauthn\Easy\Build;
use Webauthn\Easy\Load;

$time = time(); //Current time
$jwe = Build::jwe() //We want to build a JWE
    ->exp($time + 3600) //Some claims and header parameters
    ->iat($time)
    ->nbf($time)
    ->jti('0123456789', true)
    ->iss('issuer')
    ->aud('audience1')
    ->aud('audience2')
    ->sub('subject')
    ->alg('RSA-OAEP-256') // Key encryption algorithm
    ->enc('A256GCM') // Content encryption algorithm
    ->encrypt(/*Your JWK here*/) // The recipient public key
;

$jwt = Load::jwe($jwe) // We want to decrypt a JWE
    ->algs(['RSA-OAEP', 'RSA-OAEP-256']) // The allowed key encryption algorithm
    ->encs(['A128GCM', 'A256GCM']) // The allowed content encryption algorithm
    ->exp() // Some claims and header parameters we want to check
    ->iat()
    ->nbf()
    ->aud('audience1')
    ->iss('issuer')
    ->sub('subject')
    ->key(/*Your JWK here*/) // The recipient private key
    ->run() // Go!
;
  • JWS
    • Builder
    • Loader
  • JWE
    • Builder
    • Loader

To be fixed:

  • This package shall not require all algorithms but be able to load them when available
  • Tests shall cover common use cases

Spomky added 2 commits July 5, 2019 17:57
New builder to ease the use of this project.
Offers a simple and fluent way to create, load, verify and decrypt tokens

Example:

```php
$jws = Build::jws()
    ->exp(time() + 3600)
    ->iat(time())
    ->nbf(time())
    ->jti('0123456789', true)
    ->alg('RS512')
    ->sign($this->rsaKey())
```
@coveralls
Copy link

coveralls commented Jul 6, 2019

Coverage Status

Coverage decreased (-2.6%) to 73.548% when pulling 6e85a12 on Easy into 7ab2d1a on v2.1.

@Spomky Spomky added this to the v2.1 milestone Jul 8, 2019
@Spomky Spomky changed the title Easy Toolset [WIP] Easy Toolset Jul 10, 2019
@Spomky Spomky merged commit 4a49056 into v2.1 Oct 31, 2019
@Spomky Spomky deleted the Easy branch October 31, 2019 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants