SlideShare a Scribd company logo
Two-factor
Authentication
With Laravel and Google Authenticator
Allan Denot
How it works
adenot@gmail.com
Login
**************
Submit
461785
Login
Submit
Two-factor Enabled
How it works
MyApp
adenot@gmail.com
Secret key is
randomly generated
QR code is
generated from
secret key and
other info
User scans QR code
using Google
Authenticator
It starts generating
time based codes or
tokens
Enabling two-factor
372631
7JASV4C4F74ZLAR6
How it works
Verifying code
372631
Login
Submit
Two-factor Enabled
+ = 372631 ?
372631
7JASV4C4F74ZLAR6
Implementation and
Demo
Installing
composer require pragmarx/google2fa
More information at: https://github.
com/antonioribeiro/google2fa
Routes
// Generates secret key and QR image
Route::get('user/twoFactor/secret', 'UserController@twoFactorSecret');
// Enables two-factor at user profile
Route::get('user/twoFactor/enable', 'UserController@twoFactorEnable'); // code, secret
// Verify a two-factor code
Route::get('user/twoFactor/verify', 'UserController@twoFactorVerify'); // code
{
"two_factor_secret": "3UYJJUQO6O72SJJW",
"two_factor_qr": "https://chart.googleapis.com/chart?
chs=200x200&chld=M|0&cht=qr&chl=otpauth%3A%2F%2Ftotp%2FSpikeNode%3Aadenot%
40gmail.com%3Fsecret%3D7JASV4C4F74ZLAR6%26issuer%3DSpikeNode"
}
Generating Secret and QR
/api/user/twoFactor/secret
Enabling two-factor
/api/user/twoFactor/enable?secret=3UYJJUQO6O72SJJW&code=733005
Verifying
/api/user/twoFactor/verify?code=733005
Verify window
// Default window is 4
$valid = Google2FA::verifyKey($secret, $code);
// Setting to 0
$valid = Google2FA::verifyKey($secret, $code, 0);
Alternatives
Auth as a service
https://www.authy.com/
https://auth0.com/
References
Google2FA: https://github.com/antonioribeiro/google2fa
Authy: https://www.authy.com/
Auth0: https://auth0.com/
allandenot.com
adenot@gmail.com

More Related Content

PDF
Efficient Kubernetes scaling using Karpenter
PDF
Journey to the Cloud with Red Hat
PDF
PDF
Orchestration Patterns for Microservices with Messaging by RabbitMQ
PDF
Version Control & Git
PDF
SOLID Design Principles applied in Java
PPTX
Api types
PDF
Understanding Monorepos
Efficient Kubernetes scaling using Karpenter
Journey to the Cloud with Red Hat
Orchestration Patterns for Microservices with Messaging by RabbitMQ
Version Control & Git
SOLID Design Principles applied in Java
Api types
Understanding Monorepos

What's hot (20)

PDF
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
PDF
Introduction to TDD and BDD
PDF
From framework coupled code to #microservices through #DDD /by @codelytv
PPTX
Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...
PDF
gRPC with java
PDF
Gitlab CI : Integration et Déploiement Continue
PDF
An Introduction to Rancher
PDF
Kubernetes Introduction
PPTX
Domain Driven Design in Rails
PDF
Building High Performance APIs In Go Using gRPC And Protocol Buffers
PDF
Docker Registry V2
PDF
Réussir la Construction du cahier des charges de son site web WordPress
PPT
Apache Ant
PPTX
Troubleshooting common oslo.messaging and RabbitMQ issues
PDF
Istio presentation jhug
PPTX
Ventajas y Desventajas de Apache y IIS
PDF
KubeConEU - NATS Deep Dive
PDF
OpenShift Overview
PDF
Intro to git and git hub
PPTX
Flusso Continuous Integration & Continuous Delivery
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
Introduction to TDD and BDD
From framework coupled code to #microservices through #DDD /by @codelytv
Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...
gRPC with java
Gitlab CI : Integration et Déploiement Continue
An Introduction to Rancher
Kubernetes Introduction
Domain Driven Design in Rails
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Docker Registry V2
Réussir la Construction du cahier des charges de son site web WordPress
Apache Ant
Troubleshooting common oslo.messaging and RabbitMQ issues
Istio presentation jhug
Ventajas y Desventajas de Apache y IIS
KubeConEU - NATS Deep Dive
OpenShift Overview
Intro to git and git hub
Flusso Continuous Integration & Continuous Delivery
Ad

Viewers also liked (20)

PDF
Ansible with AWS
PDF
Two-factor Authentication
PPTX
2FA Protocol Presentation
PPT
9 password security
DOC
4 dezv-prenat-ii 2013
PDF
SCREAM-15: Authentication and Authorization Considerations for a Multi-tenant...
PDF
Security Authentication and Authorization Service (AAS) for IBM InfoSphere St...
PDF
The Back to School Smartphone Guide
PDF
Two Factor Authentication and You
PPTX
captcha as a graphical password
PDF
Two-factor Authentication
PDF
3 Ways to Protect the Data in Your Apple Account
PPTX
REST Service Authetication with TLS & JWTs
PPTX
Graphical password authentication system with association of sound
DOC
Seminar report on captcha
PDF
Tomasz Janczuk - Webtaskalifragilistexpialidocious
PPTX
Security models for security architecture
PPT
graphical password authentication
PDF
3D Password PPT
PPTX
NIST CyberSecurity Framework: An Overview
Ansible with AWS
Two-factor Authentication
2FA Protocol Presentation
9 password security
4 dezv-prenat-ii 2013
SCREAM-15: Authentication and Authorization Considerations for a Multi-tenant...
Security Authentication and Authorization Service (AAS) for IBM InfoSphere St...
The Back to School Smartphone Guide
Two Factor Authentication and You
captcha as a graphical password
Two-factor Authentication
3 Ways to Protect the Data in Your Apple Account
REST Service Authetication with TLS & JWTs
Graphical password authentication system with association of sound
Seminar report on captcha
Tomasz Janczuk - Webtaskalifragilistexpialidocious
Security models for security architecture
graphical password authentication
3D Password PPT
NIST CyberSecurity Framework: An Overview
Ad

Similar to Two factor authentication with Laravel and Google Authenticator (20)

PDF
Easy logins for JavaScript web applications
PDF
Killing Passwords with JavaScript
PDF
Hybrid Tips & Tricks
PDF
Easy logins for Ruby web applications
PDF
Securing the Web without site-specific passwords
PDF
WebAuthn and Security Keys
PDF
Fun With Spring Security
PDF
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...
PDF
Webauthn Tutorial
PDF
Serverless Angular, Material, Firebase and Google Cloud applications
PPTX
U2F/FIDO2 implementation of YubiKey
PDF
Cross-Platform Authentication with Google+ Sign-In
PPTX
Drive chrome(headless) with puppeteer
PPTX
Relational Database Access with Python
PPTX
Up and Running with Angular
PPTX
Docker on openstack by OpenSource Consulting
PPT
Nagios Conference 2013 - Troy Lea - Leveraging and Understanding Performance ...
PDF
Configuring kerberos based sso in weblogic
KEY
FLAR Workflow
PDF
Distributed ID generator in ChatWork
Easy logins for JavaScript web applications
Killing Passwords with JavaScript
Hybrid Tips & Tricks
Easy logins for Ruby web applications
Securing the Web without site-specific passwords
WebAuthn and Security Keys
Fun With Spring Security
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...
Webauthn Tutorial
Serverless Angular, Material, Firebase and Google Cloud applications
U2F/FIDO2 implementation of YubiKey
Cross-Platform Authentication with Google+ Sign-In
Drive chrome(headless) with puppeteer
Relational Database Access with Python
Up and Running with Angular
Docker on openstack by OpenSource Consulting
Nagios Conference 2013 - Troy Lea - Leveraging and Understanding Performance ...
Configuring kerberos based sso in weblogic
FLAR Workflow
Distributed ID generator in ChatWork

Recently uploaded (20)

PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPT
Introduction Database Management System for Course Database
PDF
medical staffing services at VALiNTRY
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
System and Network Administration Chapter 2
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Transform Your Business with a Software ERP System
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
L1 - Introduction to python Backend.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
ai tools demonstartion for schools and inter college
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Introduction to Artificial Intelligence
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
Design an Analysis of Algorithms II-SECS-1021-03
Introduction Database Management System for Course Database
medical staffing services at VALiNTRY
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
System and Network Administration Chapter 2
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
wealthsignaloriginal-com-DS-text-... (1).pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Transform Your Business with a Software ERP System
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
L1 - Introduction to python Backend.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
ai tools demonstartion for schools and inter college
Reimagine Home Health with the Power of Agentic AI​
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Introduction to Artificial Intelligence
How to Migrate SBCGlobal Email to Yahoo Easily

Two factor authentication with Laravel and Google Authenticator