mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Add an admin token for MAS -> Synapse calls
This commit is contained in:
parent
bad1f2cd35
commit
c008b44b4f
@ -90,6 +90,7 @@ class MSC3861DelegatedAuth(BaseAuth):
|
|||||||
|
|
||||||
self._http_client = hs.get_proxied_http_client()
|
self._http_client = hs.get_proxied_http_client()
|
||||||
self._hostname = hs.hostname
|
self._hostname = hs.hostname
|
||||||
|
self._admin_token = self._config.admin_token
|
||||||
|
|
||||||
self._issuer_metadata = RetryOnExceptionCachedCall(self._load_metadata)
|
self._issuer_metadata = RetryOnExceptionCachedCall(self._load_metadata)
|
||||||
|
|
||||||
@ -176,6 +177,20 @@ class MSC3861DelegatedAuth(BaseAuth):
|
|||||||
token: str,
|
token: str,
|
||||||
allow_expired: bool = False,
|
allow_expired: bool = False,
|
||||||
) -> Requester:
|
) -> Requester:
|
||||||
|
if self._admin_token is not None and token == self._admin_token:
|
||||||
|
# XXX: This is a temporary solution so that the admin API can be called by
|
||||||
|
# the OIDC provider. This will be removed once we have OIDC client
|
||||||
|
# credentials grant support in matrix-authentication-service.
|
||||||
|
logging.info("Admin toked used")
|
||||||
|
# XXX: that user doesn't exist and won't be provisioned.
|
||||||
|
# This is mostly fine for admin calls, but we should also think about doing
|
||||||
|
# requesters without a user_id.
|
||||||
|
admin_user = UserID("__oidc_admin", self._hostname)
|
||||||
|
return create_requester(
|
||||||
|
user_id=admin_user,
|
||||||
|
scope=["urn:synapse:admin:*"],
|
||||||
|
)
|
||||||
|
|
||||||
introspection_result = await self._introspect_token(token)
|
introspection_result = await self._introspect_token(token)
|
||||||
|
|
||||||
logger.info(f"Introspection result: {introspection_result!r}")
|
logger.info(f"Introspection result: {introspection_result!r}")
|
||||||
|
@ -136,6 +136,15 @@ class MSC3861:
|
|||||||
)
|
)
|
||||||
"""The URL of the My Account page on the OIDC Provider as per MSC2965."""
|
"""The URL of the My Account page on the OIDC Provider as per MSC2965."""
|
||||||
|
|
||||||
|
admin_token: Optional[str] = attr.ib(
|
||||||
|
default=None,
|
||||||
|
validator=attr.validators.optional(attr.validators.instance_of(str)),
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
A token that should be considered as an admin token.
|
||||||
|
This is used by the OIDC provider, to make admin calls to Synapse.
|
||||||
|
"""
|
||||||
|
|
||||||
def check_config_conflicts(self, root: RootConfig) -> None:
|
def check_config_conflicts(self, root: RootConfig) -> None:
|
||||||
"""Checks for any configuration conflicts with other parts of Synapse.
|
"""Checks for any configuration conflicts with other parts of Synapse.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user