appview/oauth: use ResumeSession when fetching currently logged in user #723

merged
opened by oppi.li targeting master from push-orvkryxksqsz

the final addition to my collection of oauth fixes: the session cookie is not a sufficient indication of a logged-in-ness of a user, we additionally validate this cookie against the session on redis using ResumeSession and kick users out if their session is invalid.

previously, a user may have appeared to be logged in (via the profile picture on the top right), but creating an auth'd request would have login-prompted them.

Signed-off-by: oppiliappan me@oppi.li

Changed files
+4 -5
appview
oauth
+4 -5
appview/oauth/oauth.go
···
}
func (o *OAuth) GetUser(r *http.Request) *User {
-
sess, err := o.SessStore.Get(r, SessionName)
-
-
if err != nil || sess.IsNew {
+
sess, err := o.ResumeSession(r)
+
if err != nil {
return nil
}
return &User{
-
Did: sess.Values[SessionDid].(string),
-
Pds: sess.Values[SessionPds].(string),
+
Did: sess.Data.AccountDID.String(),
+
Pds: sess.Data.HostURL,
}
}