title: Getting authentication error with HapiJS
body: <p>I have created this simple plugin:</p>
  
  <pre><code>import bcrypt from 'bcrypt';
  import Joi from 'joi';
  
  import DynamoDBClient from '../lib/DynamoDBClient';
  
  exports.register = (server, options, next) =&gt; {
    server.auth.strategy('simple', 'basic', {
      validateFunc: (request, email, password, callback) =&gt; {
        DynamoDBClient.findUserByEmail(email)
          .then(user =&gt; {
            if (!user) {
              return callback(null, false);
            }
  
            bcrypt.compare(password, user.password, (err, isValid) =&gt; {
              return callback(err, isValid, { id: user.id });
            });
          });
      }
    });
  
    server.route({
      method: 'POST',
      path: '/api/login',
      config: {
        auth: 'simple',
        validate: {
          payload: {
            email: Joi.string().required(),
            password: Joi.string().required()
          }
        }
      },
      handler: (request, reply) =&gt; reply(request.auth.credentials.id)
    });
  
    next();
  };
  
  exports.register.attributes = {
    name: 'login',
  };
  </code></pre>
  
  <p>and loaded the manifest here:</p>
  
  <pre><code>import Glue from 'glue';
  
  const manifest = {
    server: {},
    connections: [
      {
        port: process.env.PORT || 3001,
        labels: ['api']
      }
    ], 
    plugins: {
      'hapi-auth-basic': {}, 
      './api/signup': {},
      './api/login': {},
      './api/products': {},
    }
  };
  
  const options = {
    relativeTo: __dirname
  };
  
  Glue.compose(manifest, options, (err, server) =&gt; {
    if (err) {
      throw err;
    }
  
    server.start(() =&gt; console.log(`Listening to ${server.info.uri}`));
  });
  </code></pre>
  
  <p>but I get this error</p>
  
  <pre><code>{
    "statusCode": 401,
    "error": "Unauthorized",
    "message": "Missing authentication"
  }
  </code></pre>
  
  <p>when I try to login passing a POST request with email and password as body params.</p>