Skip to content

Todo app using Express, Passport, and Credential Management API for sign in with username and password.

License

Notifications You must be signed in to change notification settings

passport/todos-express-password-credential-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

todos-express-password-credential-management

This app illustrates how to use Passport with Express to sign users in with a username and password. It takes the baseline example and extends it with Credential Management, allowing the browser to assist with the storage and selection of passwords. Use this example as a starting point for your own web applications.

Quick Start

To run this app, clone the repository and install dependencies:

$ git clone https://github.com/passport/todos-express-password-credential-management.git
$ cd todos-express-password-credential-management
$ npm install

Then start the server.

$ npm start

Navigate to http://localhost:3000.

Overview

This app illustrates how to build a todo app with sign in functionality using Express, Passport, and the passport-local strategy.

This app is a traditional web application, in which application logic and data persistence resides on the server. HTML pages and forms are rendered by the server and client-side JavaScript is kept to a minimum.

This app is built using the Express web framework. Data is persisted to a SQLite database. HTML pages are rendered using EJS templates, and are styled using vanilla CSS.

When a user first arrives at this app, they are prompted to sign in. Once authenticated, a login session is established and maintained between the server and the user's browser with a cookie.

The sign in page is progressively enhanced with JavaScript in order to utilize the Credential Management API. For browsers that support it, form submission is overridden and the user is offered the option to store their password making it easy to select when they later return to the app.

After signing in, the user can view, create, and edit todo items. Interaction occurs by clicking links and submitting forms, which trigger HTTP requests. The browser automatically includes the cookie set during login with each of these requests.

When the server receives a request, it authenticates the cookie and restores the login session, thus authenticating the user. It then accesses or stores records in the database associated with the authenticated user.

Next Steps

  • Add passwordless.

    Study todos-express-webauthn to learn how to let users sign in with biometrics or a security key.

License

The Unlicense

Credit

Created by Jared Hanson

About

Todo app using Express, Passport, and Credential Management API for sign in with username and password.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published