Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix cyclic import in the module API #11180

Merged
merged 6 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/11180.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Port the Password Auth Providers module interface to the new generic interface.
2 changes: 1 addition & 1 deletion synapse/module_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
from synapse.http.site import SynapseRequest
from synapse.logging.context import make_deferred_yieldable, run_in_background
from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.rest.client.login import LoginResponse
from synapse.storage import DataStore
from synapse.storage.database import DatabasePool, LoggingTransaction
from synapse.storage.databases.main.roommember import ProfileInfo
from synapse.storage.state import StateFilter
from synapse.types import (
DomainSpecificString,
JsonDict,
LoginResponse,
Requester,
UserID,
UserInfo,
Expand Down
16 changes: 2 additions & 14 deletions synapse/rest/client/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

import logging
import re
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, List, Optional, Tuple

from typing_extensions import TypedDict
from typing import TYPE_CHECKING, Awaitable, Callable, Dict, List, Optional, Tuple

from synapse.api.errors import Codes, LoginError, SynapseError
from synapse.api.ratelimiting import Ratelimiter
Expand All @@ -36,24 +34,14 @@
from synapse.http.site import SynapseRequest
from synapse.rest.client._base import client_patterns
from synapse.rest.well_known import WellKnownBuilder
from synapse.types import JsonDict, UserID
from synapse.types import JsonDict, LoginResponse, UserID

if TYPE_CHECKING:
from synapse.server import HomeServer

logger = logging.getLogger(__name__)


class LoginResponse(TypedDict, total=False):
user_id: str
access_token: str
home_server: str
expires_in_ms: Optional[int]
refresh_token: Optional[str]
device_id: str
well_known: Optional[Dict[str, Any]]


class LoginRestServlet(RestServlet):
PATTERNS = client_patterns("/login$", v1=True)
CAS_TYPE = "m.login.cas"
Expand Down
20 changes: 20 additions & 0 deletions synapse/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import attr
from frozendict import frozendict
from signedjson.key import decode_verify_key_bytes
from typing_extensions import TypedDict
from unpaddedbase64 import decode_base64
from zope.interface import Interface

Expand Down Expand Up @@ -796,3 +797,22 @@ class UserInfo:
is_deactivated: bool
is_guest: bool
is_shadow_banned: bool


class LoginResponse(TypedDict, total=False):
"""Represents a response to a POST /login request.

The description of the fields can be found here:
https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-login

This response may also include the two additional fields from MSC2918 (refresh
tokens), which are `expires_in_ms` and `refresh_token`.
"""

user_id: str
access_token: str
home_server: str
expires_in_ms: Optional[int]
refresh_token: Optional[str]
device_id: str
well_known: Optional[Dict[str, Any]]