How to use @loopback/authentication-passport - 1 common examples

To help you get started, we’ve selected a few @loopback/authentication-passport 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 iqbaldjulfri / lb4-jwt-role-based-auth-sample / src / auth.ts View on Github external
const {strategy} = this.metadata;
    if (strategy === JWT_STRATEGY_NAME) {
      const jwtStrategy = new JwtStrategy(
        {
          secretOrKey: JWT_SECRET,
          jwtFromRequest: ExtractJwt.fromExtractors([
            ExtractJwt.fromAuthHeaderAsBearerToken(),
            ExtractJwt.fromUrlQueryParameter('access_token'),
          ]),
        },
        (payload, done) => this.verifyToken(payload, done),
      );

      // we will use Loopback's  StrategyAdapter so we can leverage passport's strategy
      // and also we don't have to implement a new strategy adapter.
      return new StrategyAdapter(jwtStrategy, JWT_STRATEGY_NAME);
    }
  }

@loopback/authentication-passport

A package creating adapters between the passport module and @loopback/authentication

MIT
Latest version published 28 days ago

Package Health Score

90 / 100
Full package analysis

Popular @loopback/authentication-passport functions