Comments (3)
You'd need to encapsulate the two instances in separate plugins.
from fastify-passport.
Thank you for your reply Matteo and sorry for the n00b question but how do I do this? Any examples are appreciated. I am using fastify-passport in a commonJS setting.
/David
from fastify-passport.
Something like:
fastify.register(async (fastify) => {
const LocalStrategy = require('passport-local');
let passport1 = new Authenticator({ key: 'userAuth1', userProperty: 'user1' })
passport1.use('local-1', new LocalStrategy({},
function (username, password, done) {
if (username === _username1 && password == _password1) {
return done(null, {username});
}
return done('local-1: You got this wrong');
}));
fastify.register(passport1.initialize());
fastify.register(passport1.secureSession());
fastify.post("/login-password-1", {
preValidation: passport1.authenticate('local-1', {
failureMessage: true,
failWithError: true,
})
}, async function (request, reply) {
console.log(request.user)
reply.code(200).send({...request.user1})
})
})
Do the same for passport2
from fastify-passport.
Related Issues (20)
- Request user is null when reading from within Mercurius HOT 19
- `state` for passport causes `fastify-passport` to fail HOT 16
- Socket IO middleware Support HOT 3
- Local Strategy bad request HOT 8
- `Forbidden` error after getting authorization code from okta using `passport-okta-oauth` library as a strategy HOT 3
- Use session or not as an option HOT 7
- passport-github verify callback never called? HOT 9
- Using fastify-secure-session with openid-client strategy HOT 8
- Failed to serialize user into session HOT 3
- Cannot publish new module HOT 1
- `state` param is not included in the Typescript interface for AuthenticateOptions HOT 1
- Calling Strategy.fail with 2 arguments is misinterpreted by the compiler HOT 8
- How to print custom error message instead of default "Unauthorized" or "Bad request" HOT 2
- Fastify Custom Strategy, redirect method not working - TypeError: res.setHeader is not a function HOT 3
- the user property remains occupied by the type when userProperty is changed HOT 3
- passport types not exists when using ESM + Typescript HOT 1
- @fastify/jwt and @fastify/passport FST_ERR_DEC_ALREADY_PRESENT HOT 1
- using fastify-passport with passport-jwt strategy HOT 2
- Invalid Typings for PassportUser in Typescript HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastify-passport.