Exposed Rest Api - Jwt Auth- Persist values between OnAuthenticate and Action

Hi to all,

I've developed a rest api that use a custom authentication that check the presence of a bearer token in the header of the request and if present validate the values included in payload.

I've action "VerifyToken" that read the jwt payload and extract a structure with some data inside, these data must be used to perform some security checks inside OnAuhtentication and others must be used inside the rest methods to perform logic action.

Now the flow is :

  1. The rest api receive request
  2. The OnAuthentication is triggered 
  3. An rest action that retrieve or edit the data 

In the points 2 & 3 i call VerifyToken, but since the structures returned are the same I find it pointless to call it twice

It's possibile to persist value from OnAuthentication and reuse it in the action methods? (I've also tried to use OnRequest trigger but unsuccessfully)



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.