Google Authenticator Implementation with PHP
Вставка
- Опубліковано 2 жов 2024
- A basic implementation of the RFC 6238 standards for TOTP: Time-Based One-Time Password Algorithm using PHP for original Key and QR Code generation and the Google Authenticator application for TOTP generation.
More about me:
interactiveuto...
GitHub:
github.com/gil...
Documentation:
www.rfc-editor...
packagist.org/...
packagist.org/...
Great tutorial, thank you very much.
super great tutorial!! 🙂 very clear, you explain things well with enough details to understand everything, thanks for sharing this!
Glad it was helpful!
Question, how can we link that with the google auth application ?
Via a generated QR code
Thank you! Your implementation and explanation in this video worked like a charm.
thanks. is it advisable to store the secret keys in the database? I'm only limited to this option right now.
Not advisable, but many times as states it is the only feasible way
Hello, my web host does not use imagemagick extension but GD2. How can I change the code? thanks
I am guessing this is for the QR code generator. Have you tried a different one? If you got the url to be created that is the important part. Then use that url in your QR generation app of your choice. You can even use a system online (not super safe nor recommended in this case) but you can use it to test your code.
you can modify your code this way:
- comment or remove this line: use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
- add this line instead (or below the previous one): use BaconQrCode\Renderer\Image\SvgImageBackEnd;
this will load the Svg library instead of the Imagick one, which doesn't require Imagick or GD, and will generate a .svg image, which is lighter and more high-density pixels screens friendly.
- this portion of code:
$renderer = new ImageRenderer(
new RendererStyle(250),
new ImagickImageBackEnd()
);
becomes:
$renderer = new ImageRenderer(
new RendererStyle(250),
new SvgImageBackEnd()
);
- then change the file name from .png to .svg
- the tag becomes:
Thanks for the help!
thanks i love you
Glad it helped