mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 01:59:21 -05:00
Name the type of token in "Invalid token" messages (#10815)
I had one of these error messages yesterday and assumed it was an invalid auth token (because that was an HTTP query parameter in the test) I was working on. In fact, it was an invalid next batch token for syncing.
This commit is contained in:
parent
01c88a09cd
commit
319b8b6bef
1
changelog.d/10815.misc
Normal file
1
changelog.d/10815.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Specify the type of token in generic "Invalid token" error messages.
|
@ -1347,7 +1347,7 @@ class AuthHandler(BaseHandler):
|
|||||||
try:
|
try:
|
||||||
res = self.macaroon_gen.verify_short_term_login_token(login_token)
|
res = self.macaroon_gen.verify_short_term_login_token(login_token)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise AuthError(403, "Invalid token", errcode=Codes.FORBIDDEN)
|
raise AuthError(403, "Invalid login token", errcode=Codes.FORBIDDEN)
|
||||||
|
|
||||||
await self.auth.check_auth_blocking(res.user_id)
|
await self.auth.check_auth_blocking(res.user_id)
|
||||||
return res
|
return res
|
||||||
|
@ -73,7 +73,7 @@ class RelationPaginationToken:
|
|||||||
t, s = string.split("-")
|
t, s = string.split("-")
|
||||||
return RelationPaginationToken(int(t), int(s))
|
return RelationPaginationToken(int(t), int(s))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise SynapseError(400, "Invalid token")
|
raise SynapseError(400, "Invalid relation pagination token")
|
||||||
|
|
||||||
def to_string(self) -> str:
|
def to_string(self) -> str:
|
||||||
return "%d-%d" % (self.topological, self.stream)
|
return "%d-%d" % (self.topological, self.stream)
|
||||||
@ -103,7 +103,7 @@ class AggregationPaginationToken:
|
|||||||
c, s = string.split("-")
|
c, s = string.split("-")
|
||||||
return AggregationPaginationToken(int(c), int(s))
|
return AggregationPaginationToken(int(c), int(s))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise SynapseError(400, "Invalid token")
|
raise SynapseError(400, "Invalid aggregation pagination token")
|
||||||
|
|
||||||
def to_string(self) -> str:
|
def to_string(self) -> str:
|
||||||
return "%d-%d" % (self.count, self.stream)
|
return "%d-%d" % (self.count, self.stream)
|
||||||
|
@ -511,7 +511,7 @@ class RoomStreamToken:
|
|||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
raise SynapseError(400, "Invalid token %r" % (string,))
|
raise SynapseError(400, "Invalid room stream token %r" % (string,))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_stream_token(cls, string: str) -> "RoomStreamToken":
|
def parse_stream_token(cls, string: str) -> "RoomStreamToken":
|
||||||
@ -520,7 +520,7 @@ class RoomStreamToken:
|
|||||||
return cls(topological=None, stream=int(string[1:]))
|
return cls(topological=None, stream=int(string[1:]))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
raise SynapseError(400, "Invalid token %r" % (string,))
|
raise SynapseError(400, "Invalid room stream token %r" % (string,))
|
||||||
|
|
||||||
def copy_and_advance(self, other: "RoomStreamToken") -> "RoomStreamToken":
|
def copy_and_advance(self, other: "RoomStreamToken") -> "RoomStreamToken":
|
||||||
"""Return a new token such that if an event is after both this token and
|
"""Return a new token such that if an event is after both this token and
|
||||||
@ -619,7 +619,7 @@ class StreamToken:
|
|||||||
await RoomStreamToken.parse(store, keys[0]), *(int(k) for k in keys[1:])
|
await RoomStreamToken.parse(store, keys[0]), *(int(k) for k in keys[1:])
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise SynapseError(400, "Invalid Token")
|
raise SynapseError(400, "Invalid stream token")
|
||||||
|
|
||||||
async def to_string(self, store: "DataStore") -> str:
|
async def to_string(self, store: "DataStore") -> str:
|
||||||
return self._SEPARATOR.join(
|
return self._SEPARATOR.join(
|
||||||
|
Loading…
Reference in New Issue
Block a user