Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/magiclabs/passport-magic

Magic is a Passport.js strategy that enables passwordless authentication middleware for any Express.js based application.
https://github.com/magiclabs/passport-magic

authentication expressjs identity javascript nodejs passportjs passwordless

Last synced: 24 days ago
JSON representation

Magic is a Passport.js strategy that enables passwordless authentication middleware for any Express.js based application.

Awesome Lists containing this project

README

        

# Magic Authentication For Passport JS

[![Tests](https://github.com/magiclabs/passport-magic/actions/workflows/test.yaml/badge.svg)](https://github.com/magiclabs/passport-magic/actions/workflows/test.yaml)

> Integrate [Magic](https://magic.link) passwordless authentication with your Passport.js application.


License ยท
Changelog ยท
Contributing Guide

## ๐Ÿ“– Documentation

See the [developer documentation](https://docs.magic.link/tutorials/full-stack-node-js) to learn how you can integrate Magic into your Passport.js application in a matter of minutes.

## ๐Ÿ”— Installation

Integrating your Passport.js application with Magic will require our server-side NPM package:

```bash
# Via NPM:
npm install --save passport-magic

# Via Yarn:
yarn add passport-magic
```

## โšก๏ธ Quick Start

```ts
const passport = require("passport");
const MagicStrategy = require("passport-magic").Strategy;

const strategy = new MagicStrategy(async function(user, done) {
const userMetadata = await magic.users.getMetadataByIssuer(user.issuer);
const existingUser = await users.findOne({ issuer: user.issuer });
if (!existingUser) {
/* Create new user if doesn't exist */
return signup(user, userMetadata, done);
} else {
/* Login user if otherwise */
return login(user, done);
}
});

passport.use(strategy);
```