SlideShare a Scribd company logo
Google Authentication
By Anubhav Goyal
Content
● About google authentication
● Two-Factor Authentication
● Plugin
● Time Based OTP
● How to Integrate
● Integrate with Spring Security
● Demo
● References
Google Authentication
Google Authenticator is a software token that implements two-step verification services using
the Time-based One-time Password Algorithm (TOTP) and HMAC-based One-time Password
Algorithm (HOTP), for authenticating users of mobile applications by Google. The service
implements algorithms specified in RFC 6238 and RFC 4226, respectively.
Authenticator provides a six- to eight-digit one-time password which users must provide in
addition to their username and password to log into Google services or other sites
Two Factor Authentication
Two-factor authentication (2FA) -- also known as two-step verification or multifactor
authentication -- is widely used to add a layer of security to your online accounts. The most
common form of two-factor authentication when logging into an account is the process of
entering your password and then receiving a code via text on your phone that you then need to
enter.
An extra layer of security that is known as "multi factor authentication"
The authentication factors of a multi-factor/two-factor authentication scheme may include:
1. some physical object in the possession of the user, such as a USB stick with a secret token,
a bank card, a key, etc.
2. some secret known to the user, such as a password, PIN, TAN, etc.
3. some physical characteristic of the user (biometrics), such as a fingerprint, eye iris, voice,
typing speed, pattern in key press intervals, etc
Plugin:
For Gradle :
compile 'com.warrenstrange:googleauth:1.1.2'
For Maven :
<dependency>
<groupId>com.warrenstrange</groupId>
<artifactId>googleauth</artifactId>
<version>1.1.2</version>
</dependency>
The required libraries will be automatically pulled into your project:
● Apache Commons Codec.
● Apache HTTP client.
Time Based OTP
A time-based one-time password (TOTP) is a temporary passcode, generated by an algorithm,
for use in authenticating access to computer systems.
The algorithm that generates each password uses the current time of day as one of its factors,
ensuring that each password is unique. Time-based one-time passwords are commonly used for
two-factor authentication and have seen growing adoption by cloud application providers.
Integration with Google Auth
The following code creates a new set of credentials for a user. No user name is provided to the
API and it is a responsibility of the caller to save it for later use during the authorisation phase.
GoogleAuthenticator gAuth = new GoogleAuthenticator();
final GoogleAuthenticatorKey key = gAuth.createCredentials();
The user should be given the value of the shared secret, returned by
key.getKey(), this will return secret key ,which can be used next time for TOTP varification.
The following code checks the validity of the specified password against the provided Base32-
encoded secretKey:
GoogleAuthenticator gAuth = new GoogleAuthenticator();
boolean isCodeValid = gAuth.authorize(secretKey, totp);
Integrate With Spring Security
Plugin:
compile ':spring-security-oauth-google:0.3.1'
grails install-plugin spring-security-oauth
Configure with spring security
oauth {
debug = true
providers {
google {
api = org.scribe.builder.api.GoogleApi
key = 'oauth_google_key'
secret = 'oauth_google_secret'
successUri = '/oauth/google/success'
failureUri = '/oauth/google/error'
callback = "${baseURL}/oauth/google/callback"
scope = 'https://www.googleapis.com/auth/userinfo.email'
}
}
}
How to create domain for OAuth:
To create OAuth Domain :
grails s2-init-oauth [domain-class-package] [oauthid-class-name]
that creates:
● The domain class
● The controller class [package path]SpringSecurityOAuthController
● The view springSecurityOAuth/askToLinkOrCreateAccount.gsp
Finally, add
static hasMany = [oAuthIDs: OAuthID]
to you user domain class.
Demo
You can find demo on :
https://github.com/NexThoughts/Google-Authenticator
References
● https://github.com/wstrange/GoogleAuth
● https://github.com/j256/two-factor-auth
● https://en.wikipedia.org/wiki/HMAC-based_One-time_Password_algorithm
● https://searchsecurity.techtarget.com/definition/Google-Authenticator
● https://en.wikipedia.org/wiki/Google_Authenticator
● https://stackoverflow.com/questions/27964389/grails-using-google-
authentication-with-the-spring-security-plugin?rq=1
● http://www.baeldung.com/spring-security-two-factor-authentication-with-soft-
token
● https://github.com/cazacugmihai/grails-spring-security-oauth
THANK YOU

More Related Content

What's hot (20)

PDF
Authentication techniques
IGZ Software house
 
PPTX
Graphical password authentication
shalini singh
 
PPT
authentication.ppt
jayarao21
 
PPTX
Email security
Baliram Yadav
 
PDF
Project Synopsis
Paras Garg
 
PPT
Graphical password authentication
bhavana sharma
 
PPTX
Attendance system based on face recognition using python by Raihan Sikdar
raihansikdar
 
PPTX
Network access protection ppt
Dasarathi Dash
 
PDF
Presentation on House Rent Management System
Rihab Rahman
 
PPTX
Kerberos
Rahul Pundir
 
PPTX
UML Diagrams for Real estate management system
Starlee Lathong
 
PPTX
Online Hotel Management System
Sanu Subham
 
PDF
Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...
Mohammad Karim Shahbaz
 
PPTX
Hostel Management System(HMS)
Omkar Walavalkar
 
PDF
CNIT 129S: Ch 7: Attacking Session Management
Sam Bowne
 
PPTX
Digital signature 2
Ankita Dave
 
PPTX
Biometric security using cryptography
Sampat Patnaik
 
PPTX
public key infrastructure
vimal kumar
 
PDF
Stateless Auth using OAUTH2 & JWT
Mobiliya
 
Authentication techniques
IGZ Software house
 
Graphical password authentication
shalini singh
 
authentication.ppt
jayarao21
 
Email security
Baliram Yadav
 
Project Synopsis
Paras Garg
 
Graphical password authentication
bhavana sharma
 
Attendance system based on face recognition using python by Raihan Sikdar
raihansikdar
 
Network access protection ppt
Dasarathi Dash
 
Presentation on House Rent Management System
Rihab Rahman
 
Kerberos
Rahul Pundir
 
UML Diagrams for Real estate management system
Starlee Lathong
 
Online Hotel Management System
Sanu Subham
 
Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...
Mohammad Karim Shahbaz
 
Hostel Management System(HMS)
Omkar Walavalkar
 
CNIT 129S: Ch 7: Attacking Session Management
Sam Bowne
 
Digital signature 2
Ankita Dave
 
Biometric security using cryptography
Sampat Patnaik
 
public key infrastructure
vimal kumar
 
Stateless Auth using OAUTH2 & JWT
Mobiliya
 

Similar to Google authentication (18)

PDF
Google Authenticator, possible attacks and prevention
Boštjan Cigan
 
PPTX
ToTP
FORMAEMPLEO
 
PDF
Building your own web based Authenticator
Varun konadagadapa
 
PDF
Creating OTP with free software
Giuseppe Paterno'
 
PDF
2FA and OTP
Tristan Gomez
 
PPTX
One Time Password - A two factor authentication system
Swetha Kogatam
 
PPTX
Privileged Access Management (PAM): A Deep Dive into Modern Authentication: O...
Bert Blevins
 
PDF
Google Case Study - Towards simpler, stronger authentication
FIDO Alliance
 
PDF
Google Case Study: Strong Authentication for Employees and Consumers
FIDO Alliance
 
PPTX
Better Security With Two Factor Authentication (PHP Unconference 2013)
Norman Soetbeer
 
PDF
How to 2FA-enable Open Source Applications
All Things Open
 
PDF
Cost-Effective Two-Factor Authentication
Waihon Yew
 
PDF
Strong Authentication in Web Application #SCS III
Sylvain Maret
 
PDF
Google FIDO Authentication Case Study
FIDO Alliance
 
PDF
Google Case Sudy: Becoming Unphishable: Towards Simpler, Stronger Authenticaton
FIDO Alliance
 
PPTX
Token based-oauth2
andreyradzkov
 
PPT
10 1 otp all
Mohammad Alyan
 
PPT
Security Tokens
tkisason
 
Google Authenticator, possible attacks and prevention
Boštjan Cigan
 
Building your own web based Authenticator
Varun konadagadapa
 
Creating OTP with free software
Giuseppe Paterno'
 
2FA and OTP
Tristan Gomez
 
One Time Password - A two factor authentication system
Swetha Kogatam
 
Privileged Access Management (PAM): A Deep Dive into Modern Authentication: O...
Bert Blevins
 
Google Case Study - Towards simpler, stronger authentication
FIDO Alliance
 
Google Case Study: Strong Authentication for Employees and Consumers
FIDO Alliance
 
Better Security With Two Factor Authentication (PHP Unconference 2013)
Norman Soetbeer
 
How to 2FA-enable Open Source Applications
All Things Open
 
Cost-Effective Two-Factor Authentication
Waihon Yew
 
Strong Authentication in Web Application #SCS III
Sylvain Maret
 
Google FIDO Authentication Case Study
FIDO Alliance
 
Google Case Sudy: Becoming Unphishable: Towards Simpler, Stronger Authenticaton
FIDO Alliance
 
Token based-oauth2
andreyradzkov
 
10 1 otp all
Mohammad Alyan
 
Security Tokens
tkisason
 
Ad

More from NexThoughts Technologies (20)

PDF
Alexa skill
NexThoughts Technologies
 
PDF
Docker & kubernetes
NexThoughts Technologies
 
PDF
Apache commons
NexThoughts Technologies
 
PDF
Microservice Architecture using Spring Boot with React & Redux
NexThoughts Technologies
 
PDF
Solid Principles
NexThoughts Technologies
 
PDF
Introduction to TypeScript
NexThoughts Technologies
 
PDF
Smart Contract samples
NexThoughts Technologies
 
PDF
My Doc of geth
NexThoughts Technologies
 
PDF
Geth important commands
NexThoughts Technologies
 
PDF
Ethereum genesis
NexThoughts Technologies
 
PPTX
Springboot Microservices
NexThoughts Technologies
 
PDF
An Introduction to Redux
NexThoughts Technologies
 
ODP
Java 9 Features
NexThoughts Technologies
 
Docker & kubernetes
NexThoughts Technologies
 
Apache commons
NexThoughts Technologies
 
Microservice Architecture using Spring Boot with React & Redux
NexThoughts Technologies
 
Solid Principles
NexThoughts Technologies
 
Introduction to TypeScript
NexThoughts Technologies
 
Smart Contract samples
NexThoughts Technologies
 
My Doc of geth
NexThoughts Technologies
 
Geth important commands
NexThoughts Technologies
 
Ethereum genesis
NexThoughts Technologies
 
Springboot Microservices
NexThoughts Technologies
 
An Introduction to Redux
NexThoughts Technologies
 
Java 9 Features
NexThoughts Technologies
 
Ad

Recently uploaded (20)

PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 

Google authentication

  • 2. Content ● About google authentication ● Two-Factor Authentication ● Plugin ● Time Based OTP ● How to Integrate ● Integrate with Spring Security ● Demo ● References
  • 3. Google Authentication Google Authenticator is a software token that implements two-step verification services using the Time-based One-time Password Algorithm (TOTP) and HMAC-based One-time Password Algorithm (HOTP), for authenticating users of mobile applications by Google. The service implements algorithms specified in RFC 6238 and RFC 4226, respectively. Authenticator provides a six- to eight-digit one-time password which users must provide in addition to their username and password to log into Google services or other sites
  • 4. Two Factor Authentication Two-factor authentication (2FA) -- also known as two-step verification or multifactor authentication -- is widely used to add a layer of security to your online accounts. The most common form of two-factor authentication when logging into an account is the process of entering your password and then receiving a code via text on your phone that you then need to enter. An extra layer of security that is known as "multi factor authentication"
  • 5. The authentication factors of a multi-factor/two-factor authentication scheme may include: 1. some physical object in the possession of the user, such as a USB stick with a secret token, a bank card, a key, etc. 2. some secret known to the user, such as a password, PIN, TAN, etc. 3. some physical characteristic of the user (biometrics), such as a fingerprint, eye iris, voice, typing speed, pattern in key press intervals, etc
  • 6. Plugin: For Gradle : compile 'com.warrenstrange:googleauth:1.1.2' For Maven : <dependency> <groupId>com.warrenstrange</groupId> <artifactId>googleauth</artifactId> <version>1.1.2</version> </dependency> The required libraries will be automatically pulled into your project: ● Apache Commons Codec. ● Apache HTTP client.
  • 7. Time Based OTP A time-based one-time password (TOTP) is a temporary passcode, generated by an algorithm, for use in authenticating access to computer systems. The algorithm that generates each password uses the current time of day as one of its factors, ensuring that each password is unique. Time-based one-time passwords are commonly used for two-factor authentication and have seen growing adoption by cloud application providers.
  • 8. Integration with Google Auth The following code creates a new set of credentials for a user. No user name is provided to the API and it is a responsibility of the caller to save it for later use during the authorisation phase. GoogleAuthenticator gAuth = new GoogleAuthenticator(); final GoogleAuthenticatorKey key = gAuth.createCredentials(); The user should be given the value of the shared secret, returned by key.getKey(), this will return secret key ,which can be used next time for TOTP varification.
  • 9. The following code checks the validity of the specified password against the provided Base32- encoded secretKey: GoogleAuthenticator gAuth = new GoogleAuthenticator(); boolean isCodeValid = gAuth.authorize(secretKey, totp);
  • 10. Integrate With Spring Security Plugin: compile ':spring-security-oauth-google:0.3.1' grails install-plugin spring-security-oauth
  • 11. Configure with spring security oauth { debug = true providers { google { api = org.scribe.builder.api.GoogleApi key = 'oauth_google_key' secret = 'oauth_google_secret' successUri = '/oauth/google/success' failureUri = '/oauth/google/error' callback = "${baseURL}/oauth/google/callback" scope = 'https://www.googleapis.com/auth/userinfo.email' } } }
  • 12. How to create domain for OAuth: To create OAuth Domain : grails s2-init-oauth [domain-class-package] [oauthid-class-name] that creates: ● The domain class ● The controller class [package path]SpringSecurityOAuthController ● The view springSecurityOAuth/askToLinkOrCreateAccount.gsp Finally, add static hasMany = [oAuthIDs: OAuthID] to you user domain class.
  • 13. Demo You can find demo on : https://github.com/NexThoughts/Google-Authenticator
  • 14. References ● https://github.com/wstrange/GoogleAuth ● https://github.com/j256/two-factor-auth ● https://en.wikipedia.org/wiki/HMAC-based_One-time_Password_algorithm ● https://searchsecurity.techtarget.com/definition/Google-Authenticator ● https://en.wikipedia.org/wiki/Google_Authenticator ● https://stackoverflow.com/questions/27964389/grails-using-google- authentication-with-the-spring-security-plugin?rq=1 ● http://www.baeldung.com/spring-security-two-factor-authentication-with-soft- token ● https://github.com/cazacugmihai/grails-spring-security-oauth