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

Request doesn't contain any headers when user service requested #578

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

Comments

Projects
None yet
1 participant
@Alendorff
Copy link

Alendorff commented Sep 21, 2017

Steps to reproduce

Here is the repo with my code:

Before start run mongodb.
How to reproduce (I use postman with Content-Type=json header included for every step):
POST to localhost:8080/user

{
	"email": "test3@test.com",
	"password": "qweqwe"
}

POST to localhost:8080/authentication

{
	"strategy": "local",
	"email": "test3@test.com",
	"password": "qweqwe"
}

You will get token.
Set new header Authorization=<received token>

Then, request localhost:8080/user and get

{
    "name": "NotAuthenticated",
    "message": "No auth token",
    "code": 401,
    "className": "not-authenticated",
    "data": {},
    "errors": {}
}

As I saw with debugger, target strategy gets request without any headers. So, no headers - no token.
By the way, if you will GET to localhost:8080/project -> it works fine. But not for user service... That's weird.

System configuration

Module versions (especially the part that's not working):

"dependencies": {
    "body-parser": "^1.18.1",
    "compression": "^1.7.0",
    "cors": "^2.8.4",
    "feathers": "^2.2.0",
    "feathers-authentication": "^1.2.7",
    "feathers-authentication-hooks": "^0.1.4",
    "feathers-authentication-jwt": "^0.3.2",
    "feathers-authentication-local": "^0.4.4",
    "feathers-authentication-oauth2": "^0.2.6",
    "feathers-configuration": "^0.4.1",
    "feathers-errors": "^2.9.2",
    "feathers-hooks": "^2.0.2",
    "feathers-hooks-common": "^3.7.3",
    "feathers-mongoose": "^5.1.2",
    "feathers-rest": "^1.8.0",
    "feathers-socketio": "^2.0.0",
    "helmet": "^3.8.1",
    "mongoose": "^4.11.9",
    "morgan": "^1.8.2",
    "passport-google-oauth20": "^1.0.0",
    "validator": "^8.2.0",
    "winston": "^2.3.1",
    "winston-daily-rotate-file": "^1.7.0"
  }

NodeJS version: v8.4.0

Operating System: Linux 4.10.0-35-generic x86_64

@Alendorff

This comment has been minimized.

Copy link
Author

Alendorff commented Sep 22, 2017

I found the problem... Authentication service must be configured before any services which require authentication. In my case, user was the first.

So, do:

  app.configure(authentication);
  app.configure(user); // auth will work

Don't

  app.configure(user); // auth won't work
  app.configure(authentication);

@Alendorff Alendorff closed this Sep 22, 2017

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.