dwyl / hapi-typescript-example

:zap: Hapi.Js + Typescript = Awesomeness
MIT License
354 stars 104 forks source link

How to verify validation token? #6

Closed francoberton closed 7 years ago

francoberton commented 7 years ago

I would like to know how to implement a rest-api to check secret and expiration

Talento90 commented 7 years ago

Hello @francoberton, basically I am using jwt2 plugin (https://github.com/dwyl/hapi-typescript-example/blob/master/src/plugins/jwt-auth/index.ts).

If you want to learn more about JWT Authentication read this: https://github.com/dwyl/hapi-auth-jwt2

francoberton commented 7 years ago

Thank you Marco for quick answer, I didn't notice the validate function associated to plugin, so the function is executed for each REST-api that provide the authentication. Is it right?

Talento90 commented 7 years ago

Sorry for the late answer.

Yes exactly! But you can have multiple strategies, jwt, cookies, basic. You can define the name when you are registering the plugin.

francoberton commented 7 years ago

Perfect, thank you very much for your help!