tokenrefresh.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright 2015, 2016 OpenMarket Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import TYPE_CHECKING
  15. from twisted.web.server import Request
  16. from synapse.api.errors import AuthError
  17. from synapse.http.server import HttpServer
  18. from synapse.http.servlet import RestServlet
  19. from ._base import client_patterns
  20. if TYPE_CHECKING:
  21. from synapse.server import HomeServer
  22. class TokenRefreshRestServlet(RestServlet):
  23. """
  24. Exchanges refresh tokens for a pair of an access token and a new refresh
  25. token.
  26. """
  27. PATTERNS = client_patterns("/tokenrefresh")
  28. def __init__(self, hs: "HomeServer"):
  29. super().__init__()
  30. async def on_POST(self, request: Request) -> None:
  31. raise AuthError(403, "tokenrefresh is no longer supported.")
  32. def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
  33. TokenRefreshRestServlet(hs).register(http_server)