Skip to content
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

Signer factory deleted ! #27

Closed
absolux opened this issue Aug 30, 2015 · 2 comments
Closed

Signer factory deleted ! #27

absolux opened this issue Aug 30, 2015 · 2 comments

Comments

@absolux
Copy link

absolux commented Aug 30, 2015

From a closed issue, the Signer Factory was deleted, for security reasons of course, but i think it still useful for signer creation, so instead of

$signer = new Sha256();
$builder = (new Builder())->sign($signer, 'some key');

we can use a factory

$builder->sign(Factory::create('HS256'), "some key");

for example, it can be helpful when we use a configuration variable to store the signer id, like

$signer = Factory::create(config('jwt.algo'));
...
$builder->sign($signer, "key");
@lcobucci
Copy link
Owner

Yeap, I deleted this factory because it turned to be useless (and just increase the complexity of this library). The main idea is that you're able to use any IoC technique to create the objects to build your token.

Of course we can provide easier ways to help this configuration process but I just think that it should be in another package. In this way we might have a ServiceProvider for Pimple/Silex, a bundle for Symfony, a module for Zend Framework, etc.

I personally use the Symfony dependency injection component (apart from the fullstack framework) and map my signer in a service using a configuration file. So is really simple to change from HS256 to RS256.

With that we keep this project following the package design principles, in this case the cohesion ones.

@absolux
Copy link
Author

absolux commented Sep 1, 2015

I am using your package, in a laravel project, and i'll create a ServiceProvider to handle that.

Thank you.

@absolux absolux closed this as completed Sep 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants