Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

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

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

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

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

Comments

@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
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.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants