magiclabs / magic-admin-php

Magic admin PHP SDK makes it easy to leverage Decentralized ID tokens to protect routes and restricted resources for your application.
https://docs.magic.link/admin-sdk/php
MIT License
19 stars 5 forks source link

Add support for runtimes without gmp #8

Closed brianrlewis closed 3 years ago

brianrlewis commented 3 years ago

📦 Pull Request

This pull implements an alternate ecRecover process internally as opposed to using digitaldonkey/ecverify. This is due to the reasons described in this issue. In summary this pull will allow this package to support runtimes that do not have the gmp extension installed as long as the bcmath extension is installed.

No new functionality has been introduced.

One thing to note is that although calls to $magic->token->validate() will work without gmp as long as bcmath is installed, there is a significant performance difference between the two. This is why the simplito/bigint-wrapper-php sub-dependency is designed to work with gmp first and bcmath as a fallback.

On average calls to $magic->token->validate() took about 17ms with gmp versus 320ms with bcmath. In apps where validate is being called on every request this may be a showstopper for some users.

Users should be encouraged to install gmp whenever possible, but also made aware that the package will work with bcmath as an alternative. Currently there are various hosting platforms that do not support gmp, like Laravel Vapor for example.

🗜 Versioning

(Check one!)

FYJen commented 3 years ago

On average calls to $magic->token->validate() took about 17ms with gmp versus 320ms with bcmath. In apps where validate is being called on every request this may be a showstopper for some users.

Thank you for sharing it!

Users should be encouraged to install gmp whenever possible, but also made aware that the package will work with bcmath as an alternative. Currently there are various hosting platforms that do not support gmp, like Laravel Vapor for example.

Agreed. Wondering if we should update https://github.com/magiclabs/magic-admin-php#dependencies section to reflect that.

brianrlewis commented 3 years ago

Users should be encouraged to install gmp whenever possible, but also made aware that the package will work with bcmath as an alternative. Currently there are various hosting platforms that do not support gmp, like Laravel Vapor for example.

Agreed. Wondering if we should update https://github.com/magiclabs/magic-admin-php#dependencies section to reflect that.

Yes, that is a good idea. I just pushed an update to the readme.