<commit_before>'use strict';

const logger = require('pino')();
const Token = require('../models/token');
const response = require('../lib/response');

module.exports = createBearerAuthMW;

function createBearerAuthMW() {
  return next => {
    return async context => {
      // We skip our (temporarily) embedded website AND paths that are
      // never expected to have valid tokens.
      if (
        context.request.url.startsWith('/www') ||
        context.request.url.startsWith('/-/v1/login')
      ) {<commit_msg>Only auth for a few routes that need it. (#39)<commit_after>'use strict';

const logger = require('pino')();
const Token = require('../models/token');
const response = require('../lib/response');

module.exports = createBearerAuthMW;

const idempotent = new Set(['GET', 'HEAD']);

function createBearerAuthMW() {
  return next => {
    return async context => {
      // We skip our (temporarily) embedded website AND paths that are
      // never expected to have valid tokens.
      const requrl = context.request.url;
      if (
        requrl.startsWith('/www') ||
        requrl.startsWith('/-/v1/login') ||
        (idempotent.has(context.request.method) && requrl !== '/-/whoami')
      ) {
{'fraction_non_alphanumeric': 0.15397215397215397, 'fraction_numerical': 0.003276003276003276, 'mean_word_length': 3.0733333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7135480', 'n_tokens_mistral': 364, 'n_tokens_neox': 350, 'n_words': 98}