-
Notifications
You must be signed in to change notification settings - Fork 0
Split session #25
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
Split session #25
Conversation
david-littlefarmer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do i understand it right, that on every request we create new JWT verifier and check the token against it?
If so, then why not to predefine them for exmaple in array and just try to iterate through them, until the one of them is successful since the private and/or public keys are defined on startup of server.
Also can you please describe some simple flow of verifier? I find it confusing.
7ff1c5c to
d1a1668
Compare
VojtechVitek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, this is getting better!
| } | ||
|
|
||
| func Session(cfg Options) func(next http.Handler) http.Handler { | ||
| func VerifyToken(cfg Options) func(next http.Handler) http.Handler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we could split Options struct into two types -- one for Verifier and one for Sessions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho, this middleware needs nothing but JWTSecret and ErrHandler. It should always verify HS256 JWT from both Authorization header and Cookie.
I don't see the need for AuthProvider interface. Is it useful for anything else? I think it just locks us down to this implementation -- switching algorithms, jwks or supporting secret rotation or multiple algorithms would be more difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho, stack/api's ProjectJWTVerifier should be a a separate implementation that doesn't have anything in common with this Verifier except for passing the token into context via ctx = jwtauth.NewContext(ctx, token, nil)
| } | ||
| } | ||
|
|
||
| func Session(cfg Options) func(next http.Handler) http.Handler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Session needs ErrorHandler, UserStore and a way to fetch AccessKey.
34dbc3e to
30ad26a
Compare
proto/authcontrol.ridl
Outdated
| webrpc = v1 | ||
|
|
||
| name = access-control | ||
| name = auth-control |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| name = auth-control | |
| name = authcontrol |
Split session and verify middleware.
JWT Auth is created by an interface, which has two implementations: