revoke된 세션 처리 추가

This commit is contained in:
2025-08-15 13:23:04 +09:00
parent d26b3b9295
commit c0ab2afcf4
3 changed files with 11 additions and 12 deletions

View File

@ -74,10 +74,6 @@ func make_storagekey(acc primitive.ObjectID) storagekey {
return storagekey(acc.Hex() + hex.EncodeToString(bs[2:]))
}
func AccountToSessionKey(acc primitive.ObjectID) string {
return string(make_storagekey(acc))
}
func storagekey_to_publickey(sk storagekey) publickey {
bs, _ := hex.DecodeString(string(sk))

View File

@ -257,6 +257,15 @@ func (c *consumer_redis) Query(pk string) (Authorization, error) {
defer c.lock.Unlock()
sk := publickey_to_storagekey(publickey(pk))
if _, deleted := c.stages[0].deleted[sk]; deleted {
return Authorization{}, nil
}
if _, deleted := c.stages[1].deleted[sk]; deleted {
return Authorization{}, nil
}
si, err := c.query_internal(sk)
if err != nil {
logger.Println("session consumer query :", pk, err)

View File

@ -591,14 +591,8 @@ func (ws *WebsocketHandler) mainLoop(ctx context.Context) {
} else if ws.sessionConsumer.IsRevoked(c.sender.Accid) {
c.Conn.MakeWriter().WriteControl(websocket.CloseMessage, unauthdata, time.Time{})
} else {
sk := session.AccountToSessionKey(c.sender.Accid)
auth, _ := ws.sessionConsumer.Query(sk)
if auth.Account != c.sender.Accid {
c.Conn.MakeWriter().WriteControl(websocket.CloseMessage, unauthdata, time.Time{})
} else {
entireConns[c.sender.Accid.Hex()] = c
go ws.ClientConnected(c)
}
entireConns[c.sender.Accid.Hex()] = c
go ws.ClientConnected(c)
}
case accid := <-ws.forceCloseChan: