Gathering detailed insights and metrics for passport-openidconnect
Gathering detailed insights and metrics for passport-openidconnect
Gathering detailed insights and metrics for passport-openidconnect
Gathering detailed insights and metrics for passport-openidconnect
npm install passport-openidconnect
82.4
Supply Chain
98.6
Quality
76.3
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
195 Stars
340 Commits
179 Forks
15 Watching
6 Branches
13 Contributors
Updated on 25 Nov 2024
JavaScript (99.79%)
Makefile (0.21%)
Cumulative downloads
Total Downloads
Last day
-28.2%
6,505
Compared to previous day
Last week
0.2%
46,480
Compared to previous week
Last month
8.9%
185,707
Compared to previous month
Last year
32%
1,952,820
Compared to previous year
2
7
Passport strategy for authenticating with OpenID Connect.
This module lets you authenticate using OpenID Connect in your Node.js applications. By plugging into Passport, OpenID Connect-based sign in can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
:heart: Sponsors
1$ npm install passport-openidconnect
The OpenID Connect authentication strategy authenticates users using their account at an OpenID Provider (OP). The strategy needs to be configured with the provider's endpoints, as well as a client ID and secret that has been issued by the provider to the app. Consult the provider's documentation for the locations of these endpoints and instructions on how to register a client.
The strategy takes a verify
function as an argument, which accepts issuer
and profile
as arguments. issuer
is set to an identifier for the OP.
profile
contains the user's profile information
stored in their account at the OP. When authenticating a user, this strategy
uses the OpenID Connect protocol to obtain this information via a sequence of
redirects and back-channel HTTP requests to the OP.
The verify
function is responsible for determining the user to which the
account at the OP belongs. In cases where the account is logging in for the
first time, a new user record is typically created automatically. On subsequent
logins, the existing user record will be found via its relation to the OP
account.
Because the verify
function is supplied by the application, the app is free to
use any database of its choosing. The example below illustrates usage of a SQL
database.
1var OpenIDConnectStrategy = require('passport-openidconnect');
2
3passport.use(new OpenIDConnectStrategy({
4 issuer: 'https://server.example.com',
5 authorizationURL: 'https://server.example.com/authorize',
6 tokenURL: 'https://server.example.com/token',
7 userInfoURL: 'https://server.example.com/userinfo',
8 clientID: process.env['CLIENT_ID'],
9 clientSecret: process.env['CLIENT_SECRET'],
10 callbackURL: 'https://client.example.org/cb'
11 },
12 function verify(issuer, profile, cb) {
13 db.get('SELECT * FROM federated_credentials WHERE provider = ? AND subject = ?', [
14 issuer,
15 profile.id
16 ], function(err, cred) {
17 if (err) { return cb(err); }
18
19 if (!cred) {
20 // The account at the OpenID Provider (OP) has not logged in to this app
21 // before. Create a new user account and associate it with the account
22 // at the OP.
23 db.run('INSERT INTO users (name) VALUES (?)', [
24 profile.displayName
25 ], function(err) {
26 if (err) { return cb(err); }
27
28 var id = this.lastID;
29 db.run('INSERT INTO federated_credentials (user_id, provider, subject) VALUES (?, ?, ?)', [
30 id,
31 issuer,
32 profile.id
33 ], function(err) {
34 if (err) { return cb(err); }
35 var user = {
36 id: id,
37 name: profile.displayName
38 };
39 return cb(null, user);
40 });
41 });
42 } else {
43 // The account at the OpenID Provider (OP) has previously logged in to
44 // the app. Get the user account associated with the account at the OP
45 // and log the user in.
46 db.get('SELECT * FROM users WHERE id = ?', [ cred.user_id ], function(err, row) {
47 if (err) { return cb(err); }
48 if (!row) { return cb(null, false); }
49 return cb(null, row);
50 });
51 }
52 });
53 }
54));
Two routes are needed in order to allow users to log in with their account at an OP. The first route redirects the user to the OP, where they will authenticate:
1app.get('/login', passport.authenticate('openidconnect'));
The second route processes the authentication response and logs the user in, when the OP redirects the user back to the app:
1app.get('/cb', 2 passport.authenticate('openidconnect', { failureRedirect: '/login', failureMessage: true }), 3 function(req, res) { 4 res.redirect('/'); 5 });
Illustrates how to use the OpenID Connect strategy within an Express application.
Illustrates how to use the OpenID Connect strategy to integrate with Auth0 in an Express application. For developers new to Passport and getting started, a tutorial is available.
Copyright (c) 2011-2022 Jared Hanson <https://www.jaredhanson.me/>
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
8 existing vulnerabilities detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
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