How to use the passport-jwt.ExtractJwt.fromUrlQueryParameter function in passport-jwt

To help you get started, we’ve selected a few passport-jwt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / passport-jwt / passport-jwt-tests.ts View on Github external
findUser({id: jwt_payload.sub}, function(err, user) {
        if (err) {
            return done(err, false);
        }
        if (user) {
            done(null, user);
        } else {
            done(null, false, {message: 'foo'});
            // or you could create a new account
        }
    });
}));

opts.jwtFromRequest = ExtractJwt.fromHeader('x-api-key');
opts.jwtFromRequest = ExtractJwt.fromBodyField('field_name');
opts.jwtFromRequest = ExtractJwt.fromUrlQueryParameter('param_name');
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('param_name');
opts.jwtFromRequest = ExtractJwt.fromExtractors([ExtractJwt.fromHeader('x-api-key'), ExtractJwt.fromBodyField('field_name'), ExtractJwt.fromUrlQueryParameter('param_name')]);
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
opts.jwtFromRequest = (req: Request) => { return req.query.token; };
opts.secretOrKey = new Buffer('secret');

declare function findUser(condition: {id: string}, callback: (error: any, user :any) => void): void;
github TreeGateway / tree-gateway / src / spec / test-data / middleware / authentication / strategies / myJwtStrategy.js View on Github external
module.exports = function (authConfig) {
    var opts = {}
    opts.jwtFromRequest = ExtractJwt.fromUrlQueryParameter('jwt');
    opts.secretOrKey = authConfig.secret;
    return new JwtStrategy(opts, function(jwt_payload, done) {
        done(null,jwt_payload.sub);
    });
};
github vellengs / nestx-server / packages / auth / src / jwt.strategy.ts View on Github external
constructor(
    private readonly authService: AuthService,
    configService: ConfigService
  ) {
    super({
      jwtFromRequest: ExtractJwt.fromExtractors([
        ExtractJwt.fromAuthHeaderAsBearerToken(),
        ExtractJwt.fromUrlQueryParameter("access_token"),
        req => {
          const token = req.cookies && req.cookies.access_token;
          return token;
        }
      ]),
      secretOrKey: configService.get("JWT_SECRET_KEY")
    });
  }
github BigDataBoutique / ElastiQuill / backend / src / routes / auth / jwt.js View on Github external
export default function(passport) {
  passport.use(
    new JwtStrategy(
      {
        jwtFromRequest: ExtractJwt.fromExtractors([
          ExtractJwt.fromUrlQueryParameter("state"),
          ExtractJwt.fromAuthHeaderAsBearerToken(),
        ]),
        secretOrKey: jwtSecret,
      },
      (jwtPayload, done) => done(null, jwtPayload.user)
    )
  );
}
github TreeGateway / tree-gateway / src / lib / authentication / strategies / jwt.ts View on Github external
function getExtractor(extractor: string, param: string) {
    switch(extractor) {
        case 'header': return ExtractJwt.fromHeader(param);
        case 'queryParam': return ExtractJwt.fromUrlQueryParameter(param);
        case 'authHeader': return ExtractJwt.fromAuthHeaderWithScheme(param);
        case 'bodyField': return ExtractJwt.fromBodyField(param);
        case 'cookie': return (req)=>{
            let token = null;
            if (req && req.cookies)
            {
                token = req.cookies[param];
            }
            return token;
        };            
    }

    return ExtractJwt.fromAuthHeader();
}
github vellengs / nestx / packages / servers / nestx-auth / src / jwt.strategy.ts View on Github external
constructor(
    private readonly authService: AuthService,
    configService: ConfigService
  ) {
    super({
      jwtFromRequest: ExtractJwt.fromExtractors([
        ExtractJwt.fromAuthHeaderAsBearerToken(),
        ExtractJwt.fromUrlQueryParameter("access_token"),
        req => {
          const token = req.cookies && req.cookies.access_token;
          return token;
        }
      ]),
      secretOrKey: configService.get("JWT_SECRET_KEY")
    });
  }
github vellengs / nestx / packages / server / src / auth / jwt.strategy.ts View on Github external
constructor(
    private readonly authService: AuthService,
    configService: ConfigService,
  ) {
    super({
      jwtFromRequest: ExtractJwt.fromExtractors([
        ExtractJwt.fromAuthHeaderAsBearerToken(),
        ExtractJwt.fromUrlQueryParameter('access_token'),
        (req) => {
          const token = req.cookies && req.cookies.access_token;
          return token;
        },
      ]),
      secretOrKey: configService.get('JWT_SECRET_KEY'),
    });
  }