diff --git a/frigate/app.py b/frigate/app.py index d2dea4fa1..0e00f4ba1 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -613,6 +613,19 @@ class FrigateApp: logger.info(f"*** Password: {password} ***") logger.info("********************************************************") logger.info("********************************************************") + elif self.config.auth.reset_admin_password: + password = secrets.token_hex(16) + password_hash = hash_password( + password, iterations=self.config.auth.hash_iterations + ) + User.replace(username="admin", password_hash=password_hash).execute() + + logger.info("********************************************************") + logger.info("********************************************************") + logger.info("*** Reset admin password set in the config. ***") + logger.info(f"*** Password: {password} ***") + logger.info("********************************************************") + logger.info("********************************************************") def start(self) -> None: parser = argparse.ArgumentParser( diff --git a/frigate/config.py b/frigate/config.py index f7546d070..9be5b9624 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -125,6 +125,9 @@ class UserConfig(FrigateBaseModel): class AuthConfig(FrigateBaseModel): enabled: bool = Field(default=False, title="Enable authentication") + reset_admin_password: bool = Field( + default=False, title="Reset the admin password on startup" + ) cookie_name: str = Field( default="frigate_token", title="Name for jwt token cookie", pattern=r"^[a-z]_*$" )