Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/magiclabs/passport-magic
- Owner: magiclabs
- License: mit
- Created: 2020-03-17T02:04:31.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T21:57:57.000Z (over 1 year ago)
- Last Synced: 2024-10-14T22:26:28.467Z (about 1 month ago)
- Topics: authentication, expressjs, identity, javascript, nodejs, passportjs, passwordless
- Language: TypeScript
- Homepage: https://docs.magic.link/tutorials/full-stack-node-js
- Size: 342 KB
- Stars: 39
- Watchers: 16
- Forks: 10
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
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);
```