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

"No auth token" with auth0 when following the guide #655

Closed
97-109-107 opened this Issue Mar 19, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@97-109-107
Copy link

97-109-107 commented Mar 19, 2018

Steps to reproduce

Having generated the authentication with the feathers-cli, and filled up the configuration file with auth0 details, authentication fails to happen (ie visiting /users) with the below message. Strategies are set to ["jwt"] only.

info: Feathers application started on http://localhost:3030         
error:  NotAuthenticated: No auth token                             
    at new NotAuthenticated (/home/amk/Projekty/onepackgo/opg-platform/node_modules/@feathersjs/errors/lib/index.js:93:17)               
    at app.authenticate.then (/home/amk/Projekty/onepackgo/opg-platform/node_modules/@feathersjs/authentication/lib/hooks/authenticate.js:76:31)
    at <anonymous>                

Authentication

const authentication = require('@feathersjs/authentication');
const jwt = require('@feathersjs/authentication-jwt');

const oauth2 = require('@feathersjs/authentication-oauth2');
const Auth0Strategy = require('passport-auth0');

module.exports = function (app) {
  const config = app.get('authentication');

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

  app.configure(oauth2(Object.assign({
    name: 'auth0',
    Strategy: Auth0Strategy
  }, config.auth0)));

  app.service('authentication').hooks({
    before: {
      create: [
        authentication.hooks.authenticate('jwt')
      ],
      remove: [
        authentication.hooks.authenticate('jwt')
      ]
    }
  });
};

Hooks

const { authenticate } = require('@feathersjs/authentication').hooks;

module.exports = {
  before: {
    all: [],
    find: [ authenticate('jwt') ],
    get: [ authenticate('jwt') ],
    create: [  ],
    update: [  authenticate('jwt') ],
    patch: [  authenticate('jwt') ],
    remove: [ authenticate('jwt') ]
  },

  after: {
    all: [ 
    ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  error: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  }
};

Package version:

  "dependencies": {
    "@feathersjs/authentication": "^2.1.3",
    "@feathersjs/authentication-jwt": "^2.0.0",
    "@feathersjs/authentication-oauth2": "^1.0.3",
    "@feathersjs/configuration": "^1.0.2",
    "@feathersjs/errors": "^3.3.0",
    "@feathersjs/express": "^1.2.0",
    "@feathersjs/feathers": "^3.1.3",
    "@feathersjs/socketio": "^3.2.0",
    "compression": "^1.7.2",
    "cors": "^2.8.4",
    "feathers-sequelize": "^3.0.1",
    "hbs": "^4.0.1",
    "helmet": "^3.12.0",
    "passport-auth0": "^0.6.1",
    "pg": "^7.4.1",
    "sequelize": "^4.37.2",
    "serve-favicon": "^2.4.5",
    "winston": "^2.4.1"
  },
@daffl

This comment has been minimized.

Copy link
Member

daffl commented Mar 19, 2018

What do you mean by "visiting /users"? The oAuth authentication flow will only set the feathers-jwt cookie which will in turn be used by either the @feathersjs/authentication-client or has to be set manually as the Authorization header.

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.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.