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

Error: Could not find stored JWT and no authentication strategy was given #367

Closed
foxhound87 opened this Issue Dec 12, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@foxhound87
Copy link

foxhound87 commented Dec 12, 2016

I just discovered that I can connect using the cookie by using authenticate() without params:

cookie

This info is missing from the docs (and should be documented as I thought I had to put in something like session or cookie strategy as param).

The method is running on both client and server side, It seems to work,
but on the client side, if the user is not yet authenticated, I get this:

Error: Could not find stored JWT and no authentication strategy was given
at NotAuthenticated.ExtendableBuiltin

If I remove the the method from the client side, it stop working (the user is no longer authenticated).

@ekryski

This comment has been minimized.

Copy link
Member

ekryski commented Dec 12, 2016

See my other comment. #366 (comment). Fix is coming to the auth client. 😄

@foxhound87

This comment has been minimized.

Copy link
Author

foxhound87 commented Dec 12, 2016

Now I see that the message is shown on the server side too.

Thank You.

@foxhound87

This comment has been minimized.

Copy link
Author

foxhound87 commented Dec 13, 2016

I miss something for SSR. I'm not able to use authenticate() without params on the server side.
It always says: feathers-authentication:passport:authenticate Authentication strategy 'jwt' failed +0ms Error: No auth token

My client side feathers app (configured with sockets - no rest) should be universal, and the same code used on the client-side should be called on the server-side too.

So I need to authenticate on the server side, I think I need to pass the jwt token from the cookie to authenticate({ strategy: 'jwt', accessToken: token }).

But I'm not able to access the token from the cookie, using DEBUG=feathers* it tells me it's present somewhere, but how can I access it? Is it currently possible with the 1.0.0-beta-2?

And maybe I should setup a different storage (don't know what) for feathers-authentication-client on the server.

Thank You.

  feathers-socket-commons:methods Got 'post::find' event with connection +25ms { provider: 'socketio',
  user: 
   { payload: 
      { userId: 'a1456682-f6c6-49e5-b650-788f1cd98bb6',
        iat: 1481595209,
        exp: 1481681609,
        aud: 'https://yourdomain.com',
        iss: 'feathers',
        sub: 'anonymous' },
     '$__': 
      InternalCache {
        strictMode: true,
        selected: undefined,
        shardval: undefined,
        saveError: undefined,
        validationError: undefined,
        adhocPaths: undefined,
        removing: undefined,
        inserting: undefined,
        version: undefined,
        getters: {},
        _id: undefined,
        populate: undefined,
        populated: undefined,
        wasPopulated: false,
        scope: undefined,
        activePaths: [Object],
        ownerDocument: undefined,
        fullPath: undefined,
        emitter: [Object] },
     isNew: false,
     errors: undefined,
     _doc: 
      { createdAt: 2016-08-06T22:20:07.645Z,
        updatedAt: 2016-08-06T22:20:07.645Z,
        __v: 0,
        uuid: 'a1456682-f6c6-49e5-b650-788f1cd98bb6',
        username: 'savino87@gmail.com',
        password: '$2a$10$CaqBw5yVBAueW75KyZcwKeg2qlENP8WWiiQkqTzw2wmTd.GLzAX6q',
        email: 'savino87@gmail.com',
        _id: 57a66297eecd0449439794c5 },
     '$__original_save': { [Function] numAsyncPres: 1 },
     save: [Function: wrappedPointCut],
     _pres: 
      { '$__original_save': [Object],
        '$__original_validate': [Object],
        '$__original_remove': [Object] },
     _posts: 
      { '$__original_save': [],
        '$__original_validate': [],
        '$__original_remove': [] },
     '$__original_validate': { [Function] numAsyncPres: 1 },
     validate: [Function: wrappedPointCut],
     '$__original_remove': { [Function] numAsyncPres: 1 },
     remove: [Function: wrappedPointCut] },
  payload: { userId: 'a1456682-f6c6-49e5-b650-788f1cd98bb6' },
  accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6ImFjY2VzcyJ9.eyJ1c2VySWQiOiJhMTQ1NjY4Mi1mNmM2LTQ5ZTUtYjY1MC03ODhmMWNkOThiYjYiLCJpYXQiOjE0ODE1OTUyNjYsImV4cCI6MTQ4MTY4MTY2NiwiYXVkIjoiaHR0cHM6Ly95b3VyZG9tYWluLmNvbSIsImlzcyI6ImZlYXRoZXJzIiwic3ViIjoiYW5vbnltb3VzIn0.p_Q3hINt8mmdkbu3NtlNiWULzorU5skj7y5hSSEXPbE',
  headers: { Authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6ImFjY2VzcyJ9.eyJ1c2VySWQiOiJhMTQ1NjY4Mi1mNmM2LTQ5ZTUtYjY1MC03ODhmMWNkOThiYjYiLCJpYXQiOjE0ODE1OTUyNjYsImV4cCI6MTQ4MTY4MTY2NiwiYXVkIjoiaHR0cHM6Ly95b3VyZG9tYWluLmNvbSIsImlzcyI6ImZlYXRoZXJzIiwic3ViIjoiYW5vbnltb3VzIn0.p_Q3hINt8mmdkbu3NtlNiWULzorU5skj7y5hSSEXPbE' },
  authenticated: true }
@ekryski

This comment has been minimized.

Copy link
Member

ekryski commented Dec 30, 2016

There were a bunch of bugs fixed around cookies after you reported this issue. I think this is now resolved if you update to all the latest auth modules. If not we can re-open for sure!

@ekryski ekryski closed this Dec 30, 2016

@foxhound87

This comment has been minimized.

Copy link
Author

foxhound87 commented Dec 30, 2016

Thank you for the support!

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.