Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Is there a way to append user_id as request header after jwtware? #90

Open
mareimorsy opened this issue May 19, 2022 · 2 comments
Open
Labels
🤔 Question Further information is requested

Comments

@mareimorsy
Copy link

I'm using jwtware to validate user jwt, but I'd like to extract the user_id from the jwt payload and append it to the request header, I could implement my own middleware I just wanna ask is there already a feature like this?

Thanks in advance <3

@mareimorsy
Copy link
Author

I figured out this :

user_id := c.Locals("user").(*jwt.Token).Claims.(jwt.MapClaims)["id"]

by casting the empty interface returned from locals to MapClaims then getting the id from the map, please advice if you have a better approach

@ReneWerner87 ReneWerner87 added the 🤔 Question Further information is requested label May 20, 2022
@ReneWerner87
Copy link
Member

ReneWerner87 commented May 20, 2022

That should be ok.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤔 Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants