Giter Club home page Giter Club logo

jose-bundle's Introduction

Jose Bundle

Help me out for a couple of 🍻!

Beerpay Beerpay


⚠️⚠️⚠️

We highly recommend you to use the new JWT Framework project instead of this bundle.

  • Active support of this bundle is provided until end of 2018.
  • Security support will be provided from 2019 and up to end of 2020.

A migration guide will be/is available in the documentation of the new project.

⚠️⚠️⚠️

Scrutinizer Code Quality Build Status

HHVM Status PHP 7 ready

SensioLabsInsight

Latest Stable Version Total Downloads Latest Unstable Version License

This Symfony bundle provides services to create, load, verify or decrypt JWT. It uses spomky-Labs/jose to ease encryption/decryption and signature/verification of JWS and JWE.

The Release Process

The release process is described here.

Prerequisites

This library needs at least:

  • PHP 5.6+
  • Symfony 2.7+ or Symfony 3.0+

Continuous Integration

It has been successfully tested using PHP 5.6, PHP 7 and HHVM.

We also track bugs and code quality using Scrutinizer-CI and Sensio Insight.

Coding Standards are verified by StyleCI.

Code coverage is not performed. We rely on tests performed on the library and we only have implemented Behavior driven development (BDD) to test this bundle.

Installation

The preferred way to install this library is to rely on Composer:

composer require spomky-labs/jose-bundle

Then, add the bundle into your kernel:

<?php

use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ...
            new SpomkyLabs\JoseBundle\SpomkyLabsJoseBundle(),
        ];

        return $bundles;
    }
}

Configuration

This bundle needs to be configured. Please see this page to know how to configure it.

How to use

Have a look at this page to know hot to configure and use this bundle.

Bundle Integration

This bundle provides a Configuration Helper. This helper provides an easy way to create all services through the configuration of another bundle.

Please read this page to know how to easily configure the bundle from another bundle.

Contributing

Requests for new features, bug fixed and all other ideas to make this library useful are welcome. The best contribution you could provide is by fixing the opened issues where help is wanted

Please make sure to follow these best practices.

Licence

This software is release under MIT licence.

jose-bundle's People

Contributors

spomky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

hyperunknown

jose-bundle's Issues

Add Cache Warmer Service

When the key sets are used for the first time, the keys are generated and, depending on the configuration, this step may take a long time.
By adding a service with the tag kernel.cache_warmer, the key sets could be created during the cache warmup (bin/console cache:warmup).

Documentation

The documentation of this bundle has to be written.

Add a JWK Source that allows random keys to be created

A new JWK Source that allows random keys to be created should be added.
This source should generate oct, RSA, EC or OKP keys depending on parameters (key size, curve...) and additional parameters.
The kid should be a random string.
The key should be stored in a file and have a TTL for key rotation.
This source should also be able to create definitions for both public and private keys (if needed).

Add a DataCollector and a template to show recommendations on the debug toolbar

Depending on the application environment, some optimizations may be available and developers should be warned.

For example, the

  • AxxxGCMKW algorithm is used but the application runs on PHP 7.0 without the libCrypto.
  • the OpenSSL EC keys are not supported and the library uses the pure PHP fallback which is not efficient.

A DataCollector and a template could be added to display some information to the developer on the debug toolbar.

Rotatable Key Sets

Like Rotatable Keys, Rotatable Key Sets should be added.
These key sets will contain keys that are updated and swapped when needed.

For example the set contains keys 1, 2 and 3.
After a period of time TTL:

  • the key 3 is erased,
  • the key 2 becomes 3,
  • the key 1 becomes 2,
  • a new key is generated for key 1.

This way, keys are available during the period TTL * nb of keys in the set.

This feature will help to solve https://github.com/Spomky-Labs/oauth2-server-library/issues/97 or Spomky-Labs/lexik-jose-bridge#13

Shared JWKSet

Add an option to share any JWKSet through a controller.
The controller should be a service. Developers will just have to create a route to allow the JWKSet to be retrieved by clients.

Can't configure JKU cache

I'm following the From a JKU (JSON Wek Key URL) instructions to set up a cache as follows:

jose:
  key_sets:
    azure:
      jku:
          url: "https://login.microsoftonline.com/common/discovery/keys"
          is_secured: true
          cache: 'cache.app' # Issue with cache config option
          cache_ttl: 300

But am getting the following error:

TypeError: Argument 3 passed to Jose\Factory\JWKFactory::createFromJKU() must implement 
interface Psr\Cache\CacheItemPoolInterface or be null, string given

It looks like the literal string cache.app is being passed through instead of the object from the container.

Configuration Helper Enhancement

At the moment the configuration helper only provides low level methods that return an array to be added to the jose configuration by the developers:

public function prepend(ContainerBuilder $container)
{
    $bundles = $container->getParameter('kernel.bundles');
    Assertion::keyExists($bundles, 'SpomkyLabsJoseBundle', 'The "Spomky-Labs/JoseBundle" must be enabled.');

    $jose_config = current($container->getExtensionConfig('jose'));
    $bundle_config = current($container->getExtensionConfig($this->getAlias()));

    $config = ConfigurationHelper::getSignerConfiguration($this->getAlias(), [$bundle_config['signature_algorithm']]);
    $jose_config['signers'] = array_merge(
        $jose_config['signers'],
        $config['jose']['signers']
    );

    $container->prependExtensionConfig('jose', $jose_config);
}

That is too complicated for devs. A better solution could be to have something like that to do:

public function prepend(ContainerBuilder $container)
{
    ConfigurationHelper::addSigner($container, 'service_name', ['list of algorithms']);
}

The configuration helper will automatically verify if the JoseBundle is enabled or not and will inject the desired configuration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.