Skip to content

Commit

Permalink
Merge branch 'main' into web/lift-license-status-to-context
Browse files Browse the repository at this point in the history
* main: (109 commits)
  translate: Updates for file web/xliff/en.xlf in fr (#8296)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in fr (#8295)
  website: update wording (#8290)
  enterrpise: exclude inactive users from license (#8294)
  web: bump API Client version (#8292)
  core: compile backend translations (#8291)
  events: migrate SystemTasks to DB (#8159)
  web/admin: fix footer links not being parsed on settings page (#8289)
  root: fix system check warnings (#8277)
  web: bump API Client version (#8288)
  enterprise: add full audit log [AUTH-458] (#8177)
  web: bump the esbuild group in /web with 2 updates (#8282)
  web: bump the sentry group in /web with 1 update (#8281)
  web: bump @codemirror/lang-html from 6.4.7 to 6.4.8 in /web (#8283)
  core: bump bandit from 1.7.6 to 1.7.7 (#8285)
  core: bump selenium from 4.16.0 to 4.17.2 (#8284)
  core: bump github.com/go-openapi/runtime from 0.26.2 to 0.27.0 (#8287)
  core: bump github.com/google/uuid from 1.5.0 to 1.6.0 (#8286)
  website/docs: Improve example nginx reverse proxy config (#8160)
  translate: Updates for file web/xliff/en.xlf in zh_CN (#8274)
  ...
  • Loading branch information
kensternberg-authentik committed Jan 25, 2024
2 parents b93b5f2 + 035795d commit f3fa553
Show file tree
Hide file tree
Showing 346 changed files with 21,042 additions and 16,125 deletions.
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Expand Up @@ -4,7 +4,7 @@ description: "Setup authentik testing environment"
inputs:
postgresql_version:
description: "Optional postgresql image tag"
default: "12"
default: "16"

runs:
using: "composite"
Expand All @@ -18,7 +18,7 @@ runs:
- name: Setup python and restore poetry
uses: actions/setup-python@v4
with:
python-version-file: 'pyproject.toml'
python-version-file: "pyproject.toml"
cache: "poetry"
- name: Setup node
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup/docker-compose.yml
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
postgresql:
image: docker.io/library/postgres:${PSQL_TAG:-12}
image: docker.io/library/postgres:${PSQL_TAG:-16}
volumes:
- db-data:/var/lib/postgresql/data
environment:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-main.yml
Expand Up @@ -172,7 +172,7 @@ jobs:
run: |
docker-compose -f tests/e2e/docker-compose.yml up -d
- id: cache-web
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: web/dist
key: ${{ runner.os }}-web-${{ hashFiles('web/package-lock.json', 'web/src/**') }}
Expand Down
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -11,6 +11,8 @@ scripts/ @goauthentik/backend
tests/ @goauthentik/backend
pyproject.toml @goauthentik/backend
poetry.lock @goauthentik/backend
go.mod @goauthentik/backend
go.sum @goauthentik/backend
# Infrastructure
.github/ @goauthentik/infrastructure
Dockerfile @goauthentik/infrastructure
Expand Down
34 changes: 23 additions & 11 deletions Makefile
Expand Up @@ -67,16 +67,18 @@ lint: ## Lint the python and golang sources
pylint $(PY_SOURCES)
golangci-lint run -v

core-install:
poetry install

migrate: ## Run the Authentik Django server's migrations
python -m lifecycle.migrate

i18n-extract: i18n-extract-core web-i18n-extract ## Extract strings that require translation into files to send to a translation service
i18n-extract: core-i18n-extract web-i18n-extract ## Extract strings that require translation into files to send to a translation service

i18n-extract-core:
core-i18n-extract:
ak makemessages --ignore web --ignore internal --ignore web --ignore web-api --ignore website -l en

install: web-install website-install ## Install all requires dependencies for `web`, `website` and `core`
poetry install
install: web-install website-install core-install ## Install all requires dependencies for `web`, `website` and `core`

dev-drop-db:
dropdb -U ${pg_user} -h ${pg_host} ${pg_name}
Expand All @@ -94,8 +96,14 @@ dev-reset: dev-drop-db dev-create-db migrate ## Drop and restore the Authentik
#########################

gen-build: ## Extract the schema from the database
AUTHENTIK_DEBUG=true ak make_blueprint_schema > blueprints/schema.json
AUTHENTIK_DEBUG=true ak spectacular --file schema.yml
AUTHENTIK_DEBUG=true \
AUTHENTIK_TENANTS__ENABLED=true \
AUTHENTIK_OUTPOSTS__DISABLE_EMBEDDED_OUTPOST=true \
ak make_blueprint_schema > blueprints/schema.json
AUTHENTIK_DEBUG=true \
AUTHENTIK_TENANTS__ENABLED=true \
AUTHENTIK_OUTPOSTS__DISABLE_EMBEDDED_OUTPOST=true \
ak spectacular --file schema.yml

gen-changelog: ## (Release) generate the changelog based from the commits since the last tag
git log --pretty=format:" - %s" $(shell git describe --tags $(shell git rev-list --tags --max-count=1))...$(shell git branch --show-current) | sort > changelog.md
Expand All @@ -114,12 +122,16 @@ gen-diff: ## (Release) generate the changelog diff between the current schema a
sed -i 's/}/}/g' diff.md
npx prettier --write diff.md

gen-clean:
rm -rf gen-go-api/
gen-clean-ts: ## Remove generated API client for Typescript
rm -rf gen-ts-api/
rm -rf web/node_modules/@goauthentik/api/

gen-client-ts: ## Build and install the authentik API for Typescript into the authentik UI Application
gen-clean-go: ## Remove generated API client for Go
rm -rf gen-go-api/

gen-clean: gen-clean-ts gen-clean-go ## Remove generated API clients

gen-client-ts: gen-clean-ts ## Build and install the authentik API for Typescript into the authentik UI Application
docker run \
--rm -v ${PWD}:/local \
--user ${UID}:${GID} \
Expand All @@ -135,7 +147,7 @@ gen-client-ts: ## Build and install the authentik API for Typescript into the a
cd gen-ts-api && npm i
\cp -rfv gen-ts-api/* web/node_modules/@goauthentik/api

gen-client-go: ## Build and install the authentik API for Golang
gen-client-go: gen-clean-go ## Build and install the authentik API for Golang
mkdir -p ./gen-go-api ./gen-go-api/templates
wget https://raw.githubusercontent.com/goauthentik/client-go/main/config.yaml -O ./gen-go-api/config.yaml
wget https://raw.githubusercontent.com/goauthentik/client-go/main/templates/README.mustache -O ./gen-go-api/templates/README.mustache
Expand All @@ -155,7 +167,7 @@ gen-client-go: ## Build and install the authentik API for Golang
gen-dev-config: ## Generate a local development config file
python -m scripts.generate_config

gen: gen-build gen-clean gen-client-ts
gen: gen-build gen-client-ts

#########################
## Web
Expand Down
14 changes: 10 additions & 4 deletions authentik/admin/api/system.py
Expand Up @@ -13,6 +13,7 @@
from rest_framework.views import APIView

from authentik.core.api.utils import PassiveSerializer
from authentik.lib.config import CONFIG
from authentik.lib.utils.reflection import get_env
from authentik.outposts.apps import MANAGED_OUTPOST
from authentik.outposts.models import Outpost
Expand All @@ -37,8 +38,9 @@ class SystemInfoSerializer(PassiveSerializer):
http_host = SerializerMethodField()
http_is_secure = SerializerMethodField()
runtime = SerializerMethodField()
tenant = SerializerMethodField()
brand = SerializerMethodField()
server_time = SerializerMethodField()
embedded_outpost_disabled = SerializerMethodField()
embedded_outpost_host = SerializerMethodField()

def get_http_headers(self, request: Request) -> dict[str, str]:
Expand Down Expand Up @@ -69,14 +71,18 @@ def get_runtime(self, request: Request) -> RuntimeDict:
"uname": " ".join(platform.uname()),
}

def get_tenant(self, request: Request) -> str:
"""Currently active tenant"""
return str(request._request.tenant)
def get_brand(self, request: Request) -> str:
"""Currently active brand"""
return str(request._request.brand)

def get_server_time(self, request: Request) -> datetime:
"""Current server time"""
return now()

def get_embedded_outpost_disabled(self, request: Request) -> bool:
"""Whether the embedded outpost is disabled"""
return CONFIG.get_bool("outposts.disable_embedded_outpost", False)

def get_embedded_outpost_host(self, request: Request) -> str:
"""Get the FQDN configured on the embedded outpost"""
outposts = Outpost.objects.filter(managed=MANAGED_OUTPOST)
Expand Down
134 changes: 0 additions & 134 deletions authentik/admin/api/tasks.py

This file was deleted.

2 changes: 1 addition & 1 deletion authentik/admin/apps.py
Expand Up @@ -15,6 +15,6 @@ class AuthentikAdminConfig(ManagedAppConfig):
verbose_name = "authentik Admin"
default = True

def reconcile_load_admin_signals(self):
def reconcile_global_load_admin_signals(self):
"""Load admin signals"""
self.import_module("authentik.admin.signals")
8 changes: 0 additions & 8 deletions authentik/admin/signals.py
@@ -1,7 +1,6 @@
"""admin signals"""
from django.dispatch import receiver

from authentik.admin.api.tasks import TaskInfo
from authentik.admin.apps import GAUGE_WORKERS
from authentik.root.celery import CELERY_APP
from authentik.root.monitoring import monitoring_set
Expand All @@ -12,10 +11,3 @@ def monitoring_set_workers(sender, **kwargs):
"""Set worker gauge"""
count = len(CELERY_APP.control.ping(timeout=0.5))
GAUGE_WORKERS.set(count)


@receiver(monitoring_set)
def monitoring_set_tasks(sender, **kwargs):
"""Set task gauges"""
for task in TaskInfo.all().values():
task.update_metrics()
19 changes: 6 additions & 13 deletions authentik/admin/tasks.py
Expand Up @@ -11,12 +11,7 @@
from authentik import __version__, get_build_hash
from authentik.admin.apps import PROM_INFO
from authentik.events.models import Event, EventAction, Notification
from authentik.events.monitored_tasks import (
MonitoredTask,
TaskResult,
TaskResultStatus,
prefill_task,
)
from authentik.events.system_tasks import SystemTask, TaskStatus, prefill_task
from authentik.lib.config import CONFIG
from authentik.lib.utils.http import get_http_session
from authentik.root.celery import CELERY_APP
Expand Down Expand Up @@ -54,13 +49,13 @@ def clear_update_notifications():
notification.delete()


@CELERY_APP.task(bind=True, base=MonitoredTask)
@CELERY_APP.task(bind=True, base=SystemTask)
@prefill_task
def update_latest_version(self: MonitoredTask):
def update_latest_version(self: SystemTask):
"""Update latest version info"""
if CONFIG.get_bool("disable_update_check"):
cache.set(VERSION_CACHE_KEY, "0.0.0", VERSION_CACHE_TIMEOUT)
self.set_status(TaskResult(TaskResultStatus.WARNING, messages=["Version check disabled."]))
self.set_status(TaskStatus.WARNING, "Version check disabled.")
return
try:
response = get_http_session().get(
Expand All @@ -70,9 +65,7 @@ def update_latest_version(self: MonitoredTask):
data = response.json()
upstream_version = data.get("stable", {}).get("version")
cache.set(VERSION_CACHE_KEY, upstream_version, VERSION_CACHE_TIMEOUT)
self.set_status(
TaskResult(TaskResultStatus.SUCCESSFUL, ["Successfully updated latest Version"])
)
self.set_status(TaskStatus.SUCCESSFUL, "Successfully updated latest Version")
_set_prom_info()
# Check if upstream version is newer than what we're running,
# and if no event exists yet, create one.
Expand All @@ -89,7 +82,7 @@ def update_latest_version(self: MonitoredTask):
Event.new(EventAction.UPDATE_AVAILABLE, **event_dict).save()
except (RequestException, IndexError) as exc:
cache.set(VERSION_CACHE_KEY, "0.0.0", VERSION_CACHE_TIMEOUT)
self.set_status(TaskResult(TaskResultStatus.ERROR).with_error(exc))
self.set_error(exc)


_set_prom_info()

0 comments on commit f3fa553

Please sign in to comment.