feathersjs-ecosystem / authentication-oauth2

[MOVED] OAuth 2 plugin for feathers-authentication
https://github.com/feathersjs/feathers
MIT License
26 stars 15 forks source link

Pass a Custom id field for service (serviceId) #67

Closed duttonkj closed 6 years ago

duttonkj commented 6 years ago

Summary

We use a custom id field for our feathers services (_id). The verifier checks for the service id on the user object using the default .id. In our case, it throws an error: debug('failed: the service.id was not set'); Also, patches to the user record fail and the userId is not properly set in the token payload due to the same issue.

This may not best the solution, but we are proposing passing in an serviceId when configuring oauth2:

const oauth2Config = {
    name: 'sampleStrategry',
    Strategy: Strategy,
    clientID: config.clientID,
    clientSecret: config.clientSecret,
    passReqToCallback: true,
    // Pass in our custom service id
    serviceId: '_id'
};

This would default to id when not passed

Nope.

Not at the moment. If this solution is accepted I would open pull request in following packages for related issues:

Thanks for all the hard work on feathersjs!

daffl commented 6 years ago

As long as your service has the id property pointing to its id field it should already work.

app.service('mycustomService').id = 'customIdField';
daffl commented 6 years ago

Thank you for the PR! I'm going to close it though since this should already be solvable with what I suggested instead of adding a new configuration option that has to be documented and tested.