buggy
stringlengths
35
5.03k
fixed
stringlengths
46
62.5k
def _parse_authz(self, query="", **kwargs): self.redirect_uris = [self.sdb[_state]["redirect_uris"]] return aresp, _state def parse_authz(self, query="", **kwargs): """ Parse authorization response from server.
def _parse_authz(self, query="", **kwargs): self.redirect_uris = [self.sdb[_state]["redirect_uris"]] return aresp, _state def parse_authz( self, query="", **kwargs ) -> Union[ http_util.BadRequest, Tuple[ Optional[AuthorizationResponse], Optional[...
def parse_authz(self, query="", **kwargs): ["id_token"] ["id_token", "token"] ["token"] :return: A AccessTokenResponse instance """ _log_info = logger.info logger.debug("- authorization -") if not query: return http_util.BadRequest("Missing q...
def parse_authz(self, query="", **kwargs): ["id_token"] ["id_token", "token"] ["token"] """ _log_info = logger.info logger.debug("- authorization -") # FIXME: This shouldn't be here... We should rather raise a sepcific Client error # That would simplify t...
def parse_authz(self, query="", **kwargs): except KeyError: pass return aresp, atr, idt elif "token" in self.consumer_config["response_type"]: # implicit flow _log_info("Expect Access Token Response") atr = self.parse_response( ...
def parse_authz(self, query="", **kwargs): except KeyError: pass elif "token" in self.consumer_config["response_type"]: # implicit flow _log_info("Expect Access Token Response") aresp = None _state = None atr = self.parse_resp...
def parse_authz(self, query="", **kwargs): if isinstance(atr, ErrorResponse): raise TokenError(atr.get("error"), atr) idt = None return None, atr, idt else: # only id_token aresp, _state = self._parse_authz(query, **kwargs)
def parse_authz(self, query="", **kwargs): if isinstance(atr, ErrorResponse): raise TokenError(atr.get("error"), atr) idt = atr.get("id_token") else: # only id_token aresp, _state = self._parse_authz(query, **kwargs)
def parse_authz(self, query="", **kwargs): session_update(self.sso_db, _state, "smid", idt["sid"]) except KeyError: pass return None, None, idt def complete(self, state): """
def parse_authz(self, query="", **kwargs): session_update(self.sso_db, _state, "smid", idt["sid"]) except KeyError: pass # Null the aresp as only id_token should be returned aresp = atr = None # Verify the IdToken if it was present...
def verify_id_token(instance, check_hash=False, **kwargs): if check_hash: _alg = idt.jws_header["alg"] # What if _alg == 'none' hfunc = "HS" + _alg[-3:] if "access_token" in instance: if "at_hash" not in idt: raise MissingRequiredAttribute("Missing at_h...
def verify_id_token(instance, check_hash=False, **kwargs): if check_hash: _alg = idt.jws_header["alg"] if _alg != "none": hfunc = "HS" + _alg[-3:] else: # This is allowed only for `code` and it needs to be checked by a Client hfunc = None if "acc...
def verify(self, **kwargs): else: if (_iat + _storage_time) < (_now - _skew): raise IATError("Issued too long ago") return True
def verify(self, **kwargs): else: if (_iat + _storage_time) < (_now - _skew): raise IATError("Issued too long ago") if _now < (_iat - _skew): raise IATError("Issued in the future") if _exp < _iat: raise EXPError("Invalid expiration tim...
from jwkest.jwk import SYMKey from oic.oauth2.message import MissingSigningKey from oic.oic import DEF_SIGN_ALG from oic.oic import Server from oic.oic import response_types_to_grant_types from oic.oic.consumer import IGNORE from oic.oic.consumer import Consumer from oic.oic.consumer import clean_response from oic.oic...
from jwkest.jwk import SYMKey from oic.oauth2.message import MissingSigningKey from oic.oauth2.message import WrongSigningAlgorithm from oic.oic import DEF_SIGN_ALG from oic.oic import Server from oic.oic import response_types_to_grant_types from oic.oic.consumer import IGNORE from oic.oic.consumer import Consumer fro...
def setup_consumer(self, session_db_factory): self.consumer.userinfo_endpoint = "https://example.com/userinfo" # type: ignore self.consumer.client_secret = "hemlig" self.consumer.secret_type = "basic" def test_backup_keys(self): keys = self.consumer.__dict__.keys()
def setup_consumer(self, session_db_factory): self.consumer.userinfo_endpoint = "https://example.com/userinfo" # type: ignore self.consumer.client_secret = "hemlig" self.consumer.secret_type = "basic" self.consumer.provider_info = ProviderConfigurationResponse( issuer="https...
def test_parse_authz(self): self.consumer._backup(_state) part = self.consumer.parse_authz(query=result.headers["location"]) atr = part[0] assert part[1] is None assert part[2] is None
def test_parse_authz(self): self.consumer._backup(_state) part = self.consumer.parse_authz(query=result.headers["location"]) assert isinstance(part, tuple) atr = part[0] assert part[1] is None assert part[2] is None
def test_parse_authz_implicit(self): ) part = self.consumer.parse_authz(query=result.headers["location"]) assert part[0] is None atr = part[1] assert part[2] is None
def test_parse_authz_implicit(self): ) part = self.consumer.parse_authz(query=result.headers["location"]) assert isinstance(part, tuple) assert part[0] is None atr = part[1] assert part[2] is None
def test_complete_auth_token(self): parsed = urlparse(result.headers["location"]) part = self.consumer.parse_authz(query=parsed.query) auth = part[0] acc = part[1] assert part[2] is None
def test_complete_auth_token(self): parsed = urlparse(result.headers["location"]) part = self.consumer.parse_authz(query=parsed.query) assert isinstance(part, tuple) auth = part[0] acc = part[1] assert part[2] is None
def test_complete_auth_token_idtoken(self): _state = "state0" self.consumer.consumer_config["response_type"] = ["id_token", "token"] self.consumer.registration_response = RegistrationResponse( id_token_signed_response_alg="RS256" ) self.consumer.provider_info = Provid...
def test_complete_auth_token_idtoken(self): _state = "state0" self.consumer.consumer_config["response_type"] = ["id_token", "token"] self.consumer.registration_response = RegistrationResponse( id_token_signed_response_alg="HS256" ) self.consumer.authz_req = {} # Stor...
def test_complete_auth_token_idtoken(self): location = ( "https://example.com/cb?state=state0&access_token=token&token_type=bearer&" "scope=openid&id_token={}".format( token.to_jwt(key=KC_RSA.keys(), algorithm="RS256") ) ) with responses.Reques...
def test_complete_auth_token_idtoken(self): location = ( "https://example.com/cb?state=state0&access_token=token&token_type=bearer&" "scope=openid&id_token={}".format( token.to_jwt(key=[SYMKey(key="hemlig")], algorithm="HS256") ) ) with respons...
def test_complete_auth_token_idtoken(self): parsed = urlparse(result.headers["location"]) with freeze_time("2019-08-09 11:00:00"): part = self.consumer.parse_authz( query=parsed.query, algs=self.consumer.sign_enc_algs("id_token") ) auth = part[0] ...
def test_complete_auth_token_idtoken(self): parsed = urlparse(result.headers["location"]) with freeze_time("2019-08-09 11:00:00"): part = self.consumer.parse_authz(query=parsed.query, algs={"sign": "HS256"}) assert isinstance(part, tuple) auth = part[0] atr = part[1]...
def test_get_session_management_id(self): self.consumer.sdb[_state] = {"redirect_uris": ["https://example.org/cb"]} resp = AuthorizationResponse(id_token=_signed_jwt, state=_state) self.consumer.consumer_config["response_type"] = ["id_token"] self.consumer.parse_authz(resp.to_urlencoded(...
def test_get_session_management_id(self): self.consumer.sdb[_state] = {"redirect_uris": ["https://example.org/cb"]} resp = AuthorizationResponse(id_token=_signed_jwt, state=_state) self.consumer.consumer_config["response_type"] = ["id_token"] self.consumer.authz_req[_state] = AccessToken...
def test_logout_with_sub(self): "openid", "code", path="https://example.com" ) resp = self.provider.authorization_endpoint(request=request_location) aresp = self.consumer.parse_authz(resp.message) assert self.consumer.sdb[sid]["issuer"] == self.provider.baseurl # Si...
def test_logout_with_sub(self): "openid", "code", path="https://example.com" ) resp = self.provider.authorization_endpoint(request=request_location) part = self.consumer.parse_authz(resp.message) assert isinstance(part, tuple) aresp = part[0] assert aresp ...
def test_logout_without_sub(self): "openid", "code", path="https://example.com" ) resp = self.provider.authorization_endpoint(request=request_location) aresp = self.consumer.parse_authz(resp.message) assert self.consumer.sdb[sid]["issuer"] == self.provider.baseurl #...
def test_logout_without_sub(self): "openid", "code", path="https://example.com" ) resp = self.provider.authorization_endpoint(request=request_location) part = self.consumer.parse_authz(resp.message) assert isinstance(part, tuple) aresp = part[0] assert aresp ...
def test_sso_db_dict(self): "openid", "code", path="https://example.com" ) resp = self.provider.authorization_endpoint(request=request_location) aresp = _consumer.parse_authz(resp.message) assert _consumer.sdb[sid]["issuer"] == self.provider.baseurl # Simulate an ac...
def test_sso_db_dict(self): "openid", "code", path="https://example.com" ) resp = self.provider.authorization_endpoint(request=request_location) part = _consumer.parse_authz(resp.message) assert isinstance(part, tuple) aresp = part[0] assert aresp ass...
from urllib.parse import urlencode import pytest from jwkest import BadSignature from jwkest.jwk import SYMKey from jwkest.jws import left_hash
from urllib.parse import urlencode import pytest from freezegun import freeze_time from jwkest import BadSignature from jwkest.jwk import SYMKey from jwkest.jws import left_hash
from oic.oic.message import BackChannelLogoutRequest from oic.oic.message import CHashError from oic.oic.message import Claims from oic.oic.message import FrontChannelLogoutRequest from oic.oic.message import IdToken from oic.oic.message import LogoutToken from oic.oic.message import OpenIDSchema
from oic.oic.message import BackChannelLogoutRequest from oic.oic.message import CHashError from oic.oic.message import Claims from oic.oic.message import EXPError from oic.oic.message import FrontChannelLogoutRequest from oic.oic.message import IATError from oic.oic.message import IdToken from oic.oic.message import L...
def test_token_type(self): at.verify() def test_id_token(): _now = time_util.utc_time_sans_frac()
def test_token_type(self): at.verify() class TestIdToken(object): """Unittests for IdToken class.""" @freeze_time("2020-01-01 11:00:00") def test_verify_iat_in_future(self): now = time_util.utc_time_sans_frac() idt = IdToken( **{ "sub": "553df2bcf9...
from oic.oic.message import IdToken from oic.oic.message import Message from oic.oic.message import OpenIDSchema from oic.oic.message import RefreshAccessTokenRequest from oic.oic.message import RegistrationRequest from oic.oic.message import RegistrationResponse
from oic.oic.message import IdToken from oic.oic.message import Message from oic.oic.message import OpenIDSchema from oic.oic.message import ProviderConfigurationResponse from oic.oic.message import RefreshAccessTokenRequest from oic.oic.message import RegistrationRequest from oic.oic.message import RegistrationRespons...
def create_provider(self, session_db_factory): self.cons.keyjar.import_jwks( self.provider.keyjar.export_jwks(), self.cons.issuer ) self.cons2 = Consumer( {}, CONSUMER_CONFIG.copy(), CLIENT_CONFIG_2, server_info=SERVER_INFO
def create_provider(self, session_db_factory): self.cons.keyjar.import_jwks( self.provider.keyjar.export_jwks(), self.cons.issuer ) self.cons.provider_info = ProviderConfigurationResponse( issuer=SERVER_INFO["issuer"] ) self.cons2 = Consumer( ...
def test_authenticated(self): part = self.cons.parse_authz(query=resp.message) aresp = part[0] assert part[1] is None assert part[2] is None
def test_authenticated(self): part = self.cons.parse_authz(query=resp.message) assert isinstance(part, tuple) aresp = part[0] assert part[1] is None assert part[2] is None
def test_authenticated_hybrid(self): part = self.cons.parse_authz(resp.message) aresp = part[0] assert part[1] is None assert part[2] is not None assert isinstance(aresp, AuthorizationResponse) assert _eq(aresp.keys(), ["scope", "state", "id_token", "client_id", "code"...
def test_authenticated_hybrid(self): part = self.cons.parse_authz(resp.message) assert isinstance(part, tuple) aresp = part[0] assert part[1] is None id_token = part[2] assert isinstance(aresp, AuthorizationResponse) assert _eq(aresp.keys(), ["scope", "state", ...
def test_authenticated_hybrid(self): self.cons.grant[_state].keys(), ["code", "id_token", "tokens", "exp_in", "grant_expiration_time", "seed"], ) id_token = part[2] assert isinstance(id_token, IdToken) assert _eq( id_token.keys(),
def test_authenticated_hybrid(self): self.cons.grant[_state].keys(), ["code", "id_token", "tokens", "exp_in", "grant_expiration_time", "seed"], ) assert isinstance(id_token, IdToken) assert _eq( id_token.keys(),
def read_fixed_bytes(self, num_bytes: int) -> bytes: """ read_bytes = self.read(num_bytes) if len(read_bytes) < num_bytes: raise EOFError(read_bytes) return read_bytes def read_pascal_bytes(self, string_length_size: int) -> bytes:
def read_fixed_bytes(self, num_bytes: int) -> bytes: """ read_bytes = self.read(num_bytes) if len(read_bytes) < num_bytes: raise EOFError("Fewer than 'num_bytes' bytes remaining in the " "underlying bytestream") return read_bytes def read_pascal_bytes...
def from_bytes( Raises: ValueError: The provided byte string is not an ``openssh-key-v1`` key list or the declared key count is negative. UserWarning: The check numbers in the decrypted private byte string do not match (likely due to an incorrect passphra...
def from_bytes( Raises: ValueError: The provided byte string is not an ``openssh-key-v1`` key list, when the declared key count is negative, or when an EOF is found while parsing the key. UserWarning: The check numbers in the decrypted private byte strin...
def from_bytes( at the end of the decrypted private byte string are not as expected. """ byte_stream = PascalStyleByteStream(byte_string) header = byte_stream.read_from_format_instructions_dict( cls.HEADER_FORMAT_INSTRUCTIONS_DICT ) i...
def from_bytes( at the end of the decrypted private byte string are not as expected. """ try: byte_stream = PascalStyleByteStream(byte_string) header = byte_stream.read_from_format_instructions_dict( cls.HEADER_FORMAT_INSTRUCTIONS_...
# the maximum length for a user id is 255 characters MAX_USERID_LENGTH = 255 class Membership:
# the maximum length for a user id is 255 characters MAX_USERID_LENGTH = 255 # The maximum length for a group id is 255 characters MAX_GROUPID_LENGTH = 255 MAX_GROUP_CATEGORYID_LENGTH = 255 MAX_GROUP_ROLEID_LENGTH = 255 class Membership:
from typing import Optional, Tuple, Type import synapse from synapse.api.errors import Codes, FederationDeniedError, SynapseError from synapse.api.room_versions import RoomVersions from synapse.api.urls import (
from typing import Optional, Tuple, Type import synapse from synapse.api.constants import MAX_GROUP_CATEGORYID_LENGTH, MAX_GROUP_ROLEID_LENGTH from synapse.api.errors import Codes, FederationDeniedError, SynapseError from synapse.api.room_versions import RoomVersions from synapse.api.urls import (
async def on_POST(self, origin, content, query, group_id, category_id, room_id): raise SynapseError(403, "requester_user_id doesn't match origin") if category_id == "": raise SynapseError(400, "category_id cannot be empty string") resp = await self.handler.update_group_summary_...
async def on_POST(self, origin, content, query, group_id, category_id, room_id): raise SynapseError(403, "requester_user_id doesn't match origin") if category_id == "": raise SynapseError( 400, "category_id cannot be empty string", Codes.INVALID_PARAM ) ...
async def on_POST(self, origin, content, query, group_id, category_id): if category_id == "": raise SynapseError(400, "category_id cannot be empty string") resp = await self.handler.upsert_group_category( group_id, requester_user_id, category_id, content )
async def on_POST(self, origin, content, query, group_id, category_id): if category_id == "": raise SynapseError(400, "category_id cannot be empty string") if len(category_id) > MAX_GROUP_CATEGORYID_LENGTH: raise SynapseError( 400, "category_id ma...
async def on_POST(self, origin, content, query, group_id, role_id): raise SynapseError(403, "requester_user_id doesn't match origin") if role_id == "": raise SynapseError(400, "role_id cannot be empty string") resp = await self.handler.update_group_role( group_id, r...
async def on_POST(self, origin, content, query, group_id, role_id): raise SynapseError(403, "requester_user_id doesn't match origin") if role_id == "": raise SynapseError( 400, "role_id cannot be empty string", Codes.INVALID_PARAM ) if len(role_id) >...
async def on_POST(self, origin, content, query, group_id, role_id, user_id): if role_id == "": raise SynapseError(400, "role_id cannot be empty string") resp = await self.handler.update_group_summary_user( group_id, requester_user_id,
async def on_POST(self, origin, content, query, group_id, role_id, user_id): if role_id == "": raise SynapseError(400, "role_id cannot be empty string") if len(role_id) > MAX_GROUP_ROLEID_LENGTH: raise SynapseError( 400, "role_id may not be longer...
import logging import random from typing import Tuple from signedjson.sign import sign_json from synapse.api.errors import HttpResponseException, RequestSendFailed, SynapseError from synapse.metrics.background_process_metrics import run_as_background_process from synapse.types import get_domain_from_id logger = log...
import logging import random from typing import TYPE_CHECKING, Optional, Tuple from signedjson.sign import sign_json from synapse.api.errors import HttpResponseException, RequestSendFailed, SynapseError from synapse.metrics.background_process_metrics import run_as_background_process from synapse.types import JsonDic...
class GroupAttestationSigning: """Creates and verifies group attestations.""" def __init__(self, hs): self.keyring = hs.get_keyring() self.clock = hs.get_clock() self.server_name = hs.hostname self.signing_key = hs.signing_key async def verify_attestation( self, att...
class GroupAttestationSigning: """Creates and verifies group attestations.""" def __init__(self, hs: "HomeServer"): self.keyring = hs.get_keyring() self.clock = hs.get_clock() self.server_name = hs.hostname self.signing_key = hs.signing_key async def verify_attestation( ...
async def verify_attestation( if valid_until_ms < now: raise SynapseError(400, "Attestation expired") await self.keyring.verify_json_for_server( server_name, attestation, now, "Group attestation" ) def create_attestation(self, group_id, user_id): """Create a...
async def verify_attestation( if valid_until_ms < now: raise SynapseError(400, "Attestation expired") assert server_name is not None await self.keyring.verify_json_for_server( server_name, attestation, now, "Group attestation" ) def create_attestation(self, ...
def create_attestation(self, group_id, user_id): class GroupAttestionRenewer: """Responsible for sending and receiving attestation updates.""" def __init__(self, hs): self.clock = hs.get_clock() self.store = hs.get_datastore() self.assestations = hs.get_groups_attestation_signing()
def create_attestation(self, group_id, user_id): class GroupAttestionRenewer: """Responsible for sending and receiving attestation updates.""" def __init__(self, hs: "HomeServer"): self.clock = hs.get_clock() self.store = hs.get_datastore() self.assestations = hs.get_groups_attestation_...
def __init__(self, hs): self._start_renew_attestations, 30 * 60 * 1000 ) async def on_renew_attestation(self, group_id, user_id, content): """When a remote updates an attestation""" attestation = content["attestation"]
def __init__(self, hs): self._start_renew_attestations, 30 * 60 * 1000 ) async def on_renew_attestation( self, group_id: str, user_id: str, content: JsonDict ) -> JsonDict: """When a remote updates an attestation""" attestation = content["attestation"]
async def on_renew_attestation(self, group_id, user_id, content): return {} def _start_renew_attestations(self): return run_as_background_process("renew_attestations", self._renew_attestations) async def _renew_attestations(self): """Called periodically to check if we need to update a...
async def on_renew_attestation(self, group_id, user_id, content): return {} def _start_renew_attestations(self) -> None: return run_as_background_process("renew_attestations", self._renew_attestations) async def _renew_attestations(self) -> None: """Called periodically to check if we ...
async def _renew_attestations(self): now + UPDATE_ATTESTATION_TIME_MS ) async def _renew_attestation(group_user: Tuple[str, str]): group_id, user_id = group_user try: if not self.is_mine_id(group_id):
async def _renew_attestations(self): now + UPDATE_ATTESTATION_TIME_MS ) async def _renew_attestation(group_user: Tuple[str, str]) -> None: group_id, user_id = group_user try: if not self.is_mine_id(group_id):
# limitations under the License. import logging from synapse.api.errors import Codes, SynapseError from synapse.handlers.profile import MAX_AVATAR_URL_LEN, MAX_DISPLAYNAME_LEN from synapse.types import GroupID, RoomID, UserID, get_domain_from_id from synapse.util.async_helpers import concurrently_execute logger = lo...
# limitations under the License. import logging from typing import TYPE_CHECKING, Optional from synapse.api.errors import Codes, SynapseError from synapse.handlers.groups_local import GroupsLocalHandler from synapse.handlers.profile import MAX_AVATAR_URL_LEN, MAX_DISPLAYNAME_LEN from synapse.types import GroupID, Jso...
class GroupsServerWorkerHandler: def __init__(self, hs): self.hs = hs self.store = hs.get_datastore() self.room_list_handler = hs.get_room_list_handler()
class GroupsServerWorkerHandler: def __init__(self, hs: "HomeServer"): self.hs = hs self.store = hs.get_datastore() self.room_list_handler = hs.get_room_list_handler()
def __init__(self, hs): self.profile_handler = hs.get_profile_handler() async def check_group_is_ours( self, group_id, requester_user_id, and_exists=False, and_is_admin=None ): """Check that the group is ours, and optionally if it exists. If group does exist then return group. ...
def __init__(self, hs): self.profile_handler = hs.get_profile_handler() async def check_group_is_ours( self, group_id: str, requester_user_id: str, and_exists: bool = False, and_is_admin: Optional[str] = None, ) -> Optional[dict]: """Check that the group ...
async def check_group_is_ours( return group async def get_group_summary(self, group_id, requester_user_id): """Get the summary for a group as seen by requester_user_id. The group summary consists of the profile of the room, and a curated
async def check_group_is_ours( return group async def get_group_summary( self, group_id: str, requester_user_id: str ) -> JsonDict: """Get the summary for a group as seen by requester_user_id. The group summary consists of the profile of the room, and a curated
async def get_group_summary(self, group_id, requester_user_id): entry = await self.room_list_handler.generate_room_entry( room_id, len(joined_users), with_alias=False, allow_private=True ) entry = dict(entry) # so we don't change what's cached entry.pop("...
async def get_group_summary(self, group_id, requester_user_id): entry = await self.room_list_handler.generate_room_entry( room_id, len(joined_users), with_alias=False, allow_private=True ) if entry is None: continue entry = dict(entry) # s...
async def get_group_summary(self, group_id, requester_user_id): rooms.sort(key=lambda e: e.get("order", 0)) for entry in users: user_id = entry["user_id"] if not self.is_mine_id(requester_user_id): attestation = await self.store.get_remote_attestation(group_id,...
async def get_group_summary(self, group_id, requester_user_id): rooms.sort(key=lambda e: e.get("order", 0)) for user in users: user_id = user["user_id"] if not self.is_mine_id(requester_user_id): attestation = await self.store.get_remote_attestation(group_id, u...
async def get_group_summary(self, group_id, requester_user_id): "user": membership_info, } async def get_group_categories(self, group_id, requester_user_id): """Get all categories in a group (as seen by user)""" await self.check_group_is_ours(group_id, requester_user_id, and_exi...
async def get_group_summary(self, group_id, requester_user_id): "user": membership_info, } async def get_group_categories( self, group_id: str, requester_user_id: str ) -> JsonDict: """Get all categories in a group (as seen by user)""" await self.check_group_is_ours(...
async def get_group_profile(self, group_id, requester_user_id): else: raise SynapseError(404, "Unknown group") async def get_users_in_group(self, group_id, requester_user_id): """Get the users in group as seen by requester_user_id. The ordering is arbitrary at the moment
async def get_group_profile(self, group_id, requester_user_id): else: raise SynapseError(404, "Unknown group") async def get_users_in_group( self, group_id: str, requester_user_id: str ) -> JsonDict: """Get the users in group as seen by requester_user_id. The orderi...
async def get_users_in_group(self, group_id, requester_user_id): return {"chunk": chunk, "total_user_count_estimate": len(user_results)} async def get_invited_users_in_group(self, group_id, requester_user_id): """Get the users that have been invited to a group as seen by requester_user_id. ...
async def get_users_in_group(self, group_id, requester_user_id): return {"chunk": chunk, "total_user_count_estimate": len(user_results)} async def get_invited_users_in_group( self, group_id: str, requester_user_id: str ) -> JsonDict: """Get the users that have been invited to a group a...
async def get_invited_users_in_group(self, group_id, requester_user_id): return {"chunk": user_profiles, "total_user_count_estimate": len(invited_users)} async def get_rooms_in_group(self, group_id, requester_user_id): """Get the rooms in group as seen by requester_user_id This returns ro...
async def get_invited_users_in_group(self, group_id, requester_user_id): return {"chunk": user_profiles, "total_user_count_estimate": len(invited_users)} async def get_rooms_in_group( self, group_id: str, requester_user_id: str ) -> JsonDict: """Get the rooms in group as seen by reques...
async def get_rooms_in_group(self, group_id, requester_user_id): class GroupsServerHandler(GroupsServerWorkerHandler): def __init__(self, hs): super().__init__(hs) # Ensure attestations get renewed hs.get_groups_attestation_renewer() async def update_group_summary_room( self,...
async def get_rooms_in_group(self, group_id, requester_user_id): class GroupsServerHandler(GroupsServerWorkerHandler): def __init__(self, hs: "HomeServer"): super().__init__(hs) # Ensure attestations get renewed hs.get_groups_attestation_renewer() async def update_group_summary_room(...
async def update_group_summary_room( return {} async def delete_group_summary_room( self, group_id, requester_user_id, room_id, category_id ): """Remove a room from the summary""" await self.check_group_is_ours( group_id, requester_user_id, and_exists=True, and_is_ad...
async def update_group_summary_room( return {} async def delete_group_summary_room( self, group_id: str, requester_user_id: str, room_id: str, category_id: str ) -> JsonDict: """Remove a room from the summary""" await self.check_group_is_ours( group_id, requester_use...
async def delete_group_summary_room( return {} async def set_group_join_policy(self, group_id, requester_user_id, content): """Sets the group join policy. Currently supported policies are:
async def delete_group_summary_room( return {} async def set_group_join_policy( self, group_id: str, requester_user_id: str, content: JsonDict ) -> JsonDict: """Sets the group join policy. Currently supported policies are:
async def set_group_join_policy(self, group_id, requester_user_id, content): return {} async def update_group_category( self, group_id, requester_user_id, category_id, content ): """Add/Update a group category""" await self.check_group_is_ours( group_id, requester_us...
async def set_group_join_policy(self, group_id, requester_user_id, content): return {} async def update_group_category( self, group_id: str, requester_user_id: str, category_id: str, content: JsonDict ) -> JsonDict: """Add/Update a group category""" await self.check_group_is_our...
async def update_group_category( return {} async def delete_group_category(self, group_id, requester_user_id, category_id): """Delete a group category""" await self.check_group_is_ours( group_id, requester_user_id, and_exists=True, and_is_admin=requester_user_id
async def update_group_category( return {} async def delete_group_category( self, group_id: str, requester_user_id: str, category_id: str ) -> JsonDict: """Delete a group category""" await self.check_group_is_ours( group_id, requester_user_id, and_exists=True, and_i...
async def delete_group_category(self, group_id, requester_user_id, category_id): return {} async def update_group_role(self, group_id, requester_user_id, role_id, content): """Add/update a role in a group""" await self.check_group_is_ours( group_id, requester_user_id, and_exist...
async def delete_group_category(self, group_id, requester_user_id, category_id): return {} async def update_group_role( self, group_id: str, requester_user_id: str, role_id: str, content: JsonDict ) -> JsonDict: """Add/update a role in a group""" await self.check_group_is_ours(...
async def update_group_role(self, group_id, requester_user_id, role_id, content) return {} async def delete_group_role(self, group_id, requester_user_id, role_id): """Remove role from group""" await self.check_group_is_ours( group_id, requester_user_id, and_exists=True, and_is_...
async def update_group_role(self, group_id, requester_user_id, role_id, content) return {} async def delete_group_role( self, group_id: str, requester_user_id: str, role_id: str ) -> JsonDict: """Remove role from group""" await self.check_group_is_ours( group_id, re...
async def delete_group_role(self, group_id, requester_user_id, role_id): return {} async def update_group_summary_user( self, group_id, requester_user_id, user_id, role_id, content ): """Add/update a users entry in the group summary""" await self.check_group_is_ours( ...
async def delete_group_role(self, group_id, requester_user_id, role_id): return {} async def update_group_summary_user( self, group_id: str, requester_user_id: str, user_id: str, role_id: str, content: JsonDict, ) -> JsonDict: """Add/update a user...
async def update_group_summary_user( return {} async def delete_group_summary_user( self, group_id, requester_user_id, user_id, role_id ): """Remove a user from the group summary""" await self.check_group_is_ours( group_id, requester_user_id, and_exists=True, and_is_...
async def update_group_summary_user( return {} async def delete_group_summary_user( self, group_id: str, requester_user_id: str, user_id: str, role_id: str ) -> JsonDict: """Remove a user from the group summary""" await self.check_group_is_ours( group_id, requester_u...
async def delete_group_summary_user( return {} async def update_group_profile(self, group_id, requester_user_id, content): """Update the group profile""" await self.check_group_is_ours( group_id, requester_user_id, and_exists=True, and_is_admin=requester_user_id
async def delete_group_summary_user( return {} async def update_group_profile( self, group_id: str, requester_user_id: str, content: JsonDict ) -> None: """Update the group profile""" await self.check_group_is_ours( group_id, requester_user_id, and_exists=True, and_...
async def update_group_profile(self, group_id, requester_user_id, content): await self.store.update_group_profile(group_id, profile) async def add_room_to_group(self, group_id, requester_user_id, room_id, content): """Add room to group""" RoomID.from_string(room_id) # Ensure valid room id...
async def update_group_profile(self, group_id, requester_user_id, content): await self.store.update_group_profile(group_id, profile) async def add_room_to_group( self, group_id: str, requester_user_id: str, room_id: str, content: JsonDict ) -> JsonDict: """Add room to group""" ...
async def add_room_to_group(self, group_id, requester_user_id, room_id, content) return {} async def update_room_in_group( self, group_id, requester_user_id, room_id, config_key, content ): """Update room in group""" RoomID.from_string(room_id) # Ensure valid room id
async def add_room_to_group(self, group_id, requester_user_id, room_id, content) return {} async def update_room_in_group( self, group_id: str, requester_user_id: str, room_id: str, config_key: str, content: JsonDict, ) -> JsonDict: """Update room...
async def update_room_in_group( return {} async def remove_room_from_group(self, group_id, requester_user_id, room_id): """Remove room from group""" await self.check_group_is_ours( group_id, requester_user_id, and_exists=True, and_is_admin=requester_user_id
async def update_room_in_group( return {} async def remove_room_from_group( self, group_id: str, requester_user_id: str, room_id: str ) -> JsonDict: """Remove room from group""" await self.check_group_is_ours( group_id, requester_user_id, and_exists=True, and_is_adm...
async def remove_room_from_group(self, group_id, requester_user_id, room_id): return {} async def invite_to_group(self, group_id, user_id, requester_user_id, content): """Invite user to group""" group = await self.check_group_is_ours( group_id, requester_user_id, and_exists=Tr...
async def remove_room_from_group(self, group_id, requester_user_id, room_id): return {} async def invite_to_group( self, group_id: str, user_id: str, requester_user_id: str, content: JsonDict ) -> JsonDict: """Invite user to group""" group = await self.check_group_is_ours( ...
async def invite_to_group(self, group_id, user_id, requester_user_id, content): if self.hs.is_mine_id(user_id): groups_local = self.hs.get_groups_local_handler() res = await groups_local.on_invite(group_id, user_id, content) local_attestation = None else:
async def invite_to_group(self, group_id, user_id, requester_user_id, content): if self.hs.is_mine_id(user_id): groups_local = self.hs.get_groups_local_handler() assert isinstance( groups_local, GroupsLocalHandler ), "Workers cannot invites users to groups." ...
async def invite_to_group(self, group_id, user_id, requester_user_id, content): local_attestation=local_attestation, remote_attestation=remote_attestation, ) elif res["state"] == "invite": await self.store.add_group_invite(group_id, user_id) re...
async def invite_to_group(self, group_id, user_id, requester_user_id, content): local_attestation=local_attestation, remote_attestation=remote_attestation, ) return {"state": "join"} elif res["state"] == "invite": await self.store.add_group_inv...
async def invite_to_group(self, group_id, user_id, requester_user_id, content): else: raise SynapseError(502, "Unknown state returned by HS") async def _add_user(self, group_id, user_id, content): """Add a user to a group based on a content dict. See accept_invite, join_group. ...
async def invite_to_group(self, group_id, user_id, requester_user_id, content): else: raise SynapseError(502, "Unknown state returned by HS") async def _add_user( self, group_id: str, user_id: str, content: JsonDict ) -> Optional[JsonDict]: """Add a user to a group based on ...
async def _add_user(self, group_id, user_id, content): return local_attestation async def accept_invite(self, group_id, requester_user_id, content): """User tries to accept an invite to the group. This is different from them asking to join, and so should error if no
async def _add_user(self, group_id, user_id, content): return local_attestation async def accept_invite( self, group_id: str, requester_user_id: str, content: JsonDict ) -> JsonDict: """User tries to accept an invite to the group. This is different from them asking to join, an...
async def accept_invite(self, group_id, requester_user_id, content): return {"state": "join", "attestation": local_attestation} async def join_group(self, group_id, requester_user_id, content): """User tries to join the group. This will error if the group requires an invite/knock to join
async def accept_invite(self, group_id, requester_user_id, content): return {"state": "join", "attestation": local_attestation} async def join_group( self, group_id: str, requester_user_id: str, content: JsonDict ) -> JsonDict: """User tries to join the group. This will error ...
async def join_group(self, group_id, requester_user_id, content): group_info = await self.check_group_is_ours( group_id, requester_user_id, and_exists=True ) if group_info["join_policy"] != "open": raise SynapseError(403, "Group is not publicly joinable")
async def join_group(self, group_id, requester_user_id, content): group_info = await self.check_group_is_ours( group_id, requester_user_id, and_exists=True ) if not group_info: raise SynapseError(404, "Group does not exist", errcode=Codes.NOT_FOUND) if group_info[...
async def join_group(self, group_id, requester_user_id, content): return {"state": "join", "attestation": local_attestation} async def knock(self, group_id, requester_user_id, content): """A user requests becoming a member of the group""" await self.check_group_is_ours(group_id, requester_...
async def join_group(self, group_id, requester_user_id, content): return {"state": "join", "attestation": local_attestation} async def remove_user_from_group( self, group_id: str, user_id: str, requester_user_id: str, content: JsonDict ) -> JsonDict: """Remove a user from the group; ei...
async def remove_user_from_group( if is_kick: if self.hs.is_mine_id(user_id): groups_local = self.hs.get_groups_local_handler() await groups_local.user_removed_from_group(group_id, user_id, {}) else: await self.transport_client.remove_user_...
async def remove_user_from_group( if is_kick: if self.hs.is_mine_id(user_id): groups_local = self.hs.get_groups_local_handler() assert isinstance( groups_local, GroupsLocalHandler ), "Workers cannot remove users from groups." ...
async def remove_user_from_group( return {} async def create_group(self, group_id, requester_user_id, content): group = await self.check_group_is_ours(group_id, requester_user_id) logger.info("Attempting to create group with ID: %r", group_id) # parsing the id into a GroupID vali...
async def remove_user_from_group( return {} async def create_group( self, group_id: str, requester_user_id: str, content: JsonDict ) -> JsonDict: logger.info("Attempting to create group with ID: %r", group_id) # parsing the id into a GroupID validates it. group_id_obj ...
async def create_group(self, group_id, requester_user_id, content): local_attestation = self.attestations.create_attestation( group_id, requester_user_id ) else: local_attestation = None remote_attestation = None
async def create_group(self, group_id, requester_user_id, content): local_attestation = self.attestations.create_attestation( group_id, requester_user_id ) # type: Optional[JsonDict] else: local_attestation = None remote_attestation = None
async def create_group(self, group_id, requester_user_id, content): return {"group_id": group_id} async def delete_group(self, group_id, requester_user_id): """Deletes a group, kicking out all current members. Only group admins or server admins can call this request Args: ...
async def create_group(self, group_id, requester_user_id, content): return {"group_id": group_id} async def delete_group(self, group_id: str, requester_user_id: str) -> None: """Deletes a group, kicking out all current members. Only group admins or server admins can call this request ...
async def delete_group(self, group_id, requester_user_id): async def _kick_user_from_group(user_id): if self.hs.is_mine_id(user_id): groups_local = self.hs.get_groups_local_handler() await groups_local.user_removed_from_group(group_id, user_id, {}) else: ...
async def delete_group(self, group_id, requester_user_id): async def _kick_user_from_group(user_id): if self.hs.is_mine_id(user_id): groups_local = self.hs.get_groups_local_handler() assert isinstance( groups_local, GroupsLocalHandler ...
async def _kick_user_from_group(user_id): await self.store.delete_group(group_id) def _parse_join_policy_from_contents(content): """Given a content for a request, return the specified join policy or None""" join_policy_dict = content.get("m.join_policy")
async def _kick_user_from_group(user_id): await self.store.delete_group(group_id) def _parse_join_policy_from_contents(content: JsonDict) -> Optional[str]: """Given a content for a request, return the specified join policy or None""" join_policy_dict = content.get("m.join_policy")
def _parse_join_policy_from_contents(content): return None def _parse_join_policy_dict(join_policy_dict): """Given a dict for the "m.join_policy" config return the join policy specified""" join_policy_type = join_policy_dict.get("type") if not join_policy_type:
def _parse_join_policy_from_contents(content): return None def _parse_join_policy_dict(join_policy_dict: JsonDict) -> str: """Given a dict for the "m.join_policy" config return the join policy specified""" join_policy_type = join_policy_dict.get("type") if not join_policy_type:
def _parse_join_policy_dict(join_policy_dict): return join_policy_type def _parse_visibility_from_contents(content): """Given a content for a request parse out whether the entity should be public or not """
def _parse_join_policy_dict(join_policy_dict): return join_policy_type def _parse_visibility_from_contents(content: JsonDict) -> bool: """Given a content for a request parse out whether the entity should be public or not """
def _parse_visibility_from_contents(content): return is_public def _parse_visibility_dict(visibility): """Given a dict for the "m.visibility" config return if the entity should be public or not """
def _parse_visibility_from_contents(content): return is_public def _parse_visibility_dict(visibility: JsonDict) -> bool: """Given a dict for the "m.visibility" config return if the entity should be public or not """
import logging from functools import wraps from typing import TYPE_CHECKING, Tuple from twisted.web.http import Request from synapse.api.errors import SynapseError from synapse.handlers.groups_local import GroupsLocalHandler from synapse.http.servlet import ( RestServlet,
import logging from functools import wraps from typing import TYPE_CHECKING, Optional, Tuple from twisted.web.http import Request from synapse.api.constants import ( MAX_GROUP_CATEGORYID_LENGTH, MAX_GROUP_ROLEID_LENGTH, MAX_GROUPID_LENGTH, ) from synapse.api.errors import Codes, SynapseError from synapse...
async def on_POST(self, request: Request, group_id: str) -> Tuple[int, JsonDict] assert_params_in_dict( content, ("name", "avatar_url", "short_description", "long_description") ) assert isinstance(self.groups_handler, GroupsLocalHandler) await self.groups_handler.update_group...
async def on_POST(self, request: Request, group_id: str) -> Tuple[int, JsonDict] assert_params_in_dict( content, ("name", "avatar_url", "short_description", "long_description") ) assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot create ...
def __init__(self, hs: "HomeServer"): @_validate_group_id async def on_PUT( self, request: Request, group_id: str, category_id: str, room_id: str ): requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() content = parse_json_obje...
def __init__(self, hs: "HomeServer"): @_validate_group_id async def on_PUT( self, request: Request, group_id: str, category_id: Optional[str], room_id: str ): requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() if category_id ...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance(self.groups_handler, GroupsLocalHandler) resp = await self.groups_handler.delete_group_summary_room( group_id, requester_user_id, room_i...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot modify group profiles." resp = await self.groups_handler.delete_grou...
async def on_PUT( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() content = parse_json_object_from_request(request) assert isinstance(self.groups_handler, GroupsLocalHandler) resp = await self.groups_handler.update_group_catego...
async def on_PUT( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() if not category_id: raise SynapseError(400, "category_id cannot be empty", Codes.INVALID_PARAM) if len(category_id) > MAX_GROUP_CATEGORYID_LENGTH: ...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance(self.groups_handler, GroupsLocalHandler) resp = await self.groups_handler.delete_group_category( group_id, requester_user_id, category_i...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot modify group categories." resp = await self.groups_handler.delete_gr...
async def on_PUT( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() content = parse_json_object_from_request(request) assert isinstance(self.groups_handler, GroupsLocalHandler) resp = await self.groups_handler.update_group_role( ...
async def on_PUT( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() if not role_id: raise SynapseError(400, "role_id cannot be empty", Codes.INVALID_PARAM) if len(role_id) > MAX_GROUP_ROLEID_LENGTH: raise Synapse...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance(self.groups_handler, GroupsLocalHandler) resp = await self.groups_handler.delete_group_role( group_id, requester_user_id, role_id=role_i...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot modify group roles." resp = await self.groups_handler.delete_group_r...
def __init__(self, hs: "HomeServer"): @_validate_group_id async def on_PUT( self, request: Request, group_id: str, role_id: str, user_id: str ) -> Tuple[int, JsonDict]: requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() conte...
def __init__(self, hs: "HomeServer"): @_validate_group_id async def on_PUT( self, request: Request, group_id: str, role_id: Optional[str], user_id: str ) -> Tuple[int, JsonDict]: requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() ...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance(self.groups_handler, GroupsLocalHandler) resp = await self.groups_handler.delete_group_summary_user( group_id, requester_user_id, user_i...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot modify group summaries." resp = await self.groups_handler.delete_gro...
async def on_PUT(self, request: Request, group_id: str) -> Tuple[int, JsonDict]: content = parse_json_object_from_request(request) assert isinstance(self.groups_handler, GroupsLocalHandler) result = await self.groups_handler.set_group_join_policy( group_id, requester_user_id, conte...
async def on_PUT(self, request: Request, group_id: str) -> Tuple[int, JsonDict]: content = parse_json_object_from_request(request) assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot modify group join policy." result = await self.groups_handler.set...
async def on_POST(self, request: Request) -> Tuple[int, JsonDict]: localpart = content.pop("localpart") group_id = GroupID(localpart, self.server_name).to_string() assert isinstance(self.groups_handler, GroupsLocalHandler) result = await self.groups_handler.create_group( gro...
async def on_POST(self, request: Request) -> Tuple[int, JsonDict]: localpart = content.pop("localpart") group_id = GroupID(localpart, self.server_name).to_string() if not localpart: raise SynapseError(400, "Group ID cannot be empty", Codes.INVALID_PARAM) if len(group_id) > ...
async def on_PUT( requester_user_id = requester.user.to_string() content = parse_json_object_from_request(request) assert isinstance(self.groups_handler, GroupsLocalHandler) result = await self.groups_handler.add_room_to_group( group_id, requester_user_id, room_id, content ...
async def on_PUT( requester_user_id = requester.user.to_string() content = parse_json_object_from_request(request) assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot modify rooms in a group." result = await self.groups_handler.add_room_to_g...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance(self.groups_handler, GroupsLocalHandler) result = await self.groups_handler.remove_room_from_group( group_id, requester_user_id, room_id...
async def on_DELETE( requester = await self.auth.get_user_by_req(request) requester_user_id = requester.user.to_string() assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot modify group categories." result = await self.groups_handler.remove_...
async def on_PUT( requester_user_id = requester.user.to_string() content = parse_json_object_from_request(request) assert isinstance(self.groups_handler, GroupsLocalHandler) result = await self.groups_handler.update_room_in_group( group_id, requester_user_id, room_id, config...
async def on_PUT( requester_user_id = requester.user.to_string() content = parse_json_object_from_request(request) assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot modify group categories." result = await self.groups_handler.update_room_i...
async def on_PUT(self, request: Request, group_id, user_id) -> Tuple[int, JsonDi content = parse_json_object_from_request(request) config = content.get("config", {}) assert isinstance(self.groups_handler, GroupsLocalHandler) result = await self.groups_handler.invite( group_i...
async def on_PUT(self, request: Request, group_id, user_id) -> Tuple[int, JsonDi content = parse_json_object_from_request(request) config = content.get("config", {}) assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot invite users to a group." ...
async def on_PUT(self, request: Request, group_id, user_id) -> Tuple[int, JsonDi requester_user_id = requester.user.to_string() content = parse_json_object_from_request(request) assert isinstance(self.groups_handler, GroupsLocalHandler) result = await self.groups_handler.remove_user_fro...
async def on_PUT(self, request: Request, group_id, user_id) -> Tuple[int, JsonDi requester_user_id = requester.user.to_string() content = parse_json_object_from_request(request) assert isinstance( self.groups_handler, GroupsLocalHandler ), "Workers cannot kick users from a g...