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
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
if "TF_BUILD" in environ or settings.TEST:
password = "akadmin" # noqa # nosec
if "AK_ADMIN_PASS" in environ:
password = environ["AK_ADMIN_PASS"]
if "AUTHENTIK_BOOTSTRAP_PASSWORD" in environ:
password = environ["AUTHENTIK_BOOTSTRAP_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")
if not akadmin.exists():
return
key = None
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:
if "AUTHENTIK_BOOTSTRAP_TOKEN" not in environ:
return
key = environ["AUTHENTIK_BOOTSTRAP_TOKEN"]
Token.objects.using(db_alias).create(
identifier="authentik-bootstrap-token",
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:
### `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.
:::info
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`
### `AUTHENTIK_BOOTSTRAP_TOKEN`
:::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.
:::info
For versions before 2022.6, this variable was called `AK_ADMIN_TOKEN`. This will be removed in 2022.7
### `AUTHENTIK_BOOTSTRAP_EMAIL`
:::note
Requires authentik 2023.3
:::
Set the email address for the default `akadmin` user.