Fix local auth strategy, pass authed entity for hooks to use#1320
Fix local auth strategy, pass authed entity for hooks to use#1320KidkArolis wants to merge 4 commits intofeathersjs:masterfeathersjs/feathers:masterfrom KidkArolis:fix-local-strategyKidkArolis/feathers:fix-local-strategyCopy head branch name to clipboard
Conversation
402b05f to
c50b365
Compare
|
Because this is making 2 calls now, one internal to resolve entity and check credentials and 1 on behalf of the external call, I had to whitelist the What if instead of using findEntity() the 2nd time, we instead use Specifically, because in my case, it wasn't a straight up failure, because I wasn't allowing |
|
I'm running into the same issue with the |
|
Had to use this locally, double get: class CustomJWTStrategy extends JWTStrategy {
async getEntity(id, params) {
const { entity } = this.configuration
const entityService = this.entityService
if (entityService === null) {
throw new errors.NotAuthenticated(`Could not find entity service`)
}
const result = await entityService.get(id, omit(params, 'provider'))
return entityService.get(id, { ...params, [entity]: result, authenticated: true, [AUTHENTICATE]: false })
}
} |
|
One suggestion, in addition to double fetching as appropriate in both local and jwt strategies, what about putting the second fetch into a dedicated method, something like |
|
Not 100% sure yet, but I think there's another issue here with passing all params from client as is. The query could be meant for another resource, e.g.: THis is query for emergency-contacts service. But the authentication strategy passes that as query to the |
|
I have pushed another commit similarly fixing the
My modification checks if the call is internal (coming from authenticate hook) or external (coming from /authentication endpoint) and either does the double entity resolution or does not. As before, I suggest to add |
Should it be
or
?