add support for 1.19 "Secure Chat Signing"

This commit is contained in:
2022-09-18 02:53:08 +08:00
parent fa86f0cfdb
commit 3dd53caea4
7 changed files with 172 additions and 34 deletions

View File

@@ -47,7 +47,11 @@ func NewSessionService(service TokenService) SessionService {
func (s *sessionStore) JoinServer(accessToken string, serverId string, selectedProfile string, ip string) error {
token, ok := s.tokenService.GetToken(accessToken)
if ok && util.UnsignedString(token.SelectedProfile.Id) == selectedProfile {
if ok {
if token.GetAvailableLevel() != model.Valid ||
util.UnsignedString(token.SelectedProfile.Id) != selectedProfile {
return util.NewForbiddenOperationError(util.MessageInvalidToken)
}
session := model.NewAuthenticationSession(serverId, token, ip)
s.sessionCache.Add(serverId, &session)
} else {