Menu

📰
0

Part II: Persisting OpenID Server Data on MongoDB with Node.js

DEV Community: koa·Ebrahim Hoseiny Fadae·about 1 month ago
#8PU8TQDv
#dev#class#code#highlight#oidc#article
Reading 0:00
15s threshold

Introduction In this article, we'll explore how to integrate MongoDB with an OIDC ( OpenID Connect 1.0 ) authentication server. We'll be using the panava/node-oidc-provider library for implementing the OIDC server and the Mongoose for connecting to MongoDB. Let's start Assuming you have followed the previous articles, you only need to add the necessary database dependencies. $ yarn add mongoose@6.0.5 -T Connect to MongoDB For connecting to the MongoDB instance we only need to call connect from the mongoose library. ./oidc/src/db/mongodb/connection.ts import mongoose from " mongoose " ; export default async () => { const URI = process . env . MONGODB_URI ?? "" ; try { return await mongoose . connect ( URI , {}); } catch ( error ) { console . error ( error ); } }; Add Base model Now that we have our database connected, we need to design our models to store the data.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More