Skip to content

Commit c6b4029

Browse files
committed
Add bypass for as/hs token config check when generating registration
1 parent ef1d5ca commit c6b4029

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

mautrix/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "0.4.0rc2"
1+
__version__ = "0.4.0rc3"
22
__author__ = "Tulir Asokan <[email protected]>"
33
__all__ = ["api", "appservice", "bridge", "client", "errors", "util", "types"]

mautrix/bridge/bridge.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def _prepare(self) -> None:
9898

9999
self.prepare_config(args.config, args.registration, args.base_config)
100100
self.prepare_log()
101-
self.check_config()
101+
self.check_config(check_tokens=not args.generate_registration)
102102

103103
if args.generate_registration:
104104
self.generate_registration()
@@ -121,8 +121,9 @@ def prepare_config(self, config: str, registration: str, base_config: str) -> No
121121
self.config.load()
122122
self.config.update()
123123

124-
def check_config(self) -> None:
124+
def check_config(self, check_tokens: bool = True) -> None:
125125
try:
126+
self.config._check_tokens = check_tokens
126127
self.config.check_default_values()
127128
except ConfigValueError as e:
128129
self.log.fatal(f"Configuration error: {e}")

mautrix/bridge/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ def exception(self) -> ConfigValueError:
4646
class BaseBridgeConfig(BaseFileConfig, ABC):
4747
registration_path: str
4848
_registration: Optional[Dict]
49+
_check_tokens: bool
4950

5051
def __init__(self, path: str, registration_path: str, base_path: str) -> None:
5152
super().__init__(path, base_path)
5253
self.registration_path = registration_path
5354
self._registration = None
55+
self._check_tokens = True
5456

5557
def save(self) -> None:
5658
super().save()
@@ -67,13 +69,14 @@ def forbidden_defaults(self) -> List[ForbiddenDefault]:
6769
return [
6870
ForbiddenDefault("homeserver.address", "https://example.com"),
6971
ForbiddenDefault("homeserver.domain", "example.com"),
72+
] + ([
7073
ForbiddenDefault("appservice.as_token",
7174
"This value is generated when generating the registration",
7275
"Did you forget to generate the registration?"),
7376
ForbiddenDefault("appservice.hs_token",
7477
"This value is generated when generating the registration",
7578
"Did you forget to generate the registration?"),
76-
]
79+
] if self._check_tokens else [])
7780

7881
def check_default_values(self) -> None:
7982
for default in self.forbidden_defaults:

0 commit comments

Comments
 (0)