core: bootstrap email (#4788)

This commit is contained in:
Jens L 2023-02-26 17:02:45 +01:00 committed by GitHub
parent 612d1c76d4
commit 596ff529c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 18 deletions

View File

@ -18,13 +18,13 @@ def create_default_user(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
db_alias = schema_editor.connection.alias db_alias = schema_editor.connection.alias
akadmin, _ = User.objects.using(db_alias).get_or_create( akadmin, _ = User.objects.using(db_alias).get_or_create(
username="akadmin", email="root@localhost", name="authentik Default Admin" username="akadmin",
email=environ.get("AUTHENTIK_BOOTSTRAP_EMAIL", "root@localhost"),
name="authentik Default Admin",
) )
password = None password = None
if "TF_BUILD" in environ or settings.TEST: if "TF_BUILD" in environ or settings.TEST:
password = "akadmin" # noqa # nosec password = "akadmin" # noqa # nosec
if "AK_ADMIN_PASS" in environ:
password = environ["AK_ADMIN_PASS"]
if "AUTHENTIK_BOOTSTRAP_PASSWORD" in environ: if "AUTHENTIK_BOOTSTRAP_PASSWORD" in environ:
password = environ["AUTHENTIK_BOOTSTRAP_PASSWORD"] password = environ["AUTHENTIK_BOOTSTRAP_PASSWORD"]
if password: if password:

View File

@ -46,13 +46,9 @@ def create_default_user_token(apps: Apps, schema_editor: BaseDatabaseSchemaEdito
akadmin = User.objects.using(db_alias).filter(username="akadmin") akadmin = User.objects.using(db_alias).filter(username="akadmin")
if not akadmin.exists(): if not akadmin.exists():
return return
key = None if "AUTHENTIK_BOOTSTRAP_TOKEN" not in environ:
if "AK_ADMIN_TOKEN" in environ:
key = environ["AK_ADMIN_TOKEN"]
if "AUTHENTIK_BOOTSTRAP_TOKEN" in environ:
key = environ["AUTHENTIK_BOOTSTRAP_TOKEN"]
if not key:
return return
key = environ["AUTHENTIK_BOOTSTRAP_TOKEN"]
Token.objects.using(db_alias).create( Token.objects.using(db_alias).create(
identifier="authentik-bootstrap-token", identifier="authentik-bootstrap-token",
user=akadmin.first(), user=akadmin.first(),

View File

@ -4,22 +4,22 @@ title: Automated install
To install authentik automatically (skipping the Out-of-box experience), you can use the following environment variables: To install authentik automatically (skipping the Out-of-box experience), you can use the following environment variables:
### `AUTHENTIK_BOOTSTRAP_PASSWORD` or `AK_ADMIN_PASS` ### `AUTHENTIK_BOOTSTRAP_PASSWORD`
Configure the default password for the `akadmin` user. Only read on the first startup. Can be used for any flow executor. Configure the default password for the `akadmin` user. Only read on the first startup. Can be used for any flow executor.
:::info ### `AUTHENTIK_BOOTSTRAP_TOKEN`
For versions before 2022.6, this variable was called `AK_ADMIN_PASS`. This will be removed in 2022.7
:::
### `AUTHENTIK_BOOTSTRAP_TOKEN` or `AK_ADMIN_TOKEN`
:::note :::note
This option has been added in 2021.8 Requires authentik 2021.8
::: :::
Create a token for the default `akadmin` user. Only read on the first startup. The string you specify for this variable is the token key you can use to authenticate yourself to the API. Create a token for the default `akadmin` user. Only read on the first startup. The string you specify for this variable is the token key you can use to authenticate yourself to the API.
:::info ### `AUTHENTIK_BOOTSTRAP_EMAIL`
For versions before 2022.6, this variable was called `AK_ADMIN_TOKEN`. This will be removed in 2022.7
:::note
Requires authentik 2023.3
::: :::
Set the email address for the default `akadmin` user.