mirror of
https://github.com/goauthentik/authentik
synced 2026-04-26 01:25:02 +02:00
254 lines
7.7 KiB
Plaintext
254 lines
7.7 KiB
Plaintext
---
|
|
title: Full development environment
|
|
sidebar_label: Full development
|
|
tags:
|
|
- development
|
|
- contributor
|
|
- backend
|
|
- frontend
|
|
- docker
|
|
---
|
|
|
|
import TabItem from "@theme/TabItem";
|
|
import Tabs from "@theme/Tabs";
|
|
|
|
## Prerequisites
|
|
|
|
Before you begin, ensure you have the following tools installed. You can run the [provided script](#3-installing-platform-specific-dependencies) below in **Installing platform-specific dependencies** to install these required tools.
|
|
|
|
- [Python](https://www.python.org/) (3.14)
|
|
- [uv](https://docs.astral.sh/uv/getting-started/installation/) (Latest stable release)
|
|
- [Rust](https://rust-lang.org/learn/get-started/) (We provide a `rust-toolchain.toml` file for the correct version, and we use the nightly toolchain to run formatting with rustfmt.)
|
|
- [Go](https://go.dev/) (1.26 or later)
|
|
- [Node.js](https://nodejs.org/en) (24 or later)
|
|
- [PostgreSQL](https://www.postgresql.org/) (16 or later)
|
|
- [Docker](https://www.docker.com/) (Latest Community Edition or Docker Desktop)
|
|
- [Docker Compose](https://docs.docker.com/compose/) (Compose v2)
|
|
- [Make](https://www.gnu.org/software/make/) (3 or later)
|
|
|
|
### Understanding the architecture
|
|
|
|
authentik is primarily a Django application running under gunicorn, proxied by a Go application that serves static files. Most functions and classes have type hints and docstrings. For better code navigation, we recommend installing a Python type-checking extension in your IDE.
|
|
|
|
## 1. Prepare your local working repository
|
|
|
|
Verify that you have a local working repository of authentik and that it is initialized and up-to-date with the [authentik repository](https://github.com/goauthentik/authentik).
|
|
|
|
Unless otherwise specified, all commands described below should be run from the project root of your local authentik repository.
|
|
|
|
## 2. Set up required services
|
|
|
|
authentik depends on several external services:
|
|
|
|
- [PostgreSQL](https://www.postgresql.org/) for database storage
|
|
- [Zenko CloudServer (S3)](https://www.zenko.io/cloudserver/) for object storage
|
|
- [Sentry Spotlight](https://spotlightjs.com/) for error tracking and visualization
|
|
|
|
The easiest way to set up these services is using the provided Docker Compose configuration:
|
|
|
|
```shell
|
|
docker compose -f scripts/compose.yml up -d
|
|
```
|
|
|
|
## 3. Installing platform-specific dependencies
|
|
|
|
<Tabs defaultValue="macOS">
|
|
<TabItem value="macOS">
|
|
|
|
Install the required native dependencies on macOS using Homebrew. You can edit the following command if you already have some of these and want to skip installing them again, or run `brew install --dry-run` to preview the changes:
|
|
|
|
```shell
|
|
brew install \
|
|
libxmlsec1 \
|
|
libpq \
|
|
pkg-config \
|
|
uv \
|
|
postgresql \
|
|
node@24 \
|
|
golangci-lint \
|
|
krb5
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="Linux">
|
|
|
|
For Debian/Ubuntu-based distributions (you can edit the following command if you already have some of these and want to skip installing them again):
|
|
|
|
```shell
|
|
pip install uv
|
|
sudo apt-get install -y \
|
|
libgss-dev \
|
|
krb5-config \
|
|
libkrb5-dev \
|
|
postgresql-server-dev-all \
|
|
postgresql
|
|
```
|
|
|
|
For other distributions (Red Hat, SUSE, Arch), adjust the package names as needed.
|
|
|
|
Install `golangci-lint` by following the [official installation instructions](https://golangci-lint.run/welcome/install/#other-ci).
|
|
|
|
</TabItem>
|
|
<TabItem value="Windows">
|
|
|
|
We're currently seeking community input on running the full development environment on Windows. If you have experience with this setup, please consider contributing to this documentation.
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
## 4. Set up the backend
|
|
|
|
:::info
|
|
All `make` commands must be executed from the root directory of your local authentik Git repository.
|
|
:::
|
|
|
|
### Install dependencies
|
|
|
|
Install all required JavaScript and Python dependencies and create an isolated Python environment:
|
|
|
|
```shell
|
|
make install
|
|
```
|
|
|
|
### Generate development configuration
|
|
|
|
Create a local configuration file that uses the local databases for development:
|
|
|
|
```shell
|
|
make gen-dev-config
|
|
```
|
|
|
|
### Initialize the database
|
|
|
|
Run all migrations with the following command:
|
|
|
|
```shell
|
|
make migrate
|
|
```
|
|
|
|
:::info
|
|
If you ever want to start over, use `make dev-reset` which drops and restores the authentik PostgreSQL database to the state it was after you ran after `make migrate`.
|
|
:::
|
|
|
|
## 5. Running authentik
|
|
|
|
Now that the backend has been set up and built, you can start authentik. In two different tabs in your terminal, run the following commands from the root of your installation directory:
|
|
|
|
```shell
|
|
make run-server
|
|
```
|
|
|
|
```shell
|
|
make run-worker
|
|
```
|
|
|
|
:::info
|
|
The very first time a worker runs, it might need some time to clear the initial task queue. Adjust [`AUTHENTIK_WORKER__THREADS`](../../../install-config/configuration/#authentik_worker__threads) as required.
|
|
:::
|
|
|
|
Both processes need to run to get a fully functioning authentik development environment.
|
|
|
|
### Initial setup
|
|
|
|
To set a password for the default admin user (**akadmin**):
|
|
|
|
1. Navigate to http://localhost:9000/if/flow/initial-setup/ in your browser.
|
|
2. Follow the prompts to set up your admin account.
|
|
|
|
From now on, you can now access authentik at http://localhost:9000 using the credentials you defined in Step 2.
|
|
|
|
## 6. Build the frontend
|
|
|
|
Even if you're not planning to develop the UI, you need to build the frontend because no compiled bundle is included by default. Run the following command to build the authentik UI:
|
|
|
|
```shell
|
|
make web-build
|
|
```
|
|
|
|
For real-time feedback you can view the UI as you make changes. Run this command and then in your browser go to http://localhost:9000/.
|
|
|
|
```shell
|
|
make web-watch
|
|
```
|
|
|
|
### Hot-reloading
|
|
|
|
When `AUTHENTIK_DEBUG` is set to `true` (the default for the development environment), the authentik server automatically reloads whenever changes are made to the code. However, due to instabilities in the reloading process of the worker, that behavior is turned off for the worker. You can enable code reloading in the worker by manually running `uv run ak worker --watch`.
|
|
|
|
## Troubleshooting
|
|
|
|
### Recovery key
|
|
|
|
If you can't login anymore or the authentication flow repeats (perhaps due to an incorrectly configured stage or a failed flow import), you can create a recovery key by running this command in your terminal:
|
|
|
|
`uv run ak create_recovery_key 10 akadmin`
|
|
|
|
Copy the generated recovery key and paste it into the URL, after the domain. For example:
|
|
|
|
`http://localhost:9000/recovery/use-token/ChFk2nJKJKJKY9OdIc8yv6RCgpGYp5rdndBhR6qHoHoJoWDdlvLuvU/`
|
|
|
|
## End-to-End (E2E) Setup
|
|
|
|
Start the E2E test services with the following command:
|
|
|
|
```shell
|
|
docker compose -f tests/e2e/compose.yml up -d
|
|
```
|
|
|
|
You can then view the Selenium Chrome browser via http://localhost:7900/ using the password: `secret`.
|
|
|
|
Alternatively, you can connect directly via VNC on port `5900` using the password: `secret`.
|
|
|
|
:::info
|
|
When using Docker Desktop, host networking needs to be enabled via **Docker Settings** > **Resources** > **Network** > **Enable host networking**.
|
|
:::
|
|
|
|
## Contributing code
|
|
|
|
### Before submitting a pull request
|
|
|
|
Ensure your code meets our quality standards by running:
|
|
|
|
1. **Code linting**:
|
|
|
|
```shell
|
|
make lint-fix
|
|
make lint
|
|
```
|
|
|
|
2. **Generate updated API documentation**:
|
|
|
|
```shell
|
|
make gen
|
|
```
|
|
|
|
3. **Format frontend code**:
|
|
|
|
```shell
|
|
make web
|
|
```
|
|
|
|
4. **Run tests**:
|
|
|
|
```shell
|
|
make test
|
|
```
|
|
|
|
You can run all these checks at once with:
|
|
|
|
```shell
|
|
make all
|
|
```
|
|
|
|
### Submitting your changes
|
|
|
|
After your code passes all checks, submit a pull request on [GitHub](https://github.com/goauthentik/authentik/pulls). Be sure to:
|
|
|
|
- Provide a clear description of your changes
|
|
- Reference any related issues
|
|
- Update any related documentation
|
|
- Follow our code and documentation [style guidelines](../../contributing/#style-guides)
|
|
- Include tests for your changes where appropriate
|
|
|
|
Thank you for contributing to authentik!
|