Code Monkey home page Code Monkey logo

nodejs-passport-login's Introduction

Project: Node.js Passport Login

Title: PassportLogin

Description

This code is a bare minimum structure of Login using PassportJS. It demonstrates the implementation of passport-local, express-session with expressJS, NodeJS, EJS. It is without CSS. It is without the backend database, content management.

Where to go from here? Obviously, we could employ styling and data modelign, then on to JWT.

[x] PassportJS
[ ] JWT
[ ] Style CSS
[ ] Modeling using MongoDB Atlas

Screenshots

Register
register


Login
Login


Index
index page

References

EJS Embedded JavaScript templating

ExpressJS Fast, unopinionated, minimalist web framework for Node.js

nodejs JavaScript runtime built on Chrome's V8 JavaScript engine

bscript or bscryptjs bcrypt is a password hashing function designed by Niels Provos and David Mazières, based on the Blowfish cipher, and presented at USENIX in 1999.

passportJS Authentication middleware for Node.js

Getting Started

Environment vscode You need to install extension for EJS Language Support! EJS is the Embedded JavaScript templating language that lets you generate HTML markup with plain JavaScript.

npm init

npm i express ejs

npm i --save-dev nodemon dotenv

bcrypt is used for hashing passwords, ...

npm i bcrypt

passport passport-local are used for password authentication. express-session is for local session, express-flash displays invalid authentication messages

npm i passport passport-local express-session express-flash

Logic for passport,...,express-flash will be written in passport-config.js

npm i method-override

method-override alternates POST so we can call app.delete to implement logout

Then,

  • Create the following files: .env .gitignore

  • Insert into .gitignore

.env

node_modules
  • Insert into .env
SESSION_SECRET=your_secret_could_be_anything_here
  • Edit package.json

"scripts": { "devStart": "nodemon server.js" }

  • To start the express server on the terminal:

npm run devStart

Docker Build, Deploy, and Run

Verify that the application is running after you cloned it. Hint, create .env file and enter the followings:

NODE_ENV=development
SESSION_SECRET=Anything you desirer here
PORT=3322

Build Docker

Replace 'hurricanemark' with your dockerhub's username

docker build -t hurricanemark/nodejs-passport-login:1.0 .

Then, run the application:

npm start

List docker image

Find the IMAGE ID of the newly build docker image

docker image ls

Run Docker

docker run -p 9999:8080 <IMAGE_ID>

Expected console output:

> node server.js

Listening on port 3322

nodejs-passport-login's People

Contributors

aesclever avatar dependabot[bot] avatar hurricanemark avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.