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

User Authentication Missing Credentials error (and subsequent nav authorization) #508

Closed
snewell92 opened this Issue May 12, 2017 · 6 comments

Comments

Projects
None yet
5 participants
@snewell92
Copy link

snewell92 commented May 12, 2017

Steps to reproduce

Clone this repo, yarn/npm install, tsc, npm start.
Add user in MySQL (might need to change permissions first, I already have a user created with pass as password before so I added authentication hook to creation).
In browser (or postman) pop open dev tools and either manually use authentication with a user in the MySQL table, or use checkCreds(grabCreds()) functions with form populated. Or uncomment the form submission, I have a login route defined that should be working and redirect to donuts test page...

Expected behavior

Authentication calls should return an accessToken, and subsequent routing should be authenticated. Should subsequent manual URL navigation work too? (If I make a call on the client to authentication service, and get a token back, should I then be able to manually navigate to /donuts ?)

Actual behavior

Currently the repo returns a Bad Request: Missing credentials 400 error.

System configuration

Module versions:

$ npm ls feathers feathers-authentication feathers-authentication-client \
   feathers-authentication-jwt feathers-authentication-local \
   feathers-authentication-management version
newhotness@0.0.0 C:\dorianRepos\newhotness
+-- feathers@2.1.1
+-- feathers-authentication@1.2.2
| `-- feathers-authentication-client@0.3.2
+-- feathers-authentication-jwt@0.3.1
+-- feathers-authentication-local@0.3.4
+-- feathers-authentication-management@0.3.0
| `-- feathers-authentication-local@0.3.4  deduped
`-- feathers-client@2.2.0
  +-- feathers@2.1.1  deduped
  `-- feathers-authentication-client@0.3.2  deduped

NodeJS version:
Node v6.10.2
NPM v4.5.0
Operating System:
Win 10 Version 1607
Browser Version:
Chrome Version 58

I am trying to go off of this example but I don't know if I've diverged too far. I am following these two issues but I don't know if those are what I need.. I'm mostly confused.

If I did something wrong let me know I'm fairly certain there's some config I must have messed up. I had the initial authentication working yesterday, but was trying to add cookies so that the server would remember users on refresh/login... and now auth doesn't seem to work at all.

The repo was based off of what feathers CLI gave me, but I've been tinkering with it a lot to add express-vue, routing, and angular so I may have moved something I shouldn't have.

But, I did get all of those pieces mostly working! If I remove the authorization from the routes Donuts actually works - which is amazing! I really love that 🎆 I just started using feathers this week and I've made so much progress (and it was nice to immediately get a REST client) - good job friends!

@snewell92

This comment has been minimized.

Copy link
Author

snewell92 commented May 12, 2017

Actually, if this is a 'I don't really know how to use this, is this correct' question it belongs on SO not here... if that is indeed the case I can close this issue, but I thought I was following the docs.

@matthewshirley

This comment has been minimized.

Copy link

matthewshirley commented May 14, 2017

When default.json is set to use 'username' as the usernameField it outputs my Windows username, 'Matt'.

Surprisingly, this is intended behaviour because feathers-configuration checks to see if a value is a part of the OS environment: https://github.com/feathersjs/feathers-configuration/blob/master/src/index.js#L26

usernameField Debugger
username feathers-debug
user feathers-debug

Workaround for OP

Change the username field or manually set this configuration in authentication.js, for example:

  // Set up authentication with the secret
  const localConfig = {
    'entity': 'users',
    'service': 'users',
    'usernameField': 'username',
    'passwordField': 'password'
  }; 

  app.configure(authentication(config));
  app.configure(local(localConfig));
@daffl

This comment has been minimized.

Copy link
Member

daffl commented May 16, 2017

You can also escape the configuration value in your default.json by using \\username. This will not pull in the environment variable.

@snewell92

This comment has been minimized.

Copy link
Author

snewell92 commented May 16, 2017

Thanks guys!

@snewell92 snewell92 closed this May 16, 2017

@lfernando-silva

This comment has been minimized.

Copy link

lfernando-silva commented Jun 26, 2017

@matthewshirley thanks a lot. It took me so much time!

@hbj

This comment has been minimized.

Copy link

hbj commented Aug 26, 2018

For information, this also happens for feathers applications managed by PM2 as it adds the environment variable username which leads to this same situation.

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.