Gathering detailed insights and metrics for passport-google-verify-token
Gathering detailed insights and metrics for passport-google-verify-token
Gathering detailed insights and metrics for passport-google-verify-token
Gathering detailed insights and metrics for passport-google-verify-token
npm install passport-google-verify-token
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5 Stars
134 Commits
9 Forks
2 Watching
1 Branches
6 Contributors
Updated on 27 Jun 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-40.4%
99
Compared to previous day
Last week
-3.2%
792
Compared to previous week
Last month
-10.3%
3,604
Compared to previous month
Last year
15.7%
51,315
Compared to previous year
Passport strategy for authenticating with Google access tokens using the OAuth 2.0 API.
This module lets you authenticate using Google in your Node.js applications. By plugging into Passport, Google authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
$ npm install passport-google-verify-token
The Google authentication strategy leverages the Google Auth Library for Node.js to authenticates users.
Applications must supply a verify
callback which accepts the idToken
or access_token
coming from the user to be authenticated, and then calls the done
callback
supplying a parsedToken
(with all its information in visible form) and the
googleId
.
1var GoogleTokenStrategy = require("passport-google-verify-token").Strategy;
2
3passport.use(new GoogleTokenStrategy({
4 clientID: '12345.abcdefghijkl.apps.googleusercontent.com'// Specify the CLIENT_ID of the backend
5 // If other clients (such as android / ios apps) also access the google api:
6 // audience: [CLIENT_ID_FOR_THE_BACKEND, CLIENT_ID_ANDROID, CLIENT_ID_IOS, CLIENT_ID_SPA]
7 },
8 function(parsedToken, googleId, done) {
9 User.findOrCreate(..., function (err, user) {
10 done(err, user);
11 });
12 }
13 ));
When verifying an idToken, the Google Auth library verifyIdToken()
function is called, and the authentication is finished. When an access_token
is passed, however, two steps have to be made:
getTokenInfo()
function is called. This is to verify that the token is valid and not expired./oauth2/v3/userinfo
is sent. access_token
s require this second step in order to get the same user information idToken
s return.Use passport.authenticate()
, specifying the 'google-verify-token'
strategy, to authenticate requests.
1app.post('/auth/google/token', 2 passport.authenticate('google-verify-token'), 3 function (req, res) { 4 // do something with req.user 5 res.send(req.user? 200 : 401); 6 } 7);
Or using Sails framework:
1// api/controllers/AuthController.js 2module.exports = { 3 facebook: function(req, res) { 4 passport.authenticate('google-verify-token', function(error, user, info) { 5 // do stuff with user 6 res.ok(); 7 })(req, res); 8 } 9};
Clients can send requests to routes that use google-verify-token authentication using query parms, body, or HTTP headers. Clients will need to transmit the access_token
or the id_token
that are received from Google after user logs in.
GET /auth/google/token?access_token=<TOKEN_HERE>
Clients can choose to send the access token using the Oauth2 Bearer token (RFC 6750) compliant format
GET /resource HTTP/1.1
Host: server.example.com
Authorization: Bearer base64_access_token_string
Clients can transmit the access token via the body
POST /resource HTTP/1.1
Host: server.example.com
access_token=base64_access_token_string
This project is inspired by Juanma Reyes' Passport Google Id Token.
The MIT License (MIT)
Copyright (c) 2018 Abdou Bouroubi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
1 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
Found 2/20 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More