title: Using Passport JS Bearer Authenticate Globally
body: <p>I have the following code written in NodeJS that uses Passport JS Bearer Authentication in Route Middleware.</p>
  
  <pre><code>app.put('/api/customers/:id', passport.authenticate('bearer', {session : false}),      handlers.putCustomers);
  app.put('/api/products/:id', passport.authenticate('bearer', {session:false}), handlers.putProducts);
  </code></pre>
  
  <p>Instead of using <code>passport.authenticate</code> for every endpoint, i want to apply this globally for every endpoint.</p>
  
  <p>I tried with the following order of middleware with no luck</p>
  
  <pre><code>var app = express();
  app.use(bodyParser());
  app.use(session({ store: new RedisStore({client:client}),secret: 'keyboard cat' }));
  app.use(passport.initialize());
  passport.use(new BearerStrategy(){....
  
  app.use(passport.authenticate('bearer', {session:false}));
  
  app.put('/api/customers/:id',  handlers.putCustomers);
  app.put('/api/products/:id', handlers.putProducts);
  </code></pre>
  
  <p>I am getting a 401 when i hit the endpoint.. I am seeing it for 'OPTIONS' type instead of  'PUT' if that helps or makes sense.( Using chrome to test my endpoint from my app's UI).</p>