Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 when accessing route using customer authentication #579

Closed
istvano opened this Issue Sep 21, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@istvano
Copy link

istvano commented Sep 21, 2017

I do not need jwt or any kind of session maangement as I receive the authenticated user in the http headers. for testing I wrote the following custom authenticator

I have a config

 "auth": {
    "strategies": ["http-headers"],
    "httpHeaders": {
        "header-name": "headername"
    },
    "secret": "-"
  }
const CustomStrategy = require('passport-custom');

module.exports = opts => {
  return function() {
      
    const verifier = (req, done) => {
      const user = {
        id: 'superuser'
      };

      done(null, user);
    };

    this.passport.use('http-headers', new CustomStrategy(verifier));
  };
};

I register it.

  const app = this;
  const config = app.get('auth');

  // Set up authentication with the secret
  app.configure(authentication(config))
    .configure(trustedheaders(config.httpHeaders));

  app.service('authentication').hooks({
    before: {
      create: authentication.hooks.authenticate([config.strategies])
    }
  });

Inside my service.hook I refer to it as

const { authenticate } = require('feathers-authentication').hooks;

module.exports = {
  before: {
    all: [
      authenticate(['http-headers'])
    ],

No matter what I do I keep getting a 404. if I comment out the authenticate hook. I got the reponsive.

I am really new to fethers, just started out and I am not sure how to debug this. I would appreciate any pointers. Also I think it shuold be throwing a 401.

Thanks

@daffl

This comment has been minimized.

Copy link
Member

daffl commented Sep 27, 2017

Can you share a repository with a complete demo application? 404 seems like an odd response (it should be at least 401 or 500 if something else went wrong).

@daffl daffl closed this Jan 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.