-
Notifications
You must be signed in to change notification settings - Fork 380
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
different Authorizator depending on Router Groups #25
Comments
maybe you can use belown method func xxAuthorizator func(userID string, c *gin.Context) bool {
claims := jwt.ExtractClaims(c)
//.... get token and do your things
} |
Hi @philippecarle, or anyone else, did you find an elegant solution to this? I also would like to pass a different Thanks! |
@arrwhidev you can create a single middleware and switch between its parameter:
And then, create your gin group router like this:
|
@alcmoraes, could you be more detailed ? how to distinguish normal user, admin user, guest user?
Could you explain these lines ? |
Currently I hacked in the gin-jwt source code, like this, to by pass the authenticator function for normal users, so I achieved 3 roles, normal user, admin, and guest without login
Then I used such middleware function like,
|
Hi,
(thx for having merged so quickly my PR on Context injection ^^)
I'm facing an issue, and I think it may be a functional / logical problem in Authorization implementation and / or limitations cause by lack of informations about groups in gin.Context.
For example, here are my groups definitions for admin/users :
By using your Authorizator callback, I have to be aware of two informations :
Each leads me to an issue :
Should I implement my own solution like writing a specific Middleware, with an string argument telling me what group is called ? Or is there any more elegant way to fix this ?
The text was updated successfully, but these errors were encountered: