SlideShare uma empresa Scribd logo
1 de 15
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

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Introduction to cyber security
Introduction to cyber securityIntroduction to cyber security
Introduction to cyber security
 
Vulnerability assessment and penetration testing
Vulnerability assessment and penetration testingVulnerability assessment and penetration testing
Vulnerability assessment and penetration testing
 
Cyber security
Cyber securityCyber security
Cyber security
 
Cyber Security
Cyber SecurityCyber Security
Cyber Security
 
Keyloggers.ppt
Keyloggers.pptKeyloggers.ppt
Keyloggers.ppt
 
Cyber security
Cyber securityCyber security
Cyber security
 
Cyber security
Cyber securityCyber security
Cyber security
 
Wireless and mobile security
Wireless and mobile securityWireless and mobile security
Wireless and mobile security
 
3 reasons your business can't ignore Two-Factor Authentication
3 reasons your business can't ignore Two-Factor Authentication3 reasons your business can't ignore Two-Factor Authentication
3 reasons your business can't ignore Two-Factor Authentication
 
Cyber security
Cyber securityCyber security
Cyber security
 
Passwordless Authentication
Passwordless AuthenticationPasswordless Authentication
Passwordless Authentication
 
Cyber Security Awareness
Cyber Security AwarenessCyber Security Awareness
Cyber Security Awareness
 
Computer security and privacy
Computer security and privacyComputer security and privacy
Computer security and privacy
 
CYBER SECURITY
CYBER SECURITYCYBER SECURITY
CYBER SECURITY
 
Guide to MFA
Guide to MFAGuide to MFA
Guide to MFA
 
Cybersecurity Basics - Aravindr.com
Cybersecurity Basics - Aravindr.comCybersecurity Basics - Aravindr.com
Cybersecurity Basics - Aravindr.com
 
Browser security
Browser securityBrowser security
Browser security
 
Password craking techniques
Password craking techniques Password craking techniques
Password craking techniques
 
Web Application Penetration Testing
Web Application Penetration Testing Web Application Penetration Testing
Web Application Penetration Testing
 
Threat Modelling
Threat ModellingThreat Modelling
Threat Modelling
 

Semelhante a Google authentication

AdWords API and OAuth 2.0
AdWords API and OAuth 2.0AdWords API and OAuth 2.0
AdWords API and OAuth 2.0
marcwan
 
OAuth 2.0
OAuth 2.0 OAuth 2.0
OAuth 2.0
marcwan
 
Enhancing Password Manager Chrome Extension through Multi Authentication and ...
Enhancing Password Manager Chrome Extension through Multi Authentication and ...Enhancing Password Manager Chrome Extension through Multi Authentication and ...
Enhancing Password Manager Chrome Extension through Multi Authentication and ...
ijtsrd
 

Semelhante a Google authentication (20)

2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi
 
OAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST ServicesOAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST Services
 
10 1 otp all
10 1 otp all10 1 otp all
10 1 otp all
 
AdWords API and OAuth 2.0
AdWords API and OAuth 2.0AdWords API and OAuth 2.0
AdWords API and OAuth 2.0
 
Cartes Asia Dem 2010 V2
Cartes Asia Dem 2010 V2Cartes Asia Dem 2010 V2
Cartes Asia Dem 2010 V2
 
OAuth with Salesforce - Demystified
OAuth with Salesforce - DemystifiedOAuth with Salesforce - Demystified
OAuth with Salesforce - Demystified
 
Cloud Identity Management
Cloud Identity ManagementCloud Identity Management
Cloud Identity Management
 
OAuth 2.0
OAuth 2.0 OAuth 2.0
OAuth 2.0
 
Enhancing Password Manager Chrome Extension through Multi Authentication and ...
Enhancing Password Manager Chrome Extension through Multi Authentication and ...Enhancing Password Manager Chrome Extension through Multi Authentication and ...
Enhancing Password Manager Chrome Extension through Multi Authentication and ...
 
Google authenticator odoo two factor authentication (2FA) login security
Google authenticator odoo two factor authentication (2FA) login securityGoogle authenticator odoo two factor authentication (2FA) login security
Google authenticator odoo two factor authentication (2FA) login security
 
Integrating Okta with Anypoint Platform for a mobile security use case
Integrating Okta with Anypoint Platform for a mobile security use caseIntegrating Okta with Anypoint Platform for a mobile security use case
Integrating Okta with Anypoint Platform for a mobile security use case
 
Microsoft Graph API Webinar Application Permissions
Microsoft Graph API Webinar Application PermissionsMicrosoft Graph API Webinar Application Permissions
Microsoft Graph API Webinar Application Permissions
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - Introduction
 
How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptx
 
ACDKOCHI19 - Enterprise grade security for web and mobile applications on AWS
ACDKOCHI19 - Enterprise grade security for web and mobile applications on AWSACDKOCHI19 - Enterprise grade security for web and mobile applications on AWS
ACDKOCHI19 - Enterprise grade security for web and mobile applications on AWS
 
Cost-Effective Two-Factor Authentication
Cost-Effective Two-Factor AuthenticationCost-Effective Two-Factor Authentication
Cost-Effective Two-Factor Authentication
 
Bye bye Identity Server
Bye bye Identity ServerBye bye Identity Server
Bye bye Identity Server
 
Two factor authentication,Google authenticator in odoo
Two factor authentication,Google authenticator  in odooTwo factor authentication,Google authenticator  in odoo
Two factor authentication,Google authenticator in odoo
 
Api security
Api security Api security
Api security
 
How to implement sso using o auth in golang application
How to implement sso using o auth in golang applicationHow to implement sso using o auth in golang application
How to implement sso using o auth in golang application
 

Mais de NexThoughts Technologies

Mais de NexThoughts Technologies (20)

Alexa skill
Alexa skillAlexa skill
Alexa skill
 
GraalVM
GraalVMGraalVM
GraalVM
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Apache commons
Apache commonsApache commons
Apache commons
 
HazelCast
HazelCastHazelCast
HazelCast
 
MySQL Pro
MySQL ProMySQL Pro
MySQL Pro
 
Microservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxMicroservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & Redux
 
Swagger
SwaggerSwagger
Swagger
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Arango DB
Arango DBArango DB
Arango DB
 
Jython
JythonJython
Jython
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Smart Contract samples
Smart Contract samplesSmart Contract samples
Smart Contract samples
 
My Doc of geth
My Doc of gethMy Doc of geth
My Doc of geth
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
 
Ethereum genesis
Ethereum genesisEthereum genesis
Ethereum genesis
 
Ethereum
EthereumEthereum
Ethereum
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

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