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

Verifier implementation #978

Closed
guillaumervls opened this issue Sep 5, 2018 · 5 comments
Closed

Verifier implementation #978

guillaumervls opened this issue Sep 5, 2018 · 5 comments

Comments

@guillaumervls
Copy link

Hi and thanks for the framework,

I need to customize my local authentication strategy. For that I can provide a subclass of local.Verifier with a custom verify method. The problem is that in this method I need to return the token payload, and if I don't use the form { [`${this.options.entity}Id`]: id } like in the default one, it won't be working with the jwt.Verifier class used by the jwt strategy (among other since it looks like each strategy module gets its own Verifier class).

Should there be a single source of truth for this ? Like somewhere a unique (possibly also overridable) function entity => jwtPayload ?

Am I missing something ?

Cheers

@daffl
Copy link
Member

daffl commented Sep 7, 2018

Yes there should be and the use id should really be included in the tokens sub header instead of the payload. This will be possible in the next version.

@matiaslopezd
Copy link

@daffl Hi!

I have a problems follow this docs trying create my custom Verifier because import return error of syntax.

import local, { Verifier } from '@feathersjs/authentication-local';

class CustomVerifier extends Verifier {
 //Custom code
}
import local, { Verifier } from '@feathersjs/authentication-local';
       ^^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:79:7)
    at createScript (vm.js:251:10)
    at Object.runInThisContext (vm.js:303:10)
    at Module._compile (internal/modules/cjs/loader.js:656:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\xampp\htdocs\api-feathers\src\app.js:22:24)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)

The only way to make my custom Verifier is with this method:

authentication.js

const local = require('@feathersjs/authentication-local');

class CustomVerifier extends local.Verifier {
 //Custom code
}

@daffl
Copy link
Member

daffl commented Feb 27, 2019

It is indeed, I updated the docs.

@matiaslopezd
Copy link

The same with JWT Verifier. Pull request: #1276 in docs.

@daffl
Copy link
Member

daffl commented Jun 6, 2019

Setting the sub properly has been implemented in Feathers v4 authentication. See the Migration guide for more information on how to upgrade.

@daffl daffl closed this as completed Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants