config option to reset admin password on startup

This commit is contained in:
Blake Blackshear 2024-05-12 06:28:31 -05:00
parent fafc0aab2f
commit d6b517dc85
2 changed files with 16 additions and 0 deletions

View File

@ -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(

View File

@ -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]_*$"
)