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

Authentication service doesn't work with versions? #1

Open
georgeedwards opened this issue Oct 14, 2017 · 8 comments
Open

Authentication service doesn't work with versions? #1

georgeedwards opened this issue Oct 14, 2017 · 8 comments
Labels

Comments

@georgeedwards
Copy link

I tried adding this to my project, and changing all my services to be registered on app.v1. However, I am having issues with the authentication service, as it isn;t registered in the normal way. Then I get this error:

\node_modules\feathers-authentication-jwt\lib\verifier.js:32
[1]       throw new Error('options.service does not exist.\n\tMake sure you are passing a valid service path or service instance and it is initialized before feathers-authentication-jwt.');
[1]       ^
[1]
[1] Error: options.service does not exist.
[1]     Make sure you are passing a valid service path or service instance and it is initialized before feathers-authentication-jwt.
@luke3butler
Copy link
Owner

Thanks for the report!

Do you have general steps needed to reproduce this? I'm going to sit down and tackle this asap.

This is definitely something a test should be written for as well.

@georgeedwards
Copy link
Author

Sure - thanks!

I created a default application and added authentication, added:

app.configure(versionate());
// Register a base-path "/api/v2", and provide access to it via `app.v2`
app.versionate('v1',  '/api/v1/');

straight after export const app = feathers(); in app.js.

Then change the services to the form:

export function users() {
  const app = this;
  const paginate = app.get('paginate');
  const User = app.get('sequelizeClient')._['User'];

  const options = {
    name: 'users',
    Model: User,
    paginate
  };

  const userService = createService(options);

  // Initialize our service with any options it requires
  app.v1.use('users', userService);

  // Get our initialized service so that we can register hooks and filters
  const service = app.v1.service('users');

  service.hooks(hooks);

  if (service.filter) {
    service.filter(filters);
  }
};

@luke3butler
Copy link
Owner

Awesome! I'll add to this issue when progress is made.

@georgeedwards
Copy link
Author

@luke3butler Is there anything else you need from me?

@luke3butler
Copy link
Owner

@georgeedwards I haven't gotten time to dive into this too much yet.
Have you set up authentication before without feathers-versionate?

I would suggest defining the full path in the authentication options for now until I get this sorted. feathers-authentication isn't something I've spent a lot of time with yet, so I need to get a handle on it.

It looks like custom services might not be supported yet? If I need to, I'll get confirmation from a core dev once I get a better grip on this.

@georgeedwards
Copy link
Author

georgeedwards commented Oct 19, 2017

@luke3butler Yes, it was set up before I added feathers versionate to the project.

but when using your package I have this in my app.ts file:

import * as versionate from 'feathers-versionate';
export const app = <any>feathers();

app.configure(versionate());
app.versionate('v1', '/api/v1/');

And my services are shown above. However, my API's are still being served on http://localhost:3030/users rather than http://localhost:3030/apiu/v1/users. Have I missunderstood how this works?

@luke3butler luke3butler added the bug label Nov 2, 2017
@luke3butler
Copy link
Owner

I've taken a look and I'm going to dedicate some time to get this resolved, but there is no current ETA.

Will update here and update with any progress I've made.

I'm open to PRs!

@3CordGuy
Copy link

3CordGuy commented Apr 6, 2018

I would suggest defining the full path in the authentication options for now until I get this sorted.

I can't seem to get this to work with explicitly defining the version full path in authentication.js to match the versionate path. Seems like a great service though.

EDIT: I had forgotten to change the auth service path in the config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants