Compare commits
37 Commits
core/fix-g
...
npm-worksp
Author | SHA1 | Date | |
---|---|---|---|
ee6b8b596e | |||
1c5e906a3e | |||
c133ba9bd3 | |||
65517f3b7f | |||
b361dd3b59 | |||
40f598f3f1 | |||
b72d0e84c9 | |||
d97297e0ce | |||
1a80353bc0 | |||
beece507fd | |||
e2bec88403 | |||
26b6c2e130 | |||
1a38679ecf | |||
b2334c3680 | |||
13251bb8c4 | |||
9fe6bac99d | |||
7c9fe53b47 | |||
b20c4eab29 | |||
8ca09a9ece | |||
856598fc54 | |||
fdb7b29d9a | |||
3748781368 | |||
99b559893b | |||
8014088c3a | |||
3ee353126f | |||
db76c5d9e2 | |||
61bff69b7d | |||
69651323e3 | |||
75a0ac9588 | |||
941a697397 | |||
4a74db17a1 | |||
0cf6bff93c | |||
814e438422 | |||
2db77a37dd | |||
e40c5ac617 | |||
7440900dac | |||
ca96b27825 |
@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 2025.4.0
|
current_version = 2025.4.1
|
||||||
tag = True
|
tag = True
|
||||||
commit = True
|
commit = True
|
||||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:-(?P<rc_t>[a-zA-Z-]+)(?P<rc_n>[1-9]\\d*))?
|
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:-(?P<rc_t>[a-zA-Z-]+)(?P<rc_n>[1-9]\\d*))?
|
||||||
|
1
.github/workflows/api-ts-publish.yml
vendored
1
.github/workflows/api-ts-publish.yml
vendored
@ -53,6 +53,7 @@ jobs:
|
|||||||
signoff: true
|
signoff: true
|
||||||
# ID from https://api.github.com/users/authentik-automation[bot]
|
# ID from https://api.github.com/users/authentik-automation[bot]
|
||||||
author: authentik-automation[bot] <135050075+authentik-automation[bot]@users.noreply.github.com>
|
author: authentik-automation[bot] <135050075+authentik-automation[bot]@users.noreply.github.com>
|
||||||
|
labels: dependencies
|
||||||
- uses: peter-evans/enable-pull-request-automerge@v3
|
- uses: peter-evans/enable-pull-request-automerge@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.generate_token.outputs.token }}
|
token: ${{ steps.generate_token.outputs.token }}
|
||||||
|
@ -37,6 +37,7 @@ jobs:
|
|||||||
signoff: true
|
signoff: true
|
||||||
# ID from https://api.github.com/users/authentik-automation[bot]
|
# ID from https://api.github.com/users/authentik-automation[bot]
|
||||||
author: authentik-automation[bot] <135050075+authentik-automation[bot]@users.noreply.github.com>
|
author: authentik-automation[bot] <135050075+authentik-automation[bot]@users.noreply.github.com>
|
||||||
|
labels: dependencies
|
||||||
- uses: peter-evans/enable-pull-request-automerge@v3
|
- uses: peter-evans/enable-pull-request-automerge@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.generate_token.outputs.token }}
|
token: ${{ steps.generate_token.outputs.token }}
|
||||||
|
1
.github/workflows/image-compress.yml
vendored
1
.github/workflows/image-compress.yml
vendored
@ -53,6 +53,7 @@ jobs:
|
|||||||
body: ${{ steps.compress.outputs.markdown }}
|
body: ${{ steps.compress.outputs.markdown }}
|
||||||
delete-branch: true
|
delete-branch: true
|
||||||
signoff: true
|
signoff: true
|
||||||
|
labels: dependencies
|
||||||
- uses: peter-evans/enable-pull-request-automerge@v3
|
- uses: peter-evans/enable-pull-request-automerge@v3
|
||||||
if: "${{ github.event_name != 'pull_request' && steps.compress.outputs.markdown != '' }}"
|
if: "${{ github.event_name != 'pull_request' && steps.compress.outputs.markdown != '' }}"
|
||||||
with:
|
with:
|
||||||
|
@ -52,3 +52,6 @@ jobs:
|
|||||||
body: "core, web: update translations"
|
body: "core, web: update translations"
|
||||||
delete-branch: true
|
delete-branch: true
|
||||||
signoff: true
|
signoff: true
|
||||||
|
labels: dependencies
|
||||||
|
# ID from https://api.github.com/users/authentik-automation[bot]
|
||||||
|
author: authentik-automation[bot] <135050075+authentik-automation[bot]@users.noreply.github.com>
|
||||||
|
14
.github/workflows/translation-rename.yml
vendored
14
.github/workflows/translation-rename.yml
vendored
@ -25,23 +25,13 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||||
run: |
|
run: |
|
||||||
title=$(curl -q -L \
|
title=$(gh pr view ${{ github.event.pull_request.number }} --json "title" -q ".title")
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "Authorization: Bearer ${GH_TOKEN}" \
|
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
||||||
https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }} | jq -r .title)
|
|
||||||
echo "title=${title}" >> "$GITHUB_OUTPUT"
|
echo "title=${title}" >> "$GITHUB_OUTPUT"
|
||||||
- name: Rename
|
- name: Rename
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||||
run: |
|
run: |
|
||||||
curl -L \
|
gh pr edit -t "translate: ${{ steps.title.outputs.title }}" --add-label dependencies
|
||||||
-X PATCH \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "Authorization: Bearer ${GH_TOKEN}" \
|
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
||||||
https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }} \
|
|
||||||
-d "{\"title\":\"translate: ${{ steps.title.outputs.title }}\"}"
|
|
||||||
- uses: peter-evans/enable-pull-request-automerge@v3
|
- uses: peter-evans/enable-pull-request-automerge@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.generate_token.outputs.token }}
|
token: ${{ steps.generate_token.outputs.token }}
|
||||||
|
@ -94,7 +94,7 @@ RUN --mount=type=secret,id=GEOIPUPDATE_ACCOUNT_ID \
|
|||||||
/bin/sh -c "GEOIPUPDATE_LICENSE_KEY_FILE=/run/secrets/GEOIPUPDATE_LICENSE_KEY /usr/bin/entry.sh || echo 'Failed to get GeoIP database, disabling'; exit 0"
|
/bin/sh -c "GEOIPUPDATE_LICENSE_KEY_FILE=/run/secrets/GEOIPUPDATE_LICENSE_KEY /usr/bin/entry.sh || echo 'Failed to get GeoIP database, disabling'; exit 0"
|
||||||
|
|
||||||
# Stage 5: Download uv
|
# Stage 5: Download uv
|
||||||
FROM ghcr.io/astral-sh/uv:0.7.3 AS uv
|
FROM ghcr.io/astral-sh/uv:0.7.5 AS uv
|
||||||
# Stage 6: Base python image
|
# Stage 6: Base python image
|
||||||
FROM ghcr.io/goauthentik/fips-python:3.13.3-slim-bookworm-fips AS python-base
|
FROM ghcr.io/goauthentik/fips-python:3.13.3-slim-bookworm-fips AS python-base
|
||||||
|
|
||||||
|
51
Makefile
51
Makefile
@ -1,6 +1,7 @@
|
|||||||
.PHONY: gen dev-reset all clean test web website
|
.PHONY: gen dev-reset all clean test web website
|
||||||
|
|
||||||
.SHELLFLAGS += ${SHELLFLAGS} -e
|
SHELL := /bin/bash
|
||||||
|
.SHELLFLAGS += ${SHELLFLAGS} -e -o pipefail
|
||||||
PWD = $(shell pwd)
|
PWD = $(shell pwd)
|
||||||
UID = $(shell id -u)
|
UID = $(shell id -u)
|
||||||
GID = $(shell id -g)
|
GID = $(shell id -g)
|
||||||
@ -8,9 +9,9 @@ NPM_VERSION = $(shell python -m scripts.generate_semver)
|
|||||||
PY_SOURCES = authentik tests scripts lifecycle .github
|
PY_SOURCES = authentik tests scripts lifecycle .github
|
||||||
DOCKER_IMAGE ?= "authentik:test"
|
DOCKER_IMAGE ?= "authentik:test"
|
||||||
|
|
||||||
GEN_API_TS = "gen-ts-api"
|
GEN_API_TS = gen-ts-api
|
||||||
GEN_API_PY = "gen-py-api"
|
GEN_API_PY = gen-py-api
|
||||||
GEN_API_GO = "gen-go-api"
|
GEN_API_GO = gen-go-api
|
||||||
|
|
||||||
pg_user := $(shell uv run python -m authentik.lib.config postgresql.user 2>/dev/null)
|
pg_user := $(shell uv run python -m authentik.lib.config postgresql.user 2>/dev/null)
|
||||||
pg_host := $(shell uv run python -m authentik.lib.config postgresql.host 2>/dev/null)
|
pg_host := $(shell uv run python -m authentik.lib.config postgresql.host 2>/dev/null)
|
||||||
@ -117,14 +118,19 @@ gen-diff: ## (Release) generate the changelog diff between the current schema a
|
|||||||
npx prettier --write diff.md
|
npx prettier --write diff.md
|
||||||
|
|
||||||
gen-clean-ts: ## Remove generated API client for Typescript
|
gen-clean-ts: ## Remove generated API client for Typescript
|
||||||
rm -rf ./${GEN_API_TS}/
|
rm -rf ${PWD}/${GEN_API_TS}/
|
||||||
rm -rf ./web/node_modules/@goauthentik/api/
|
rm -rf ${PWD}/web/node_modules/@goauthentik/api/
|
||||||
|
|
||||||
gen-clean-go: ## Remove generated API client for Go
|
gen-clean-go: ## Remove generated API client for Go
|
||||||
rm -rf ./${GEN_API_GO}/
|
mkdir -p ${PWD}/${GEN_API_GO}
|
||||||
|
ifneq ($(wildcard ${PWD}/${GEN_API_GO}/.*),)
|
||||||
|
make -C ${PWD}/${GEN_API_GO} clean
|
||||||
|
else
|
||||||
|
rm -rf ${PWD}/${GEN_API_GO}
|
||||||
|
endif
|
||||||
|
|
||||||
gen-clean-py: ## Remove generated API client for Python
|
gen-clean-py: ## Remove generated API client for Python
|
||||||
rm -rf ./${GEN_API_PY}/
|
rm -rf ${PWD}/${GEN_API_PY}/
|
||||||
|
|
||||||
gen-clean: gen-clean-ts gen-clean-go gen-clean-py ## Remove generated API clients
|
gen-clean: gen-clean-ts gen-clean-go gen-clean-py ## Remove generated API clients
|
||||||
|
|
||||||
@ -141,8 +147,8 @@ gen-client-ts: gen-clean-ts ## Build and install the authentik API for Typescri
|
|||||||
--git-repo-id authentik \
|
--git-repo-id authentik \
|
||||||
--git-user-id goauthentik
|
--git-user-id goauthentik
|
||||||
mkdir -p web/node_modules/@goauthentik/api
|
mkdir -p web/node_modules/@goauthentik/api
|
||||||
cd ./${GEN_API_TS} && npm i
|
cd ${PWD}/${GEN_API_TS} && npm i
|
||||||
\cp -rf ./${GEN_API_TS}/* web/node_modules/@goauthentik/api
|
\cp -rf ${PWD}/${GEN_API_TS}/* web/node_modules/@goauthentik/api
|
||||||
|
|
||||||
gen-client-py: gen-clean-py ## Build and install the authentik API for Python
|
gen-client-py: gen-clean-py ## Build and install the authentik API for Python
|
||||||
docker run \
|
docker run \
|
||||||
@ -156,24 +162,17 @@ gen-client-py: gen-clean-py ## Build and install the authentik API for Python
|
|||||||
--additional-properties=packageVersion=${NPM_VERSION} \
|
--additional-properties=packageVersion=${NPM_VERSION} \
|
||||||
--git-repo-id authentik \
|
--git-repo-id authentik \
|
||||||
--git-user-id goauthentik
|
--git-user-id goauthentik
|
||||||
pip install ./${GEN_API_PY}
|
|
||||||
|
|
||||||
gen-client-go: gen-clean-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_API_GO} ./${GEN_API_GO}/templates
|
mkdir -p ${PWD}/${GEN_API_GO}
|
||||||
wget https://raw.githubusercontent.com/goauthentik/client-go/main/config.yaml -O ./${GEN_API_GO}/config.yaml
|
ifeq ($(wildcard ${PWD}/${GEN_API_GO}/.*),)
|
||||||
wget https://raw.githubusercontent.com/goauthentik/client-go/main/templates/README.mustache -O ./${GEN_API_GO}/templates/README.mustache
|
git clone --depth 1 https://github.com/goauthentik/client-go.git ${PWD}/${GEN_API_GO}
|
||||||
wget https://raw.githubusercontent.com/goauthentik/client-go/main/templates/go.mod.mustache -O ./${GEN_API_GO}/templates/go.mod.mustache
|
else
|
||||||
cp schema.yml ./${GEN_API_GO}/
|
cd ${PWD}/${GEN_API_GO} && git pull
|
||||||
docker run \
|
endif
|
||||||
--rm -v ${PWD}/${GEN_API_GO}:/local \
|
cp ${PWD}/schema.yml ${PWD}/${GEN_API_GO}
|
||||||
--user ${UID}:${GID} \
|
make -C ${PWD}/${GEN_API_GO} build
|
||||||
docker.io/openapitools/openapi-generator-cli:v6.5.0 generate \
|
|
||||||
-i /local/schema.yml \
|
|
||||||
-g go \
|
|
||||||
-o /local/ \
|
|
||||||
-c /local/config.yaml
|
|
||||||
go mod edit -replace goauthentik.io/api/v3=./${GEN_API_GO}
|
go mod edit -replace goauthentik.io/api/v3=./${GEN_API_GO}
|
||||||
rm -rf ./${GEN_API_GO}/config.yaml ./${GEN_API_GO}/templates/
|
|
||||||
|
|
||||||
gen-dev-config: ## Generate a local development config file
|
gen-dev-config: ## Generate a local development config file
|
||||||
uv run scripts/generate_config.py
|
uv run scripts/generate_config.py
|
||||||
@ -244,7 +243,7 @@ docker: ## Build a docker image of the current source tree
|
|||||||
DOCKER_BUILDKIT=1 docker build . --progress plain --tag ${DOCKER_IMAGE}
|
DOCKER_BUILDKIT=1 docker build . --progress plain --tag ${DOCKER_IMAGE}
|
||||||
|
|
||||||
test-docker:
|
test-docker:
|
||||||
BUILD=true ./scripts/test_docker.sh
|
BUILD=true ${PWD}/scripts/test_docker.sh
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
## CI
|
## CI
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from os import environ
|
from os import environ
|
||||||
|
|
||||||
__version__ = "2025.4.0"
|
__version__ = "2025.4.1"
|
||||||
ENV_GIT_HASH_KEY = "GIT_BUILD_HASH"
|
ENV_GIT_HASH_KEY = "GIT_BUILD_HASH"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
"""API Authentication"""
|
"""API Authentication"""
|
||||||
|
|
||||||
from hmac import compare_digest
|
from hmac import compare_digest
|
||||||
|
from pathlib import Path
|
||||||
|
from tempfile import gettempdir
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from drf_spectacular.extensions import OpenApiAuthenticationExtension
|
from drf_spectacular.extensions import OpenApiAuthenticationExtension
|
||||||
from rest_framework.authentication import BaseAuthentication, get_authorization_header
|
from rest_framework.authentication import BaseAuthentication, get_authorization_header
|
||||||
from rest_framework.exceptions import AuthenticationFailed
|
from rest_framework.exceptions import AuthenticationFailed
|
||||||
@ -11,11 +14,17 @@ from rest_framework.request import Request
|
|||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.core.middleware import CTX_AUTH_VIA
|
from authentik.core.middleware import CTX_AUTH_VIA
|
||||||
from authentik.core.models import Token, TokenIntents, User
|
from authentik.core.models import Token, TokenIntents, User, UserTypes
|
||||||
from authentik.outposts.models import Outpost
|
from authentik.outposts.models import Outpost
|
||||||
from authentik.providers.oauth2.constants import SCOPE_AUTHENTIK_API
|
from authentik.providers.oauth2.constants import SCOPE_AUTHENTIK_API
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
|
_tmp = Path(gettempdir())
|
||||||
|
try:
|
||||||
|
with open(_tmp / "authentik-core-ipc.key") as _f:
|
||||||
|
ipc_key = _f.read()
|
||||||
|
except OSError:
|
||||||
|
ipc_key = None
|
||||||
|
|
||||||
|
|
||||||
def validate_auth(header: bytes) -> str | None:
|
def validate_auth(header: bytes) -> str | None:
|
||||||
@ -73,6 +82,11 @@ def auth_user_lookup(raw_header: bytes) -> User | None:
|
|||||||
if user:
|
if user:
|
||||||
CTX_AUTH_VIA.set("secret_key")
|
CTX_AUTH_VIA.set("secret_key")
|
||||||
return user
|
return user
|
||||||
|
# then try to auth via secret key (for embedded outpost/etc)
|
||||||
|
user = token_ipc(auth_credentials)
|
||||||
|
if user:
|
||||||
|
CTX_AUTH_VIA.set("ipc")
|
||||||
|
return user
|
||||||
raise AuthenticationFailed("Token invalid/expired")
|
raise AuthenticationFailed("Token invalid/expired")
|
||||||
|
|
||||||
|
|
||||||
@ -90,6 +104,43 @@ def token_secret_key(value: str) -> User | None:
|
|||||||
return outpost.user
|
return outpost.user
|
||||||
|
|
||||||
|
|
||||||
|
class IPCUser(AnonymousUser):
|
||||||
|
"""'Virtual' user for IPC communication between authentik core and the authentik router"""
|
||||||
|
|
||||||
|
username = "authentik:system"
|
||||||
|
is_active = True
|
||||||
|
is_superuser = True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return UserTypes.INTERNAL_SERVICE_ACCOUNT
|
||||||
|
|
||||||
|
def has_perm(self, perm, obj=None):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def has_perms(self, perm_list, obj=None):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def has_module_perms(self, module):
|
||||||
|
return True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_anonymous(self):
|
||||||
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_authenticated(self):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def token_ipc(value: str) -> User | None:
|
||||||
|
"""Check if the token is the secret key
|
||||||
|
and return the service account for the managed outpost"""
|
||||||
|
if not ipc_key or not compare_digest(value, ipc_key):
|
||||||
|
return None
|
||||||
|
return IPCUser()
|
||||||
|
|
||||||
|
|
||||||
class TokenAuthentication(BaseAuthentication):
|
class TokenAuthentication(BaseAuthentication):
|
||||||
"""Token-based authentication using HTTP Bearer authentication"""
|
"""Token-based authentication using HTTP Bearer authentication"""
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ class BrandSerializer(ModelSerializer):
|
|||||||
"flow_device_code",
|
"flow_device_code",
|
||||||
"default_application",
|
"default_application",
|
||||||
"web_certificate",
|
"web_certificate",
|
||||||
|
"client_certificates",
|
||||||
"attributes",
|
"attributes",
|
||||||
]
|
]
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
@ -120,6 +121,7 @@ class BrandViewSet(UsedByMixin, ModelViewSet):
|
|||||||
"domain",
|
"domain",
|
||||||
"branding_title",
|
"branding_title",
|
||||||
"web_certificate__name",
|
"web_certificate__name",
|
||||||
|
"client_certificates__name",
|
||||||
]
|
]
|
||||||
filterset_fields = [
|
filterset_fields = [
|
||||||
"brand_uuid",
|
"brand_uuid",
|
||||||
@ -136,6 +138,7 @@ class BrandViewSet(UsedByMixin, ModelViewSet):
|
|||||||
"flow_user_settings",
|
"flow_user_settings",
|
||||||
"flow_device_code",
|
"flow_device_code",
|
||||||
"web_certificate",
|
"web_certificate",
|
||||||
|
"client_certificates",
|
||||||
]
|
]
|
||||||
ordering = ["domain"]
|
ordering = ["domain"]
|
||||||
|
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
# Generated by Django 5.1.9 on 2025-05-19 15:09
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_brands", "0009_brand_branding_default_flow_background"),
|
||||||
|
("authentik_crypto", "0004_alter_certificatekeypair_name"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="brand",
|
||||||
|
name="client_certificates",
|
||||||
|
field=models.ManyToManyField(
|
||||||
|
blank=True,
|
||||||
|
default=None,
|
||||||
|
help_text="Certificates used for client authentication.",
|
||||||
|
to="authentik_crypto.certificatekeypair",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="brand",
|
||||||
|
name="web_certificate",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
default=None,
|
||||||
|
help_text="Web Certificate used by the authentik Core webserver.",
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.SET_DEFAULT,
|
||||||
|
related_name="+",
|
||||||
|
to="authentik_crypto.certificatekeypair",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
@ -73,6 +73,13 @@ class Brand(SerializerModel):
|
|||||||
default=None,
|
default=None,
|
||||||
on_delete=models.SET_DEFAULT,
|
on_delete=models.SET_DEFAULT,
|
||||||
help_text=_("Web Certificate used by the authentik Core webserver."),
|
help_text=_("Web Certificate used by the authentik Core webserver."),
|
||||||
|
related_name="+",
|
||||||
|
)
|
||||||
|
client_certificates = models.ManyToManyField(
|
||||||
|
CertificateKeyPair,
|
||||||
|
default=None,
|
||||||
|
blank=True,
|
||||||
|
help_text=_("Certificates used for client authentication."),
|
||||||
)
|
)
|
||||||
attributes = models.JSONField(default=dict, blank=True)
|
attributes = models.JSONField(default=dict, blank=True)
|
||||||
|
|
||||||
|
@ -16,12 +16,10 @@ from drf_spectacular.utils import (
|
|||||||
from guardian.shortcuts import get_objects_for_user
|
from guardian.shortcuts import get_objects_for_user
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.fields import CharField, IntegerField, SerializerMethodField
|
from rest_framework.fields import CharField, IntegerField, SerializerMethodField
|
||||||
from rest_framework.permissions import SAFE_METHODS, BasePermission
|
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.serializers import ListSerializer, ValidationError
|
from rest_framework.serializers import ListSerializer, ValidationError
|
||||||
from rest_framework.validators import UniqueValidator
|
from rest_framework.validators import UniqueValidator
|
||||||
from rest_framework.views import View
|
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
from authentik.core.api.used_by import UsedByMixin
|
from authentik.core.api.used_by import UsedByMixin
|
||||||
@ -87,6 +85,33 @@ class GroupSerializer(ModelSerializer):
|
|||||||
raise ValidationError(_("Cannot set group as parent of itself."))
|
raise ValidationError(_("Cannot set group as parent of itself."))
|
||||||
return parent
|
return parent
|
||||||
|
|
||||||
|
def validate_is_superuser(self, superuser: bool):
|
||||||
|
"""Ensure that the user creating this group has permissions to set the superuser flag"""
|
||||||
|
request: Request = self.context.get("request", None)
|
||||||
|
if not request:
|
||||||
|
return superuser
|
||||||
|
# If we're updating an instance, and the state hasn't changed, we don't need to check perms
|
||||||
|
if self.instance and superuser == self.instance.is_superuser:
|
||||||
|
return superuser
|
||||||
|
user: User = request.user
|
||||||
|
perm = (
|
||||||
|
"authentik_core.enable_group_superuser"
|
||||||
|
if superuser
|
||||||
|
else "authentik_core.disable_group_superuser"
|
||||||
|
)
|
||||||
|
if self.instance or superuser:
|
||||||
|
has_perm = user.has_perm(perm) or user.has_perm(perm, self.instance)
|
||||||
|
if not has_perm:
|
||||||
|
raise ValidationError(
|
||||||
|
_(
|
||||||
|
(
|
||||||
|
"User does not have permission to set "
|
||||||
|
"superuser status to {superuser_status}."
|
||||||
|
).format_map({"superuser_status": superuser})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return superuser
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Group
|
model = Group
|
||||||
fields = [
|
fields = [
|
||||||
@ -154,36 +179,6 @@ class GroupFilter(FilterSet):
|
|||||||
fields = ["name", "is_superuser", "members_by_pk", "attributes", "members_by_username"]
|
fields = ["name", "is_superuser", "members_by_pk", "attributes", "members_by_username"]
|
||||||
|
|
||||||
|
|
||||||
class SuperuserSetter(BasePermission):
|
|
||||||
"""Check for enable_group_superuser or disable_group_superuser permissions"""
|
|
||||||
|
|
||||||
message = _("User does not have permission to set the given superuser status.")
|
|
||||||
enable_perm = "authentik_core.enable_group_superuser"
|
|
||||||
disable_perm = "authentik_core.disable_group_superuser"
|
|
||||||
|
|
||||||
def has_permission(self, request: Request, view: View):
|
|
||||||
if request.method != "POST":
|
|
||||||
return True
|
|
||||||
|
|
||||||
is_superuser = request.data.get("is_superuser", False)
|
|
||||||
if not is_superuser:
|
|
||||||
return True
|
|
||||||
|
|
||||||
return request.user.has_perm(self.enable_perm)
|
|
||||||
|
|
||||||
def has_object_permission(self, request: Request, view: View, object: Group):
|
|
||||||
if request.method in SAFE_METHODS:
|
|
||||||
return True
|
|
||||||
|
|
||||||
new_value = request.data.get("is_superuser")
|
|
||||||
old_value = object.is_superuser
|
|
||||||
if new_value is None or new_value == old_value:
|
|
||||||
return True
|
|
||||||
|
|
||||||
perm = self.enable_perm if new_value else self.disable_perm
|
|
||||||
return request.user.has_perm(perm) or request.user.has_perm(perm, object)
|
|
||||||
|
|
||||||
|
|
||||||
class GroupViewSet(UsedByMixin, ModelViewSet):
|
class GroupViewSet(UsedByMixin, ModelViewSet):
|
||||||
"""Group Viewset"""
|
"""Group Viewset"""
|
||||||
|
|
||||||
@ -196,7 +191,6 @@ class GroupViewSet(UsedByMixin, ModelViewSet):
|
|||||||
serializer_class = GroupSerializer
|
serializer_class = GroupSerializer
|
||||||
search_fields = ["name", "is_superuser"]
|
search_fields = ["name", "is_superuser"]
|
||||||
filterset_class = GroupFilter
|
filterset_class = GroupFilter
|
||||||
permission_classes = [SuperuserSetter]
|
|
||||||
ordering = ["name"]
|
ordering = ["name"]
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
@ -118,24 +118,21 @@ class TestGroupsAPI(APITestCase):
|
|||||||
reverse("authentik_api:group-list"),
|
reverse("authentik_api:group-list"),
|
||||||
data={"name": generate_id(), "is_superuser": True},
|
data={"name": generate_id(), "is_superuser": True},
|
||||||
)
|
)
|
||||||
self.assertEqual(res.status_code, 403)
|
self.assertEqual(res.status_code, 400)
|
||||||
self.assertJSONEqual(
|
self.assertJSONEqual(
|
||||||
res.content,
|
res.content,
|
||||||
{"detail": "User does not have permission to set the given superuser status."},
|
{"is_superuser": ["User does not have permission to set superuser status to True."]},
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_superuser_update_object_perm(self):
|
def test_superuser_no_perm_no_superuser(self):
|
||||||
"""Test updating a superuser group with object permission"""
|
"""Test creating a group without permission and without superuser flag"""
|
||||||
group = Group.objects.create(name=generate_id(), is_superuser=False)
|
assign_perm("authentik_core.add_group", self.login_user)
|
||||||
assign_perm("view_group", self.login_user, group)
|
|
||||||
assign_perm("change_group", self.login_user, group)
|
|
||||||
assign_perm("enable_group_superuser", self.login_user, group)
|
|
||||||
self.client.force_login(self.login_user)
|
self.client.force_login(self.login_user)
|
||||||
res = self.client.patch(
|
res = self.client.post(
|
||||||
reverse("authentik_api:group-detail", kwargs={"pk": group.pk}),
|
reverse("authentik_api:group-list"),
|
||||||
data={"is_superuser": True},
|
data={"name": generate_id(), "is_superuser": False},
|
||||||
)
|
)
|
||||||
self.assertEqual(res.status_code, 200)
|
self.assertEqual(res.status_code, 201)
|
||||||
|
|
||||||
def test_superuser_update_no_perm(self):
|
def test_superuser_update_no_perm(self):
|
||||||
"""Test updating a superuser group without permission"""
|
"""Test updating a superuser group without permission"""
|
||||||
@ -147,10 +144,10 @@ class TestGroupsAPI(APITestCase):
|
|||||||
reverse("authentik_api:group-detail", kwargs={"pk": group.pk}),
|
reverse("authentik_api:group-detail", kwargs={"pk": group.pk}),
|
||||||
data={"is_superuser": False},
|
data={"is_superuser": False},
|
||||||
)
|
)
|
||||||
self.assertEqual(res.status_code, 403)
|
self.assertEqual(res.status_code, 400)
|
||||||
self.assertJSONEqual(
|
self.assertJSONEqual(
|
||||||
res.content,
|
res.content,
|
||||||
{"detail": "User does not have permission to set the given superuser status."},
|
{"is_superuser": ["User does not have permission to set superuser status to False."]},
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_superuser_update_no_change(self):
|
def test_superuser_update_no_change(self):
|
||||||
@ -176,27 +173,3 @@ class TestGroupsAPI(APITestCase):
|
|||||||
data={"name": generate_id(), "is_superuser": True},
|
data={"name": generate_id(), "is_superuser": True},
|
||||||
)
|
)
|
||||||
self.assertEqual(res.status_code, 201)
|
self.assertEqual(res.status_code, 201)
|
||||||
|
|
||||||
def test_superuser_create_no_perm(self):
|
|
||||||
"""Test creating a superuser group with no permission"""
|
|
||||||
assign_perm("authentik_core.add_group", self.login_user)
|
|
||||||
self.client.force_login(self.login_user)
|
|
||||||
res = self.client.post(
|
|
||||||
reverse("authentik_api:group-list"),
|
|
||||||
data={"name": generate_id(), "is_superuser": True},
|
|
||||||
)
|
|
||||||
self.assertEqual(res.status_code, 403)
|
|
||||||
self.assertJSONEqual(
|
|
||||||
res.content,
|
|
||||||
{"detail": "User does not have permission to set the given superuser status."},
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_no_superuser_create_no_perm(self):
|
|
||||||
"""Test creating a non-superuser group with no permission"""
|
|
||||||
assign_perm("authentik_core.add_group", self.login_user)
|
|
||||||
self.client.force_login(self.login_user)
|
|
||||||
res = self.client.post(
|
|
||||||
reverse("authentik_api:group-list"),
|
|
||||||
data={"name": generate_id()},
|
|
||||||
)
|
|
||||||
self.assertEqual(res.status_code, 201)
|
|
||||||
|
@ -30,6 +30,7 @@ from structlog.stdlib import get_logger
|
|||||||
|
|
||||||
from authentik.core.api.used_by import UsedByMixin
|
from authentik.core.api.used_by import UsedByMixin
|
||||||
from authentik.core.api.utils import ModelSerializer, PassiveSerializer
|
from authentik.core.api.utils import ModelSerializer, PassiveSerializer
|
||||||
|
from authentik.core.models import UserTypes
|
||||||
from authentik.crypto.apps import MANAGED_KEY
|
from authentik.crypto.apps import MANAGED_KEY
|
||||||
from authentik.crypto.builder import CertificateBuilder, PrivateKeyAlg
|
from authentik.crypto.builder import CertificateBuilder, PrivateKeyAlg
|
||||||
from authentik.crypto.models import CertificateKeyPair
|
from authentik.crypto.models import CertificateKeyPair
|
||||||
@ -272,11 +273,12 @@ class CertificateKeyPairViewSet(UsedByMixin, ModelViewSet):
|
|||||||
def view_certificate(self, request: Request, pk: str) -> Response:
|
def view_certificate(self, request: Request, pk: str) -> Response:
|
||||||
"""Return certificate-key pairs certificate and log access"""
|
"""Return certificate-key pairs certificate and log access"""
|
||||||
certificate: CertificateKeyPair = self.get_object()
|
certificate: CertificateKeyPair = self.get_object()
|
||||||
Event.new( # noqa # nosec
|
if request.user.type != UserTypes.INTERNAL_SERVICE_ACCOUNT:
|
||||||
EventAction.SECRET_VIEW,
|
Event.new( # noqa # nosec
|
||||||
secret=certificate,
|
EventAction.SECRET_VIEW,
|
||||||
type="certificate",
|
secret=certificate,
|
||||||
).from_http(request)
|
type="certificate",
|
||||||
|
).from_http(request)
|
||||||
if "download" in request.query_params:
|
if "download" in request.query_params:
|
||||||
# Mime type from https://pki-tutorial.readthedocs.io/en/latest/mime.html
|
# Mime type from https://pki-tutorial.readthedocs.io/en/latest/mime.html
|
||||||
response = HttpResponse(
|
response = HttpResponse(
|
||||||
@ -302,11 +304,12 @@ class CertificateKeyPairViewSet(UsedByMixin, ModelViewSet):
|
|||||||
def view_private_key(self, request: Request, pk: str) -> Response:
|
def view_private_key(self, request: Request, pk: str) -> Response:
|
||||||
"""Return certificate-key pairs private key and log access"""
|
"""Return certificate-key pairs private key and log access"""
|
||||||
certificate: CertificateKeyPair = self.get_object()
|
certificate: CertificateKeyPair = self.get_object()
|
||||||
Event.new( # noqa # nosec
|
if request.user.type != UserTypes.INTERNAL_SERVICE_ACCOUNT:
|
||||||
EventAction.SECRET_VIEW,
|
Event.new( # noqa # nosec
|
||||||
secret=certificate,
|
EventAction.SECRET_VIEW,
|
||||||
type="private_key",
|
secret=certificate,
|
||||||
).from_http(request)
|
type="private_key",
|
||||||
|
).from_http(request)
|
||||||
if "download" in request.query_params:
|
if "download" in request.query_params:
|
||||||
# Mime type from https://pki-tutorial.readthedocs.io/en/latest/mime.html
|
# Mime type from https://pki-tutorial.readthedocs.io/en/latest/mime.html
|
||||||
response = HttpResponse(certificate.key_data, content_type="application/x-pem-file")
|
response = HttpResponse(certificate.key_data, content_type="application/x-pem-file")
|
||||||
|
@ -25,7 +25,7 @@ class GoogleWorkspaceGroupClient(
|
|||||||
"""Google client for groups"""
|
"""Google client for groups"""
|
||||||
|
|
||||||
connection_type = GoogleWorkspaceProviderGroup
|
connection_type = GoogleWorkspaceProviderGroup
|
||||||
connection_type_query = "group"
|
connection_attr = "googleworkspaceprovidergroup_set"
|
||||||
can_discover = True
|
can_discover = True
|
||||||
|
|
||||||
def __init__(self, provider: GoogleWorkspaceProvider) -> None:
|
def __init__(self, provider: GoogleWorkspaceProvider) -> None:
|
||||||
|
@ -20,7 +20,7 @@ class GoogleWorkspaceUserClient(GoogleWorkspaceSyncClient[User, GoogleWorkspaceP
|
|||||||
"""Sync authentik users into google workspace"""
|
"""Sync authentik users into google workspace"""
|
||||||
|
|
||||||
connection_type = GoogleWorkspaceProviderUser
|
connection_type = GoogleWorkspaceProviderUser
|
||||||
connection_type_query = "user"
|
connection_attr = "googleworkspaceprovideruser_set"
|
||||||
can_discover = True
|
can_discover = True
|
||||||
|
|
||||||
def __init__(self, provider: GoogleWorkspaceProvider) -> None:
|
def __init__(self, provider: GoogleWorkspaceProvider) -> None:
|
||||||
|
@ -132,7 +132,11 @@ class GoogleWorkspaceProvider(OutgoingSyncProvider, BackchannelProvider):
|
|||||||
if type == User:
|
if type == User:
|
||||||
# Get queryset of all users with consistent ordering
|
# Get queryset of all users with consistent ordering
|
||||||
# according to the provider's settings
|
# according to the provider's settings
|
||||||
base = User.objects.all().exclude_anonymous()
|
base = (
|
||||||
|
User.objects.prefetch_related("googleworkspaceprovideruser_set")
|
||||||
|
.all()
|
||||||
|
.exclude_anonymous()
|
||||||
|
)
|
||||||
if self.exclude_users_service_account:
|
if self.exclude_users_service_account:
|
||||||
base = base.exclude(type=UserTypes.SERVICE_ACCOUNT).exclude(
|
base = base.exclude(type=UserTypes.SERVICE_ACCOUNT).exclude(
|
||||||
type=UserTypes.INTERNAL_SERVICE_ACCOUNT
|
type=UserTypes.INTERNAL_SERVICE_ACCOUNT
|
||||||
@ -142,7 +146,11 @@ class GoogleWorkspaceProvider(OutgoingSyncProvider, BackchannelProvider):
|
|||||||
return base.order_by("pk")
|
return base.order_by("pk")
|
||||||
if type == Group:
|
if type == Group:
|
||||||
# Get queryset of all groups with consistent ordering
|
# Get queryset of all groups with consistent ordering
|
||||||
return Group.objects.all().order_by("pk")
|
return (
|
||||||
|
Group.objects.prefetch_related("googleworkspaceprovidergroup_set")
|
||||||
|
.all()
|
||||||
|
.order_by("pk")
|
||||||
|
)
|
||||||
raise ValueError(f"Invalid type {type}")
|
raise ValueError(f"Invalid type {type}")
|
||||||
|
|
||||||
def google_credentials(self):
|
def google_credentials(self):
|
||||||
|
@ -29,7 +29,7 @@ class MicrosoftEntraGroupClient(
|
|||||||
"""Microsoft client for groups"""
|
"""Microsoft client for groups"""
|
||||||
|
|
||||||
connection_type = MicrosoftEntraProviderGroup
|
connection_type = MicrosoftEntraProviderGroup
|
||||||
connection_type_query = "group"
|
connection_attr = "microsoftentraprovidergroup_set"
|
||||||
can_discover = True
|
can_discover = True
|
||||||
|
|
||||||
def __init__(self, provider: MicrosoftEntraProvider) -> None:
|
def __init__(self, provider: MicrosoftEntraProvider) -> None:
|
||||||
|
@ -24,7 +24,7 @@ class MicrosoftEntraUserClient(MicrosoftEntraSyncClient[User, MicrosoftEntraProv
|
|||||||
"""Sync authentik users into microsoft entra"""
|
"""Sync authentik users into microsoft entra"""
|
||||||
|
|
||||||
connection_type = MicrosoftEntraProviderUser
|
connection_type = MicrosoftEntraProviderUser
|
||||||
connection_type_query = "user"
|
connection_attr = "microsoftentraprovideruser_set"
|
||||||
can_discover = True
|
can_discover = True
|
||||||
|
|
||||||
def __init__(self, provider: MicrosoftEntraProvider) -> None:
|
def __init__(self, provider: MicrosoftEntraProvider) -> None:
|
||||||
|
@ -121,7 +121,11 @@ class MicrosoftEntraProvider(OutgoingSyncProvider, BackchannelProvider):
|
|||||||
if type == User:
|
if type == User:
|
||||||
# Get queryset of all users with consistent ordering
|
# Get queryset of all users with consistent ordering
|
||||||
# according to the provider's settings
|
# according to the provider's settings
|
||||||
base = User.objects.all().exclude_anonymous()
|
base = (
|
||||||
|
User.objects.prefetch_related("microsoftentraprovideruser_set")
|
||||||
|
.all()
|
||||||
|
.exclude_anonymous()
|
||||||
|
)
|
||||||
if self.exclude_users_service_account:
|
if self.exclude_users_service_account:
|
||||||
base = base.exclude(type=UserTypes.SERVICE_ACCOUNT).exclude(
|
base = base.exclude(type=UserTypes.SERVICE_ACCOUNT).exclude(
|
||||||
type=UserTypes.INTERNAL_SERVICE_ACCOUNT
|
type=UserTypes.INTERNAL_SERVICE_ACCOUNT
|
||||||
@ -131,7 +135,11 @@ class MicrosoftEntraProvider(OutgoingSyncProvider, BackchannelProvider):
|
|||||||
return base.order_by("pk")
|
return base.order_by("pk")
|
||||||
if type == Group:
|
if type == Group:
|
||||||
# Get queryset of all groups with consistent ordering
|
# Get queryset of all groups with consistent ordering
|
||||||
return Group.objects.all().order_by("pk")
|
return (
|
||||||
|
Group.objects.prefetch_related("microsoftentraprovidergroup_set")
|
||||||
|
.all()
|
||||||
|
.order_by("pk")
|
||||||
|
)
|
||||||
raise ValueError(f"Invalid type {type}")
|
raise ValueError(f"Invalid type {type}")
|
||||||
|
|
||||||
def microsoft_credentials(self):
|
def microsoft_credentials(self):
|
||||||
|
@ -19,6 +19,7 @@ TENANT_APPS = [
|
|||||||
"authentik.enterprise.providers.microsoft_entra",
|
"authentik.enterprise.providers.microsoft_entra",
|
||||||
"authentik.enterprise.providers.ssf",
|
"authentik.enterprise.providers.ssf",
|
||||||
"authentik.enterprise.stages.authenticator_endpoint_gdtc",
|
"authentik.enterprise.stages.authenticator_endpoint_gdtc",
|
||||||
|
"authentik.enterprise.stages.mtls",
|
||||||
"authentik.enterprise.stages.source",
|
"authentik.enterprise.stages.source",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
0
authentik/enterprise/stages/mtls/__init__.py
Normal file
0
authentik/enterprise/stages/mtls/__init__.py
Normal file
31
authentik/enterprise/stages/mtls/api.py
Normal file
31
authentik/enterprise/stages/mtls/api.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
"""Mutual TLS Stage API Views"""
|
||||||
|
|
||||||
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
|
from authentik.core.api.used_by import UsedByMixin
|
||||||
|
from authentik.enterprise.api import EnterpriseRequiredMixin
|
||||||
|
from authentik.enterprise.stages.mtls.models import MutualTLSStage
|
||||||
|
from authentik.flows.api.stages import StageSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class MutualTLSStageSerializer(EnterpriseRequiredMixin, StageSerializer):
|
||||||
|
"""MutualTLSStage Serializer"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = MutualTLSStage
|
||||||
|
fields = StageSerializer.Meta.fields + [
|
||||||
|
"mode",
|
||||||
|
"certificate_authorities",
|
||||||
|
"cert_attribute",
|
||||||
|
"user_attribute",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class MutualTLSStageViewSet(UsedByMixin, ModelViewSet):
|
||||||
|
"""MutualTLSStage Viewset"""
|
||||||
|
|
||||||
|
queryset = MutualTLSStage.objects.all()
|
||||||
|
serializer_class = MutualTLSStageSerializer
|
||||||
|
filterset_fields = "__all__"
|
||||||
|
ordering = ["name"]
|
||||||
|
search_fields = ["name"]
|
12
authentik/enterprise/stages/mtls/apps.py
Normal file
12
authentik/enterprise/stages/mtls/apps.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
"""authentik stage app config"""
|
||||||
|
|
||||||
|
from authentik.enterprise.apps import EnterpriseConfig
|
||||||
|
|
||||||
|
|
||||||
|
class AuthentikEnterpriseStageMTLSConfig(EnterpriseConfig):
|
||||||
|
"""authentik MTLS stage config"""
|
||||||
|
|
||||||
|
name = "authentik.enterprise.stages.mtls"
|
||||||
|
label = "authentik_stages_mtls"
|
||||||
|
verbose_name = "authentik Enterprise.Stages.MTLS"
|
||||||
|
default = True
|
68
authentik/enterprise/stages/mtls/migrations/0001_initial.py
Normal file
68
authentik/enterprise/stages/mtls/migrations/0001_initial.py
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# Generated by Django 5.1.9 on 2025-05-19 18:29
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_crypto", "0004_alter_certificatekeypair_name"),
|
||||||
|
("authentik_flows", "0027_auto_20231028_1424"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="MutualTLSStage",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"stage_ptr",
|
||||||
|
models.OneToOneField(
|
||||||
|
auto_created=True,
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
parent_link=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
to="authentik_flows.stage",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"mode",
|
||||||
|
models.TextField(choices=[("optional", "Optional"), ("required", "Required")]),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"cert_attribute",
|
||||||
|
models.TextField(
|
||||||
|
choices=[
|
||||||
|
("subject", "Subject"),
|
||||||
|
("common_name", "Common Name"),
|
||||||
|
("email", "Email"),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"user_attribute",
|
||||||
|
models.TextField(choices=[("username", "Username"), ("email", "Email")]),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"certificate_authorities",
|
||||||
|
models.ManyToManyField(
|
||||||
|
blank=True,
|
||||||
|
default=None,
|
||||||
|
help_text="Configure certificate authorities to validate the certificate against. This option has a higher priority than the `client_certificate` option on `Brand`.",
|
||||||
|
to="authentik_crypto.certificatekeypair",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Mutual TLS Stage",
|
||||||
|
"verbose_name_plural": "Mutual TLS Stages",
|
||||||
|
"permissions": [
|
||||||
|
("pass_outpost_certificate", "Permissions to pass Certificates for outposts.")
|
||||||
|
],
|
||||||
|
},
|
||||||
|
bases=("authentik_flows.stage",),
|
||||||
|
),
|
||||||
|
]
|
71
authentik/enterprise/stages/mtls/models.py
Normal file
71
authentik/enterprise/stages/mtls/models.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from rest_framework.serializers import Serializer
|
||||||
|
|
||||||
|
from authentik.crypto.models import CertificateKeyPair
|
||||||
|
from authentik.flows.models import Stage
|
||||||
|
from authentik.flows.stage import StageView
|
||||||
|
|
||||||
|
|
||||||
|
class TLSMode(models.TextChoices):
|
||||||
|
"""Modes the TLS Stage can operate in"""
|
||||||
|
|
||||||
|
OPTIONAL = "optional"
|
||||||
|
REQUIRED = "required"
|
||||||
|
|
||||||
|
|
||||||
|
class CertAttributes(models.TextChoices):
|
||||||
|
"""Certificate attribute used for user matching"""
|
||||||
|
|
||||||
|
SUBJECT = "subject"
|
||||||
|
COMMON_NAME = "common_name"
|
||||||
|
EMAIL = "email"
|
||||||
|
|
||||||
|
|
||||||
|
class UserAttributes(models.TextChoices):
|
||||||
|
"""User attribute for user matching"""
|
||||||
|
|
||||||
|
USERNAME = "username"
|
||||||
|
EMAIL = "email"
|
||||||
|
|
||||||
|
|
||||||
|
class MutualTLSStage(Stage):
|
||||||
|
"""Authenticate/enroll users using a client-certificate."""
|
||||||
|
|
||||||
|
mode = models.TextField(choices=TLSMode.choices)
|
||||||
|
|
||||||
|
certificate_authorities = models.ManyToManyField(
|
||||||
|
CertificateKeyPair,
|
||||||
|
default=None,
|
||||||
|
blank=True,
|
||||||
|
help_text=_(
|
||||||
|
"Configure certificate authorities to validate the certificate against. "
|
||||||
|
"This option has a higher priority than the `client_certificate` option on `Brand`."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
cert_attribute = models.TextField(choices=CertAttributes.choices)
|
||||||
|
user_attribute = models.TextField(choices=UserAttributes.choices)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def view(self) -> type[StageView]:
|
||||||
|
from authentik.enterprise.stages.mtls.stage import MTLSStageView
|
||||||
|
|
||||||
|
return MTLSStageView
|
||||||
|
|
||||||
|
@property
|
||||||
|
def serializer(self) -> type[Serializer]:
|
||||||
|
from authentik.enterprise.stages.mtls.api import MutualTLSStageSerializer
|
||||||
|
|
||||||
|
return MutualTLSStageSerializer
|
||||||
|
|
||||||
|
@property
|
||||||
|
def component(self) -> str:
|
||||||
|
return "ak-stage-mtls-form"
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _("Mutual TLS Stage")
|
||||||
|
verbose_name_plural = _("Mutual TLS Stages")
|
||||||
|
permissions = [
|
||||||
|
("pass_outpost_certificate", _("Permissions to pass Certificates for outposts.")),
|
||||||
|
]
|
215
authentik/enterprise/stages/mtls/stage.py
Normal file
215
authentik/enterprise/stages/mtls/stage.py
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
from binascii import hexlify
|
||||||
|
from urllib.parse import unquote_plus
|
||||||
|
|
||||||
|
from cryptography.exceptions import InvalidSignature
|
||||||
|
from cryptography.hazmat.primitives import hashes
|
||||||
|
from cryptography.x509 import Certificate, NameOID, ObjectIdentifier, load_pem_x509_certificate
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from authentik.brands.models import Brand
|
||||||
|
from authentik.core.models import User
|
||||||
|
from authentik.crypto.models import CertificateKeyPair
|
||||||
|
from authentik.enterprise.stages.mtls.models import (
|
||||||
|
CertAttributes,
|
||||||
|
MutualTLSStage,
|
||||||
|
TLSMode,
|
||||||
|
UserAttributes,
|
||||||
|
)
|
||||||
|
from authentik.flows.challenge import AccessDeniedChallenge
|
||||||
|
from authentik.flows.models import FlowDesignation
|
||||||
|
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER
|
||||||
|
from authentik.flows.stage import ChallengeStageView
|
||||||
|
from authentik.root.middleware import ClientIPMiddleware
|
||||||
|
from authentik.stages.password.stage import PLAN_CONTEXT_METHOD, PLAN_CONTEXT_METHOD_ARGS
|
||||||
|
from authentik.stages.prompt.stage import PLAN_CONTEXT_PROMPT
|
||||||
|
|
||||||
|
# All of these headers must only be accepted from "trusted" reverse proxies
|
||||||
|
# See internal/web/proxy.go:39
|
||||||
|
HEADER_PROXY_FORWARDED = "X-Forwarded-Client-Cert"
|
||||||
|
HEADER_NGINX_FORWARDED = "SSL-Client-Cert"
|
||||||
|
HEADER_TRAEFIK_FORWARDED = "X-Forwarded-TLS-Client-Cert"
|
||||||
|
HEADER_OUTPOST_FORWARDED = "X-Authentik-Outpost-Certificate"
|
||||||
|
|
||||||
|
|
||||||
|
PLAN_CONTEXT_CERTIFICATE = "certificate"
|
||||||
|
|
||||||
|
|
||||||
|
class MTLSStageView(ChallengeStageView):
|
||||||
|
|
||||||
|
def __parse_single_cert(self, raw: str | None) -> list[Certificate]:
|
||||||
|
"""Helper to parse a single certificate"""
|
||||||
|
if not raw:
|
||||||
|
return []
|
||||||
|
try:
|
||||||
|
cert = load_pem_x509_certificate(unquote_plus(raw).encode())
|
||||||
|
return [cert]
|
||||||
|
except ValueError as exc:
|
||||||
|
self.logger.info("Failed to parse certificate", exc=exc)
|
||||||
|
return []
|
||||||
|
|
||||||
|
def _parse_cert_xfcc(self) -> list[Certificate]:
|
||||||
|
"""Parse certificates in the format given to us in
|
||||||
|
the format of the authentik router/envoy"""
|
||||||
|
xfcc_raw = self.request.headers.get(HEADER_PROXY_FORWARDED)
|
||||||
|
if not xfcc_raw:
|
||||||
|
return []
|
||||||
|
certs = []
|
||||||
|
for r_cert in xfcc_raw.split(","):
|
||||||
|
el = r_cert.split(";")
|
||||||
|
raw_cert = {k.split("=")[0]: k.split("=")[1] for k in el}
|
||||||
|
if "Cert" not in raw_cert:
|
||||||
|
continue
|
||||||
|
certs.extend(self.__parse_single_cert(raw_cert["Cert"]))
|
||||||
|
return certs
|
||||||
|
|
||||||
|
def _parse_cert_nginx(self) -> list[Certificate]:
|
||||||
|
"""Parse certificates in the format nginx-ingress gives to us"""
|
||||||
|
sslcc_raw = self.request.headers.get(HEADER_NGINX_FORWARDED)
|
||||||
|
return self.__parse_single_cert(sslcc_raw)
|
||||||
|
|
||||||
|
def _parse_cert_traefik(self) -> list[Certificate]:
|
||||||
|
"""Parse certificates in the format traefik gives to us"""
|
||||||
|
ftcc_raw = self.request.headers.get(HEADER_TRAEFIK_FORWARDED)
|
||||||
|
return self.__parse_single_cert(ftcc_raw)
|
||||||
|
|
||||||
|
def _parse_cert_outpost(self) -> list[Certificate]:
|
||||||
|
"""Parse certificates in the format outposts give to us. Also authenticates
|
||||||
|
the outpost to ensure it has the permission to do so"""
|
||||||
|
user = ClientIPMiddleware.get_outpost_user(self.request)
|
||||||
|
if not user:
|
||||||
|
return []
|
||||||
|
if not user.has_perm(
|
||||||
|
"pass_outpost_certificate", self.executor.current_stage
|
||||||
|
) and not user.has_perm("authentik_stages_mtls.pass_outpost_certificate"):
|
||||||
|
return []
|
||||||
|
outpost_raw = self.request.headers.get(HEADER_OUTPOST_FORWARDED)
|
||||||
|
return self.__parse_single_cert(outpost_raw)
|
||||||
|
|
||||||
|
def get_authorities(self) -> list[CertificateKeyPair] | None:
|
||||||
|
# We can't access `certificate_authorities` on `self.executor.current_stage`, as that would
|
||||||
|
# load the certificate into the directly referenced foreign key, which we have to pickle
|
||||||
|
# as part of the flow plan, and cryptography certs can't be pickled
|
||||||
|
stage: MutualTLSStage = (
|
||||||
|
MutualTLSStage.objects.filter(pk=self.executor.current_stage.pk)
|
||||||
|
.prefetch_related("certificate_authorities")
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if stage.certificate_authorities.exists():
|
||||||
|
return stage.certificate_authorities.order_by("name")
|
||||||
|
brand: Brand = self.request.brand
|
||||||
|
if brand.client_certificates.exists():
|
||||||
|
return brand.client_certificates.order_by("name")
|
||||||
|
return None
|
||||||
|
|
||||||
|
def validate_cert(self, authorities: list[CertificateKeyPair], certs: list[Certificate]):
|
||||||
|
for _cert in certs:
|
||||||
|
for ca in authorities:
|
||||||
|
try:
|
||||||
|
_cert.verify_directly_issued_by(ca.certificate)
|
||||||
|
return _cert
|
||||||
|
except (InvalidSignature, TypeError, ValueError) as exc:
|
||||||
|
self.logger.warning(
|
||||||
|
"Discarding cert not issued by authority", cert=_cert, authority=ca, exc=exc
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
return None
|
||||||
|
|
||||||
|
def check_if_user(self, cert: Certificate):
|
||||||
|
stage: MutualTLSStage = self.executor.current_stage
|
||||||
|
cert_attr = None
|
||||||
|
user_attr = None
|
||||||
|
match stage.cert_attribute:
|
||||||
|
case CertAttributes.SUBJECT:
|
||||||
|
cert_attr = cert.subject.rfc4514_string()
|
||||||
|
case CertAttributes.COMMON_NAME:
|
||||||
|
cert_attr = self.get_cert_attribute(cert, NameOID.COMMON_NAME)
|
||||||
|
case CertAttributes.EMAIL:
|
||||||
|
cert_attr = self.get_cert_attribute(cert, NameOID.EMAIL_ADDRESS)
|
||||||
|
match stage.user_attribute:
|
||||||
|
case UserAttributes.USERNAME:
|
||||||
|
user_attr = "username"
|
||||||
|
case UserAttributes.EMAIL:
|
||||||
|
user_attr = "email"
|
||||||
|
if not user_attr or not cert_attr:
|
||||||
|
return None
|
||||||
|
return User.objects.filter(**{user_attr: cert_attr}).first()
|
||||||
|
|
||||||
|
def _cert_to_dict(self, cert: Certificate) -> dict:
|
||||||
|
"""Represent a certificate in a dictionary, as certificate objects cannot be pickled"""
|
||||||
|
return {
|
||||||
|
"serial_number": str(cert.serial_number),
|
||||||
|
"subject": cert.subject.rfc4514_string(),
|
||||||
|
"issuer": cert.issuer.rfc4514_string(),
|
||||||
|
"fingerprint_sha256": hexlify(cert.fingerprint(hashes.SHA256()), ":").decode("utf-8"),
|
||||||
|
"fingerprint_sha1": hexlify(cert.fingerprint(hashes.SHA256()), ":").decode("utf-8"),
|
||||||
|
}
|
||||||
|
|
||||||
|
def auth_user(self, user: User, cert: Certificate):
|
||||||
|
self.executor.plan.context[PLAN_CONTEXT_PENDING_USER] = user
|
||||||
|
self.executor.plan.context.setdefault(PLAN_CONTEXT_METHOD, "mtls")
|
||||||
|
self.executor.plan.context.setdefault(PLAN_CONTEXT_METHOD_ARGS, {})
|
||||||
|
self.executor.plan.context[PLAN_CONTEXT_METHOD_ARGS].update(
|
||||||
|
{"certificate": self._cert_to_dict(cert)}
|
||||||
|
)
|
||||||
|
|
||||||
|
def enroll_prepare_user(self, cert: Certificate):
|
||||||
|
self.executor.plan.context.setdefault(PLAN_CONTEXT_PROMPT, {})
|
||||||
|
self.executor.plan.context[PLAN_CONTEXT_PROMPT].update(
|
||||||
|
{
|
||||||
|
"email": self.get_cert_attribute(cert, NameOID.EMAIL_ADDRESS),
|
||||||
|
"name": self.get_cert_attribute(cert, NameOID.COMMON_NAME),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.executor.plan.context[PLAN_CONTEXT_CERTIFICATE] = self._cert_to_dict(cert)
|
||||||
|
|
||||||
|
def get_cert_attribute(self, cert: Certificate, oid: ObjectIdentifier) -> str | None:
|
||||||
|
attr = cert.subject.get_attributes_for_oid(oid)
|
||||||
|
if len(attr) < 1:
|
||||||
|
return None
|
||||||
|
return str(attr[0].value)
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
stage: MutualTLSStage = self.executor.current_stage
|
||||||
|
certs = [
|
||||||
|
*self._parse_cert_xfcc(),
|
||||||
|
*self._parse_cert_nginx(),
|
||||||
|
*self._parse_cert_traefik(),
|
||||||
|
*self._parse_cert_outpost(),
|
||||||
|
]
|
||||||
|
authorities = self.get_authorities()
|
||||||
|
if not authorities:
|
||||||
|
self.logger.warning("No Certificate authority found")
|
||||||
|
if stage.mode == TLSMode.OPTIONAL:
|
||||||
|
return self.executor.stage_ok()
|
||||||
|
if stage.mode == TLSMode.REQUIRED:
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
cert = self.validate_cert(authorities, certs)
|
||||||
|
if not cert and stage.mode == TLSMode.REQUIRED:
|
||||||
|
self.logger.warning("Client certificate required but no certificates given")
|
||||||
|
return super().dispatch(
|
||||||
|
request,
|
||||||
|
*args,
|
||||||
|
error_message=_("Certificate required but no certificate was given."),
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
if not cert and stage.mode == TLSMode.OPTIONAL:
|
||||||
|
self.logger.info("No certificate given, continuing")
|
||||||
|
return self.executor.stage_ok()
|
||||||
|
existing_user = self.check_if_user(cert)
|
||||||
|
if self.executor.flow.designation == FlowDesignation.ENROLLMENT:
|
||||||
|
self.enroll_prepare_user(cert)
|
||||||
|
elif existing_user:
|
||||||
|
self.auth_user(existing_user, cert)
|
||||||
|
else:
|
||||||
|
return super().dispatch(
|
||||||
|
request, *args, error_message=_("No user found for certificate."), **kwargs
|
||||||
|
)
|
||||||
|
return self.executor.stage_ok()
|
||||||
|
|
||||||
|
def get_challenge(self, *args, error_message: str | None = None, **kwargs):
|
||||||
|
return AccessDeniedChallenge(
|
||||||
|
data={
|
||||||
|
"component": "ak-stage-access-denied",
|
||||||
|
"error_message": str(error_message or "Unknown error"),
|
||||||
|
}
|
||||||
|
)
|
0
authentik/enterprise/stages/mtls/tests/__init__.py
Normal file
0
authentik/enterprise/stages/mtls/tests/__init__.py
Normal file
31
authentik/enterprise/stages/mtls/tests/fixtures/ca.pem
vendored
Normal file
31
authentik/enterprise/stages/mtls/tests/fixtures/ca.pem
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFXDCCA0SgAwIBAgIUBmV7zREyC1SPr72/75/L9zpwV18wDQYJKoZIhvcNAQEL
|
||||||
|
BQAwRjEaMBgGA1UEAwwRYXV0aGVudGlrIFRlc3QgQ0ExEjAQBgNVBAoMCWF1dGhl
|
||||||
|
bnRpazEUMBIGA1UECwwLU2VsZi1zaWduZWQwHhcNMjUwNDI3MTgzMDUwWhcNMzUw
|
||||||
|
MzA3MTgzMDUwWjBGMRowGAYDVQQDDBFhdXRoZW50aWsgVGVzdCBDQTESMBAGA1UE
|
||||||
|
CgwJYXV0aGVudGlrMRQwEgYDVQQLDAtTZWxmLXNpZ25lZDCCAiIwDQYJKoZIhvcN
|
||||||
|
AQEBBQADggIPADCCAgoCggIBAMc0NxZj7j1mPu0aRToo8oMPdC3T99xgxnqdr18x
|
||||||
|
LV4pWyi/YLghgZHqNQY2xNP6JIlSeUZD6KFUYT2sPL4Av/zSg5zO8bl+/lf7ckje
|
||||||
|
O1/Bt5A8xtL0CpmpMDGiI6ibdDElaywM6AohisbxrV29pygSKGq2wugF/urqGtE+
|
||||||
|
5z4y5Kt6qMdKkd0iXT+WagbQTIUlykFKgB0+qqTLzDl01lVDa/DoLl8Hqp45mVx2
|
||||||
|
pqrGsSa3TCErLIv9hUlZklF7A8UV4ZB4JL20UKcP8dKzQClviNie17tpsUpOuy3A
|
||||||
|
SQ6+guWTHTLJNCSdLn1xIqc5q+f5wd2dIDf8zXCTHj+Xp0bJE3Vgaq5R31K9+b+1
|
||||||
|
2dDWz1KcNJaLEnw2+b0O8M64wTMLxhqOv7QfLUr6Pmg1ZymghjLcZ6bnU9e31Vza
|
||||||
|
hlPKhxjqYQUC4Kq+oaYF6qdUeJy+dsYf0iDv5tTC+eReZDWIjxTPrNpwA773ZwT7
|
||||||
|
WVmL7ULGpuP2g9rNvFBcZiN+i6d7CUoN+jd/iRdo79lrI0dfXiyy4bYgW/2HeZfF
|
||||||
|
HaOsc1xsoqnJdWbWkX/ooyaCjAfm07kS3HiOzz4q3QW4wgGrwV8lEraLPxYYeOQu
|
||||||
|
YcGMOM8NfnVkjc8gmyXUxedCje5Vz/Tu5fKrQEInnCmXxVsWbwr/LzEjMKAM/ivY
|
||||||
|
0TXxAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0G
|
||||||
|
A1UdDgQWBBTa+Ns6QzqlNvnTGszkouQQtZnVJDANBgkqhkiG9w0BAQsFAAOCAgEA
|
||||||
|
NpJEDMXjuEIzSzafkxSshvjnt5sMYmzmvjNoRlkxgN2YcWvPoxbalGAYzcpyggT2
|
||||||
|
6xZY8R4tvB1oNTCArqwf860kkofUoJCr88D/pU3Cv4JhjCWs4pmXTsvSqlBSlJbo
|
||||||
|
+jPBZwbn6it/6jcit6Be3rW2PtHe8tASd9Lf8/2r1ZvupXwPzcR84R4Z10ve2lqV
|
||||||
|
xxcWlMmBh51CaYI0b1/WTe9Ua+wgkCVkxbf9zNcDQXjxw2ICWK+nR/4ld4nmqVm2
|
||||||
|
C7nhvXwU8FAHl7ZgR2Z3PLrwPuhd+kd6NXQqNkS9A+n+1vSRLbRjmV8pwIPpdPEq
|
||||||
|
nslUAGJJBHDUBArxC3gOJSB+WtmaCfzDu2gepMf9Ng1H2ZhwSF/FH3v3fsJqZkzz
|
||||||
|
NBstT9KuNGQRYiCmAPJaoVAc9BoLa+BFML1govtWtpdmbFk8PZEcuUsP7iAZqFF1
|
||||||
|
uuldPyZ8huGpQSR6Oq2bILRHowfGY0npTZAyxg0Vs8UMy1HTwNOp9OuRtArMZmsJ
|
||||||
|
jFIx1QzRf9S1i6bYpOzOudoXj4ARkS1KmVExGjJFcIT0xlFSSERie2fEKSeEYOyG
|
||||||
|
G+PA2qRt/F51FGOMm1ZscjPXqk2kt3C4BFbz6Vvxsq7D3lmhvFLn4jVA8+OidsM0
|
||||||
|
YUrVMtWET/RkjEIbADbgRXxNUNo+jtQZDU9C1IiAdfk=
|
||||||
|
-----END CERTIFICATE-----
|
30
authentik/enterprise/stages/mtls/tests/fixtures/cert_client.pem
vendored
Normal file
30
authentik/enterprise/stages/mtls/tests/fixtures/cert_client.pem
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFOzCCAyOgAwIBAgIUbnIMy+Ewi5RvK7OBDxWMCk7wi08wDQYJKoZIhvcNAQEL
|
||||||
|
BQAwRjEaMBgGA1UEAwwRYXV0aGVudGlrIFRlc3QgQ0ExEjAQBgNVBAoMCWF1dGhl
|
||||||
|
bnRpazEUMBIGA1UECwwLU2VsZi1zaWduZWQwHhcNMjUwNDI3MTgzMTE3WhcNMjYw
|
||||||
|
NDIzMTgzMTE3WjARMQ8wDQYDVQQDDAZjbGllbnQwggIiMA0GCSqGSIb3DQEBAQUA
|
||||||
|
A4ICDwAwggIKAoICAQCdV+GEa7+7ito1i/z637OZW+0azv1kuF2aDwSzv+FJd+4L
|
||||||
|
6hCroRbVYTUFS3I3YwanOOZfau64xH0+pFM5Js8aREG68eqKBayx8vT27hyAOFhd
|
||||||
|
giEVmSQJfla4ogvPie1rJ0HVOL7CiR72HDPQvz+9k1iDX3xQ/4sdAb3XurN13e+M
|
||||||
|
Gtavhjiyqxmoo/H4WRd8BhD/BZQFWtaxWODDY8aKk5R7omw6Xf7aRv1BlHdE4Ucy
|
||||||
|
Wozvpsj2Kz0l61rRUhiMlE0D9dpijgaRYFB+M7R2casH3CdhGQbBHTRiqBkZa6iq
|
||||||
|
SDkTiTwNJQQJov8yPTsR+9P8OOuV6QN+DGm/FXJJFaPnsHw/HDy7EAbA1PcdbSyK
|
||||||
|
XvJ8nVjdNhCEGbLGVSwAQLO+78hChVIN5YH+QSrP84YBSxKZYArnf4z2e9drqAN3
|
||||||
|
KmC26TkaUzkXnndnxOXBEIOSmyCdD4Dutg1XPE/bs8rA6rVGIR3pKXbCr29Z8hZn
|
||||||
|
Cn9jbxwDwTX865ljR1Oc3dnIeCWa9AS/uHaSMdGlbGbDrt4Bj/nyyfu8xc034K/0
|
||||||
|
uPh3hF3FLWNAomRVZCvtuh/v7IEIQEgUbvQMWBhZJ8hu3HdtV8V9TIAryVKzEzGy
|
||||||
|
Q72UHuQyK0njRDTmA/T+jn7P8GWOuf9eNdzd0gH0gcEuhCZFxPPRvUAeDuC7DQID
|
||||||
|
AQABo1YwVDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwEwFAYDVR0RAQH/
|
||||||
|
BAowCIIGY2xpZW50MB0GA1UdDgQWBBQ5KZwTD8+4CqLnbM/cBSXg8XeLXTANBgkq
|
||||||
|
hkiG9w0BAQsFAAOCAgEABDkb3iyEOl1xKq1wxyRzf2L8qfPXAQw71FxMbgHArM+a
|
||||||
|
e44wJGO3mZgPH0trOaJ+tuN6erB5YbZfsoX+xFacwskj9pKyb4QJLr/ENmJZRgyL
|
||||||
|
wp5P6PB6IUJhvryvy/GxrG938YGmFtYQ+ikeJw5PWhB6218C1aZ9hsi94wZ1Zzrc
|
||||||
|
Ry0q0D4QvIEZ0X2HL1Harc7gerE3VqhgQ7EWyImM+lCRtNDduwDQnZauwhr2r6cW
|
||||||
|
XG4VTe1RCNsDA0xinXQE2Xf9voCd0Zf6wOOXJseQtrXpf+tG4N13cy5heF5ihed1
|
||||||
|
hDxSeki0KjTM+18kVVfVm4fzxf1Zg0gm54UlzWceIWh9EtnWMUV08H0D1M9YNmW8
|
||||||
|
hWTupk7M+jAw8Y+suHOe6/RLi0+fb9NSJpIpq4GqJ5UF2kerXHX0SvuAavoXyB0j
|
||||||
|
CQrUXkRScEKOO2KAbVExSG56Ff7Ee8cRUAQ6rLC5pQRACq/R0sa6RcUsFPXul3Yv
|
||||||
|
vbO2rTuArAUPkNVFknwkndheN4lOslRd1If02HunZETmsnal6p+nmuMWt2pQ2fDA
|
||||||
|
vIguG54FyQ1T1IbF/QhfTEY62CQAebcgutnqqJHt9qe7Jr6ev57hMrJDEjotSzkY
|
||||||
|
OhOVrcYqgLldr1nBqNVlIK/4VrDaWH8H5dNJ72gA9aMNVH4/bSTJhuO7cJkLnHw=
|
||||||
|
-----END CERTIFICATE-----
|
213
authentik/enterprise/stages/mtls/tests/test_stage.py
Normal file
213
authentik/enterprise/stages/mtls/tests/test_stage.py
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
|
from django.urls import reverse
|
||||||
|
from guardian.shortcuts import assign_perm
|
||||||
|
|
||||||
|
from authentik.core.models import User
|
||||||
|
from authentik.core.tests.utils import create_test_brand, create_test_flow, create_test_user
|
||||||
|
from authentik.crypto.models import CertificateKeyPair
|
||||||
|
from authentik.enterprise.stages.mtls.models import (
|
||||||
|
CertAttributes,
|
||||||
|
MutualTLSStage,
|
||||||
|
TLSMode,
|
||||||
|
UserAttributes,
|
||||||
|
)
|
||||||
|
from authentik.enterprise.stages.mtls.stage import PLAN_CONTEXT_CERTIFICATE
|
||||||
|
from authentik.flows.models import FlowDesignation, FlowStageBinding
|
||||||
|
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER
|
||||||
|
from authentik.flows.tests import FlowTestCase
|
||||||
|
from authentik.lib.generators import generate_id
|
||||||
|
from authentik.lib.tests.utils import load_fixture
|
||||||
|
from authentik.outposts.models import Outpost, OutpostType
|
||||||
|
from authentik.stages.prompt.stage import PLAN_CONTEXT_PROMPT
|
||||||
|
|
||||||
|
|
||||||
|
class MTLSStageTests(FlowTestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
self.flow = create_test_flow(FlowDesignation.AUTHENTICATION)
|
||||||
|
self.ca = CertificateKeyPair.objects.create(
|
||||||
|
name=generate_id(),
|
||||||
|
certificate_data=load_fixture("fixtures/ca.pem"),
|
||||||
|
)
|
||||||
|
self.stage = MutualTLSStage.objects.create(
|
||||||
|
name=generate_id(),
|
||||||
|
mode=TLSMode.REQUIRED,
|
||||||
|
cert_attribute=CertAttributes.COMMON_NAME,
|
||||||
|
user_attribute=UserAttributes.USERNAME,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.stage.certificate_authorities.add(self.ca)
|
||||||
|
self.binding = FlowStageBinding.objects.create(target=self.flow, stage=self.stage, order=0)
|
||||||
|
self.client_cert = load_fixture("fixtures/cert_client.pem")
|
||||||
|
# User matching the certificate
|
||||||
|
User.objects.filter(username="client").delete()
|
||||||
|
self.cert_user = create_test_user(username="client")
|
||||||
|
|
||||||
|
def test_parse_xfcc(self):
|
||||||
|
"""Test authentik Proxy/Envoy's XFCC format"""
|
||||||
|
with self.assertFlowFinishes() as plan:
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Forwarded-Client-Cert": f"Cert={quote_plus(self.client_cert)}"},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageRedirects(res, reverse("authentik_core:root-redirect"))
|
||||||
|
self.assertEqual(plan().context[PLAN_CONTEXT_PENDING_USER], self.cert_user)
|
||||||
|
|
||||||
|
def test_parse_nginx(self):
|
||||||
|
"""Test nginx's format"""
|
||||||
|
with self.assertFlowFinishes() as plan:
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"SSL-Client-Cert": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageRedirects(res, reverse("authentik_core:root-redirect"))
|
||||||
|
self.assertEqual(plan().context[PLAN_CONTEXT_PENDING_USER], self.cert_user)
|
||||||
|
|
||||||
|
def test_parse_traefik(self):
|
||||||
|
"""Test traefik's format"""
|
||||||
|
with self.assertFlowFinishes() as plan:
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Forwarded-TLS-Client-Cert": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageRedirects(res, reverse("authentik_core:root-redirect"))
|
||||||
|
self.assertEqual(plan().context[PLAN_CONTEXT_PENDING_USER], self.cert_user)
|
||||||
|
|
||||||
|
def test_parse_outpost_object(self):
|
||||||
|
"""Test outposts's format"""
|
||||||
|
outpost = Outpost.objects.create(name=generate_id(), type=OutpostType.PROXY)
|
||||||
|
assign_perm("pass_outpost_certificate", outpost.user, self.stage)
|
||||||
|
with patch(
|
||||||
|
"authentik.root.middleware.ClientIPMiddleware.get_outpost_user",
|
||||||
|
MagicMock(return_value=outpost.user),
|
||||||
|
):
|
||||||
|
with self.assertFlowFinishes() as plan:
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Authentik-Outpost-Certificate": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageRedirects(res, reverse("authentik_core:root-redirect"))
|
||||||
|
self.assertEqual(plan().context[PLAN_CONTEXT_PENDING_USER], self.cert_user)
|
||||||
|
|
||||||
|
def test_parse_outpost_global(self):
|
||||||
|
"""Test outposts's format"""
|
||||||
|
outpost = Outpost.objects.create(name=generate_id(), type=OutpostType.PROXY)
|
||||||
|
assign_perm("authentik_stages_mtls.pass_outpost_certificate", outpost.user)
|
||||||
|
with patch(
|
||||||
|
"authentik.root.middleware.ClientIPMiddleware.get_outpost_user",
|
||||||
|
MagicMock(return_value=outpost.user),
|
||||||
|
):
|
||||||
|
with self.assertFlowFinishes() as plan:
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Authentik-Outpost-Certificate": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageRedirects(res, reverse("authentik_core:root-redirect"))
|
||||||
|
self.assertEqual(plan().context[PLAN_CONTEXT_PENDING_USER], self.cert_user)
|
||||||
|
|
||||||
|
def test_parse_outpost_no_perm(self):
|
||||||
|
"""Test outposts's format"""
|
||||||
|
outpost = Outpost.objects.create(name=generate_id(), type=OutpostType.PROXY)
|
||||||
|
with patch(
|
||||||
|
"authentik.root.middleware.ClientIPMiddleware.get_outpost_user",
|
||||||
|
MagicMock(return_value=outpost.user),
|
||||||
|
):
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Authentik-Outpost-Certificate": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageResponse(res, self.flow, component="ak-stage-access-denied")
|
||||||
|
|
||||||
|
def test_auth_no_user(self):
|
||||||
|
"""Test auth with no user"""
|
||||||
|
User.objects.filter(username="client").delete()
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Forwarded-TLS-Client-Cert": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageResponse(res, self.flow, component="ak-stage-access-denied")
|
||||||
|
|
||||||
|
def test_brand_ca(self):
|
||||||
|
"""Test using a CA from the brand"""
|
||||||
|
self.stage.certificate_authorities.clear()
|
||||||
|
|
||||||
|
brand = create_test_brand()
|
||||||
|
brand.client_certificates.add(self.ca)
|
||||||
|
with self.assertFlowFinishes() as plan:
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Forwarded-TLS-Client-Cert": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageRedirects(res, reverse("authentik_core:root-redirect"))
|
||||||
|
self.assertEqual(plan().context[PLAN_CONTEXT_PENDING_USER], self.cert_user)
|
||||||
|
|
||||||
|
def test_no_ca_optional(self):
|
||||||
|
"""Test using no CA Set"""
|
||||||
|
self.stage.mode = TLSMode.OPTIONAL
|
||||||
|
self.stage.certificate_authorities.clear()
|
||||||
|
self.stage.save()
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Forwarded-TLS-Client-Cert": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageRedirects(res, reverse("authentik_core:root-redirect"))
|
||||||
|
|
||||||
|
def test_no_ca_required(self):
|
||||||
|
"""Test using no CA Set"""
|
||||||
|
self.stage.certificate_authorities.clear()
|
||||||
|
self.stage.save()
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Forwarded-TLS-Client-Cert": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageResponse(res, self.flow, component="ak-stage-access-denied")
|
||||||
|
|
||||||
|
def test_no_cert_optional(self):
|
||||||
|
"""Test using no cert Set"""
|
||||||
|
self.stage.mode = TLSMode.OPTIONAL
|
||||||
|
self.stage.save()
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageRedirects(res, reverse("authentik_core:root-redirect"))
|
||||||
|
|
||||||
|
def test_enroll(self):
|
||||||
|
"""Test Enrollment flow"""
|
||||||
|
self.flow.designation = FlowDesignation.ENROLLMENT
|
||||||
|
self.flow.save()
|
||||||
|
with self.assertFlowFinishes() as plan:
|
||||||
|
res = self.client.get(
|
||||||
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
|
||||||
|
headers={"X-Forwarded-TLS-Client-Cert": quote_plus(self.client_cert)},
|
||||||
|
)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertStageRedirects(res, reverse("authentik_core:root-redirect"))
|
||||||
|
self.assertEqual(plan().context[PLAN_CONTEXT_PROMPT], {"email": None, "name": "client"})
|
||||||
|
self.assertEqual(
|
||||||
|
plan().context[PLAN_CONTEXT_CERTIFICATE],
|
||||||
|
{
|
||||||
|
"fingerprint_sha1": (
|
||||||
|
"08:d4:a4:79:25:ca:c3:51:28:88:bb:30:c2:96:c3:44:5a:eb:18:07:84:ca:b4:75:27:74:61:19:8a:6a:af:fc"
|
||||||
|
),
|
||||||
|
"fingerprint_sha256": (
|
||||||
|
"08:d4:a4:79:25:ca:c3:51:28:88:bb:30:c2:96:c3:44:5a:eb:18:07:84:ca:b4:75:27:74:61:19:8a:6a:af:fc"
|
||||||
|
),
|
||||||
|
"issuer": "OU=Self-signed,O=authentik,CN=authentik Test CA",
|
||||||
|
"serial_number": "630532384467334865093173111400266136879266564943",
|
||||||
|
"subject": "CN=client",
|
||||||
|
},
|
||||||
|
)
|
5
authentik/enterprise/stages/mtls/urls.py
Normal file
5
authentik/enterprise/stages/mtls/urls.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
"""API URLs"""
|
||||||
|
|
||||||
|
from authentik.enterprise.stages.mtls.api import MutualTLSStageViewSet
|
||||||
|
|
||||||
|
api_urlpatterns = [("stages/mtls", MutualTLSStageViewSet)]
|
@ -7,7 +7,7 @@
|
|||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<link rel="prefetch" href="{{ flow_background_url }}" />
|
<link rel="prefetch" href="{{ flow_background_url }}" />
|
||||||
{% if flow.compatibility_mode and not inspector %}
|
{% if flow.compatibility_mode and not inspector %}
|
||||||
<script>ShadyDOM = { force: !navigator.webdriver };</script>
|
<script>ShadyDOM = { force: true };</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include "base/header_js.html" %}
|
{% include "base/header_js.html" %}
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
"""Test helpers"""
|
"""Test helpers"""
|
||||||
|
|
||||||
|
from collections.abc import Callable, Generator
|
||||||
|
from contextlib import contextmanager
|
||||||
from json import loads
|
from json import loads
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from django.http.response import HttpResponse
|
from django.http.response import HttpResponse
|
||||||
from django.urls.base import reverse
|
from django.urls.base import reverse
|
||||||
@ -9,6 +12,8 @@ from rest_framework.test import APITestCase
|
|||||||
|
|
||||||
from authentik.core.models import User
|
from authentik.core.models import User
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
|
from authentik.flows.planner import FlowPlan
|
||||||
|
from authentik.flows.views.executor import SESSION_KEY_PLAN
|
||||||
|
|
||||||
|
|
||||||
class FlowTestCase(APITestCase):
|
class FlowTestCase(APITestCase):
|
||||||
@ -44,3 +49,12 @@ class FlowTestCase(APITestCase):
|
|||||||
def assertStageRedirects(self, response: HttpResponse, to: str) -> dict[str, Any]:
|
def assertStageRedirects(self, response: HttpResponse, to: str) -> dict[str, Any]:
|
||||||
"""Wrapper around assertStageResponse that checks for a redirect"""
|
"""Wrapper around assertStageResponse that checks for a redirect"""
|
||||||
return self.assertStageResponse(response, component="xak-flow-redirect", to=to)
|
return self.assertStageResponse(response, component="xak-flow-redirect", to=to)
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def assertFlowFinishes(self) -> Generator[Callable[[], FlowPlan]]:
|
||||||
|
"""Capture the flow plan before the flow finishes and return it"""
|
||||||
|
try:
|
||||||
|
with patch("authentik.flows.views.executor.FlowExecutorView.cancel", MagicMock()):
|
||||||
|
yield lambda: self.client.session.get(SESSION_KEY_PLAN)
|
||||||
|
finally:
|
||||||
|
pass
|
||||||
|
@ -23,7 +23,6 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class Direction(StrEnum):
|
class Direction(StrEnum):
|
||||||
|
|
||||||
add = "add"
|
add = "add"
|
||||||
remove = "remove"
|
remove = "remove"
|
||||||
|
|
||||||
@ -37,13 +36,16 @@ SAFE_METHODS = [
|
|||||||
|
|
||||||
|
|
||||||
class BaseOutgoingSyncClient[
|
class BaseOutgoingSyncClient[
|
||||||
TModel: "Model", TConnection: "Model", TSchema: dict, TProvider: "OutgoingSyncProvider"
|
TModel: "Model",
|
||||||
|
TConnection: "Model",
|
||||||
|
TSchema: dict,
|
||||||
|
TProvider: "OutgoingSyncProvider",
|
||||||
]:
|
]:
|
||||||
"""Basic Outgoing sync client Client"""
|
"""Basic Outgoing sync client Client"""
|
||||||
|
|
||||||
provider: TProvider
|
provider: TProvider
|
||||||
connection_type: type[TConnection]
|
connection_type: type[TConnection]
|
||||||
connection_type_query: str
|
connection_attr: str
|
||||||
mapper: PropertyMappingManager
|
mapper: PropertyMappingManager
|
||||||
|
|
||||||
can_discover = False
|
can_discover = False
|
||||||
@ -63,9 +65,7 @@ class BaseOutgoingSyncClient[
|
|||||||
def write(self, obj: TModel) -> tuple[TConnection, bool]:
|
def write(self, obj: TModel) -> tuple[TConnection, bool]:
|
||||||
"""Write object to destination. Uses self.create and self.update, but
|
"""Write object to destination. Uses self.create and self.update, but
|
||||||
can be overwritten for further logic"""
|
can be overwritten for further logic"""
|
||||||
connection = self.connection_type.objects.filter(
|
connection = getattr(obj, self.connection_attr).filter(provider=self.provider).first()
|
||||||
provider=self.provider, **{self.connection_type_query: obj}
|
|
||||||
).first()
|
|
||||||
try:
|
try:
|
||||||
if not connection:
|
if not connection:
|
||||||
connection = self.create(obj)
|
connection = self.create(obj)
|
||||||
|
@ -34,7 +34,7 @@ class SCIMGroupClient(SCIMClient[Group, SCIMProviderGroup, SCIMGroupSchema]):
|
|||||||
"""SCIM client for groups"""
|
"""SCIM client for groups"""
|
||||||
|
|
||||||
connection_type = SCIMProviderGroup
|
connection_type = SCIMProviderGroup
|
||||||
connection_type_query = "group"
|
connection_attr = "scimprovidergroup_set"
|
||||||
mapper: PropertyMappingManager
|
mapper: PropertyMappingManager
|
||||||
|
|
||||||
def __init__(self, provider: SCIMProvider):
|
def __init__(self, provider: SCIMProvider):
|
||||||
|
@ -18,7 +18,7 @@ class SCIMUserClient(SCIMClient[User, SCIMProviderUser, SCIMUserSchema]):
|
|||||||
"""SCIM client for users"""
|
"""SCIM client for users"""
|
||||||
|
|
||||||
connection_type = SCIMProviderUser
|
connection_type = SCIMProviderUser
|
||||||
connection_type_query = "user"
|
connection_attr = "scimprovideruser_set"
|
||||||
mapper: PropertyMappingManager
|
mapper: PropertyMappingManager
|
||||||
|
|
||||||
def __init__(self, provider: SCIMProvider):
|
def __init__(self, provider: SCIMProvider):
|
||||||
|
@ -116,7 +116,7 @@ class SCIMProvider(OutgoingSyncProvider, BackchannelProvider):
|
|||||||
if type == User:
|
if type == User:
|
||||||
# Get queryset of all users with consistent ordering
|
# Get queryset of all users with consistent ordering
|
||||||
# according to the provider's settings
|
# according to the provider's settings
|
||||||
base = User.objects.all().exclude_anonymous()
|
base = User.objects.prefetch_related("scimprovideruser_set").all().exclude_anonymous()
|
||||||
if self.exclude_users_service_account:
|
if self.exclude_users_service_account:
|
||||||
base = base.exclude(type=UserTypes.SERVICE_ACCOUNT).exclude(
|
base = base.exclude(type=UserTypes.SERVICE_ACCOUNT).exclude(
|
||||||
type=UserTypes.INTERNAL_SERVICE_ACCOUNT
|
type=UserTypes.INTERNAL_SERVICE_ACCOUNT
|
||||||
@ -126,7 +126,7 @@ class SCIMProvider(OutgoingSyncProvider, BackchannelProvider):
|
|||||||
return base.order_by("pk")
|
return base.order_by("pk")
|
||||||
if type == Group:
|
if type == Group:
|
||||||
# Get queryset of all groups with consistent ordering
|
# Get queryset of all groups with consistent ordering
|
||||||
return Group.objects.all().order_by("pk")
|
return Group.objects.prefetch_related("scimprovidergroup_set").all().order_by("pk")
|
||||||
raise ValueError(f"Invalid type {type}")
|
raise ValueError(f"Invalid type {type}")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -317,7 +317,7 @@ class KerberosSource(Source):
|
|||||||
usage="accept", name=name, store=self.get_gssapi_store()
|
usage="accept", name=name, store=self.get_gssapi_store()
|
||||||
)
|
)
|
||||||
except gssapi.exceptions.GSSError as exc:
|
except gssapi.exceptions.GSSError as exc:
|
||||||
LOGGER.warn("GSSAPI credentials failure", exc=exc)
|
LOGGER.warning("GSSAPI credentials failure", exc=exc)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
|||||||
"$schema": "http://json-schema.org/draft-07/schema",
|
"$schema": "http://json-schema.org/draft-07/schema",
|
||||||
"$id": "https://goauthentik.io/blueprints/schema.json",
|
"$id": "https://goauthentik.io/blueprints/schema.json",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "authentik 2025.4.0 Blueprint schema",
|
"title": "authentik 2025.4.1 Blueprint schema",
|
||||||
"required": [
|
"required": [
|
||||||
"version",
|
"version",
|
||||||
"entries"
|
"entries"
|
||||||
@ -3921,6 +3921,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"model",
|
||||||
|
"identifiers"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"model": {
|
||||||
|
"const": "authentik_stages_mtls.mutualtlsstage"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"absent",
|
||||||
|
"present",
|
||||||
|
"created",
|
||||||
|
"must_created"
|
||||||
|
],
|
||||||
|
"default": "present"
|
||||||
|
},
|
||||||
|
"conditions": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"permissions": {
|
||||||
|
"$ref": "#/$defs/model_authentik_stages_mtls.mutualtlsstage_permissions"
|
||||||
|
},
|
||||||
|
"attrs": {
|
||||||
|
"$ref": "#/$defs/model_authentik_stages_mtls.mutualtlsstage"
|
||||||
|
},
|
||||||
|
"identifiers": {
|
||||||
|
"$ref": "#/$defs/model_authentik_stages_mtls.mutualtlsstage"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -4867,6 +4907,7 @@
|
|||||||
"authentik.enterprise.providers.microsoft_entra",
|
"authentik.enterprise.providers.microsoft_entra",
|
||||||
"authentik.enterprise.providers.ssf",
|
"authentik.enterprise.providers.ssf",
|
||||||
"authentik.enterprise.stages.authenticator_endpoint_gdtc",
|
"authentik.enterprise.stages.authenticator_endpoint_gdtc",
|
||||||
|
"authentik.enterprise.stages.mtls",
|
||||||
"authentik.enterprise.stages.source",
|
"authentik.enterprise.stages.source",
|
||||||
"authentik.events"
|
"authentik.events"
|
||||||
],
|
],
|
||||||
@ -4977,6 +5018,7 @@
|
|||||||
"authentik_providers_microsoft_entra.microsoftentraprovidermapping",
|
"authentik_providers_microsoft_entra.microsoftentraprovidermapping",
|
||||||
"authentik_providers_ssf.ssfprovider",
|
"authentik_providers_ssf.ssfprovider",
|
||||||
"authentik_stages_authenticator_endpoint_gdtc.authenticatorendpointgdtcstage",
|
"authentik_stages_authenticator_endpoint_gdtc.authenticatorendpointgdtcstage",
|
||||||
|
"authentik_stages_mtls.mutualtlsstage",
|
||||||
"authentik_stages_source.sourcestage",
|
"authentik_stages_source.sourcestage",
|
||||||
"authentik_events.event",
|
"authentik_events.event",
|
||||||
"authentik_events.notificationtransport",
|
"authentik_events.notificationtransport",
|
||||||
@ -7477,6 +7519,11 @@
|
|||||||
"authentik_stages_invitation.delete_invitationstage",
|
"authentik_stages_invitation.delete_invitationstage",
|
||||||
"authentik_stages_invitation.view_invitation",
|
"authentik_stages_invitation.view_invitation",
|
||||||
"authentik_stages_invitation.view_invitationstage",
|
"authentik_stages_invitation.view_invitationstage",
|
||||||
|
"authentik_stages_mtls.add_mutualtlsstage",
|
||||||
|
"authentik_stages_mtls.change_mutualtlsstage",
|
||||||
|
"authentik_stages_mtls.delete_mutualtlsstage",
|
||||||
|
"authentik_stages_mtls.pass_outpost_certificate",
|
||||||
|
"authentik_stages_mtls.view_mutualtlsstage",
|
||||||
"authentik_stages_password.add_passwordstage",
|
"authentik_stages_password.add_passwordstage",
|
||||||
"authentik_stages_password.change_passwordstage",
|
"authentik_stages_password.change_passwordstage",
|
||||||
"authentik_stages_password.delete_passwordstage",
|
"authentik_stages_password.delete_passwordstage",
|
||||||
@ -13422,6 +13469,16 @@
|
|||||||
"title": "Web certificate",
|
"title": "Web certificate",
|
||||||
"description": "Web Certificate used by the authentik Core webserver."
|
"description": "Web Certificate used by the authentik Core webserver."
|
||||||
},
|
},
|
||||||
|
"client_certificates": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uuid",
|
||||||
|
"description": "Certificates used for client authentication."
|
||||||
|
},
|
||||||
|
"title": "Client certificates",
|
||||||
|
"description": "Certificates used for client authentication."
|
||||||
|
},
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": true,
|
"additionalProperties": true,
|
||||||
@ -14185,6 +14242,11 @@
|
|||||||
"authentik_stages_invitation.delete_invitationstage",
|
"authentik_stages_invitation.delete_invitationstage",
|
||||||
"authentik_stages_invitation.view_invitation",
|
"authentik_stages_invitation.view_invitation",
|
||||||
"authentik_stages_invitation.view_invitationstage",
|
"authentik_stages_invitation.view_invitationstage",
|
||||||
|
"authentik_stages_mtls.add_mutualtlsstage",
|
||||||
|
"authentik_stages_mtls.change_mutualtlsstage",
|
||||||
|
"authentik_stages_mtls.delete_mutualtlsstage",
|
||||||
|
"authentik_stages_mtls.pass_outpost_certificate",
|
||||||
|
"authentik_stages_mtls.view_mutualtlsstage",
|
||||||
"authentik_stages_password.add_passwordstage",
|
"authentik_stages_password.add_passwordstage",
|
||||||
"authentik_stages_password.change_passwordstage",
|
"authentik_stages_password.change_passwordstage",
|
||||||
"authentik_stages_password.delete_passwordstage",
|
"authentik_stages_password.delete_passwordstage",
|
||||||
@ -15088,6 +15150,161 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"model_authentik_stages_mtls.mutualtlsstage": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1,
|
||||||
|
"title": "Name"
|
||||||
|
},
|
||||||
|
"flow_set": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1,
|
||||||
|
"title": "Name"
|
||||||
|
},
|
||||||
|
"slug": {
|
||||||
|
"type": "string",
|
||||||
|
"maxLength": 50,
|
||||||
|
"minLength": 1,
|
||||||
|
"pattern": "^[-a-zA-Z0-9_]+$",
|
||||||
|
"title": "Slug",
|
||||||
|
"description": "Visible in the URL."
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1,
|
||||||
|
"title": "Title",
|
||||||
|
"description": "Shown as the Title in Flow pages."
|
||||||
|
},
|
||||||
|
"designation": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"authentication",
|
||||||
|
"authorization",
|
||||||
|
"invalidation",
|
||||||
|
"enrollment",
|
||||||
|
"unenrollment",
|
||||||
|
"recovery",
|
||||||
|
"stage_configuration"
|
||||||
|
],
|
||||||
|
"title": "Designation",
|
||||||
|
"description": "Decides what this Flow is used for. For example, the Authentication flow is redirect to when an un-authenticated user visits authentik."
|
||||||
|
},
|
||||||
|
"policy_engine_mode": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"all",
|
||||||
|
"any"
|
||||||
|
],
|
||||||
|
"title": "Policy engine mode"
|
||||||
|
},
|
||||||
|
"compatibility_mode": {
|
||||||
|
"type": "boolean",
|
||||||
|
"title": "Compatibility mode",
|
||||||
|
"description": "Enable compatibility mode, increases compatibility with password managers on mobile devices."
|
||||||
|
},
|
||||||
|
"layout": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"stacked",
|
||||||
|
"content_left",
|
||||||
|
"content_right",
|
||||||
|
"sidebar_left",
|
||||||
|
"sidebar_right"
|
||||||
|
],
|
||||||
|
"title": "Layout"
|
||||||
|
},
|
||||||
|
"denied_action": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"message_continue",
|
||||||
|
"message",
|
||||||
|
"continue"
|
||||||
|
],
|
||||||
|
"title": "Denied action",
|
||||||
|
"description": "Configure what should happen when a flow denies access to a user."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"slug",
|
||||||
|
"title",
|
||||||
|
"designation"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": "Flow set"
|
||||||
|
},
|
||||||
|
"mode": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"optional",
|
||||||
|
"required"
|
||||||
|
],
|
||||||
|
"title": "Mode"
|
||||||
|
},
|
||||||
|
"certificate_authorities": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uuid",
|
||||||
|
"description": "Configure certificate authorities to validate the certificate against. This option has a higher priority than the `client_certificate` option on `Brand`."
|
||||||
|
},
|
||||||
|
"title": "Certificate authorities",
|
||||||
|
"description": "Configure certificate authorities to validate the certificate against. This option has a higher priority than the `client_certificate` option on `Brand`."
|
||||||
|
},
|
||||||
|
"cert_attribute": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"subject",
|
||||||
|
"common_name",
|
||||||
|
"email"
|
||||||
|
],
|
||||||
|
"title": "Cert attribute"
|
||||||
|
},
|
||||||
|
"user_attribute": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"username",
|
||||||
|
"email"
|
||||||
|
],
|
||||||
|
"title": "User attribute"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": []
|
||||||
|
},
|
||||||
|
"model_authentik_stages_mtls.mutualtlsstage_permissions": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"permission"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"permission": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"pass_outpost_certificate",
|
||||||
|
"add_mutualtlsstage",
|
||||||
|
"change_mutualtlsstage",
|
||||||
|
"delete_mutualtlsstage",
|
||||||
|
"view_mutualtlsstage"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"role": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"model_authentik_stages_source.sourcestage": {
|
"model_authentik_stages_source.sourcestage": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -19,7 +19,6 @@ import (
|
|||||||
sentryutils "goauthentik.io/internal/utils/sentry"
|
sentryutils "goauthentik.io/internal/utils/sentry"
|
||||||
webutils "goauthentik.io/internal/utils/web"
|
webutils "goauthentik.io/internal/utils/web"
|
||||||
"goauthentik.io/internal/web"
|
"goauthentik.io/internal/web"
|
||||||
"goauthentik.io/internal/web/brand_tls"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
@ -67,12 +66,12 @@ var rootCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
ws := web.NewWebServer()
|
ws := web.NewWebServer()
|
||||||
ws.Core().HealthyCallback = func() {
|
ws.Core().AddHealthyCallback(func() {
|
||||||
if config.Get().Outposts.DisableEmbeddedOutpost {
|
if config.Get().Outposts.DisableEmbeddedOutpost {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go attemptProxyStart(ws, u)
|
go attemptProxyStart(ws, u)
|
||||||
}
|
})
|
||||||
ws.Start()
|
ws.Start()
|
||||||
<-ex
|
<-ex
|
||||||
l.Info("shutting down webserver")
|
l.Info("shutting down webserver")
|
||||||
@ -95,13 +94,8 @@ func attemptProxyStart(ws *web.WebServer, u *url.URL) {
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Init brand_tls here too since it requires an API Client,
|
|
||||||
// so we just reuse the same one as the outpost uses
|
|
||||||
tw := brand_tls.NewWatcher(ac.Client)
|
|
||||||
go tw.Start()
|
|
||||||
ws.BrandTLS = tw
|
|
||||||
ac.AddRefreshHandler(func() {
|
ac.AddRefreshHandler(func() {
|
||||||
tw.Check()
|
ws.BrandTLS.Check()
|
||||||
})
|
})
|
||||||
|
|
||||||
srv := proxyv2.NewProxyServer(ac)
|
srv := proxyv2.NewProxyServer(ac)
|
||||||
|
@ -31,7 +31,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- redis:/data
|
- redis:/data
|
||||||
server:
|
server:
|
||||||
image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2025.4.0}
|
image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2025.4.1}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: server
|
command: server
|
||||||
environment:
|
environment:
|
||||||
@ -55,7 +55,7 @@ services:
|
|||||||
redis:
|
redis:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
worker:
|
worker:
|
||||||
image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2025.4.0}
|
image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2025.4.1}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: worker
|
command: worker
|
||||||
environment:
|
environment:
|
||||||
|
4
go.mod
4
go.mod
@ -5,7 +5,7 @@ go 1.24.0
|
|||||||
require (
|
require (
|
||||||
beryju.io/ldap v0.1.0
|
beryju.io/ldap v0.1.0
|
||||||
github.com/coreos/go-oidc/v3 v3.14.1
|
github.com/coreos/go-oidc/v3 v3.14.1
|
||||||
github.com/getsentry/sentry-go v0.32.0
|
github.com/getsentry/sentry-go v0.33.0
|
||||||
github.com/go-http-utils/etag v0.0.0-20161124023236-513ea8f21eb1
|
github.com/go-http-utils/etag v0.0.0-20161124023236-513ea8f21eb1
|
||||||
github.com/go-ldap/ldap/v3 v3.4.11
|
github.com/go-ldap/ldap/v3 v3.4.11
|
||||||
github.com/go-openapi/runtime v0.28.0
|
github.com/go-openapi/runtime v0.28.0
|
||||||
@ -27,7 +27,7 @@ require (
|
|||||||
github.com/spf13/cobra v1.9.1
|
github.com/spf13/cobra v1.9.1
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/stretchr/testify v1.10.0
|
||||||
github.com/wwt/guac v1.3.2
|
github.com/wwt/guac v1.3.2
|
||||||
goauthentik.io/api/v3 v3.2025040.1
|
goauthentik.io/api/v3 v3.2025041.2
|
||||||
golang.org/x/exp v0.0.0-20230210204819-062eb4c674ab
|
golang.org/x/exp v0.0.0-20230210204819-062eb4c674ab
|
||||||
golang.org/x/oauth2 v0.30.0
|
golang.org/x/oauth2 v0.30.0
|
||||||
golang.org/x/sync v0.14.0
|
golang.org/x/sync v0.14.0
|
||||||
|
8
go.sum
8
go.sum
@ -69,8 +69,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
|
|||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
|
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
|
||||||
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
github.com/getsentry/sentry-go v0.32.0 h1:YKs+//QmwE3DcYtfKRH8/KyOOF/I6Qnx7qYGNHCGmCY=
|
github.com/getsentry/sentry-go v0.33.0 h1:YWyDii0KGVov3xOaamOnF0mjOrqSjBqwv48UEzn7QFg=
|
||||||
github.com/getsentry/sentry-go v0.32.0/go.mod h1:CYNcMMz73YigoHljQRG+qPF+eMq8gG72XcGN/p71BAY=
|
github.com/getsentry/sentry-go v0.33.0/go.mod h1:C55omcY9ChRQIUcVcGcs+Zdy4ZpQGvNJ7JYHIoSWOtE=
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 h1:BP4M0CvQ4S3TGls2FvczZtj5Re/2ZzkV9VwqPHH/3Bo=
|
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 h1:BP4M0CvQ4S3TGls2FvczZtj5Re/2ZzkV9VwqPHH/3Bo=
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||||
@ -290,8 +290,8 @@ go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y
|
|||||||
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
|
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
goauthentik.io/api/v3 v3.2025040.1 h1:rQEcMNpz84/LPX8LVFteOJuserrd4PnU4k1Iu/wWqhs=
|
goauthentik.io/api/v3 v3.2025041.2 h1:vFYYnhcDcxL95RczZwhzt3i4LptFXMvIRN+vgf8sQYg=
|
||||||
goauthentik.io/api/v3 v3.2025040.1/go.mod h1:zz+mEZg8rY/7eEjkMGWJ2DnGqk+zqxuybGCGrR2O4Kw=
|
goauthentik.io/api/v3 v3.2025041.2/go.mod h1:zz+mEZg8rY/7eEjkMGWJ2DnGqk+zqxuybGCGrR2O4Kw=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
@ -21,12 +21,16 @@ func FullVersion() string {
|
|||||||
return ver
|
return ver
|
||||||
}
|
}
|
||||||
|
|
||||||
func OutpostUserAgent() string {
|
func UserAgentOutpost() string {
|
||||||
return fmt.Sprintf("goauthentik.io/outpost/%s", FullVersion())
|
return fmt.Sprintf("goauthentik.io/outpost/%s", FullVersion())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UserAgentIPC() string {
|
||||||
|
return fmt.Sprintf("goauthentik.io/ipc/%s", FullVersion())
|
||||||
|
}
|
||||||
|
|
||||||
func UserAgent() string {
|
func UserAgent() string {
|
||||||
return fmt.Sprintf("authentik@%s", FullVersion())
|
return fmt.Sprintf("authentik@%s", FullVersion())
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION = "2025.4.0"
|
const VERSION = "2025.4.1"
|
||||||
|
@ -18,8 +18,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type GoUnicorn struct {
|
type GoUnicorn struct {
|
||||||
Healthcheck func() bool
|
Healthcheck func() bool
|
||||||
HealthyCallback func()
|
healthyCallbacks []func()
|
||||||
|
|
||||||
log *log.Entry
|
log *log.Entry
|
||||||
p *exec.Cmd
|
p *exec.Cmd
|
||||||
@ -32,12 +32,12 @@ type GoUnicorn struct {
|
|||||||
func New(healthcheck func() bool) *GoUnicorn {
|
func New(healthcheck func() bool) *GoUnicorn {
|
||||||
logger := log.WithField("logger", "authentik.router.unicorn")
|
logger := log.WithField("logger", "authentik.router.unicorn")
|
||||||
g := &GoUnicorn{
|
g := &GoUnicorn{
|
||||||
Healthcheck: healthcheck,
|
Healthcheck: healthcheck,
|
||||||
log: logger,
|
log: logger,
|
||||||
started: false,
|
started: false,
|
||||||
killed: false,
|
killed: false,
|
||||||
alive: false,
|
alive: false,
|
||||||
HealthyCallback: func() {},
|
healthyCallbacks: []func(){},
|
||||||
}
|
}
|
||||||
g.initCmd()
|
g.initCmd()
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
@ -79,6 +79,10 @@ func (g *GoUnicorn) initCmd() {
|
|||||||
g.p.Stderr = os.Stderr
|
g.p.Stderr = os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GoUnicorn) AddHealthyCallback(cb func()) {
|
||||||
|
g.healthyCallbacks = append(g.healthyCallbacks, cb)
|
||||||
|
}
|
||||||
|
|
||||||
func (g *GoUnicorn) IsRunning() bool {
|
func (g *GoUnicorn) IsRunning() bool {
|
||||||
return g.alive
|
return g.alive
|
||||||
}
|
}
|
||||||
@ -101,7 +105,9 @@ func (g *GoUnicorn) healthcheck() {
|
|||||||
if g.Healthcheck() {
|
if g.Healthcheck() {
|
||||||
g.alive = true
|
g.alive = true
|
||||||
g.log.Debug("backend is alive, backing off with healthchecks")
|
g.log.Debug("backend is alive, backing off with healthchecks")
|
||||||
g.HealthyCallback()
|
for _, cb := range g.healthyCallbacks {
|
||||||
|
cb()
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
g.log.Debug("backend not alive yet")
|
g.log.Debug("backend not alive yet")
|
||||||
|
@ -62,7 +62,7 @@ func NewAPIController(akURL url.URL, token string) *APIController {
|
|||||||
apiConfig.Scheme = akURL.Scheme
|
apiConfig.Scheme = akURL.Scheme
|
||||||
apiConfig.HTTPClient = &http.Client{
|
apiConfig.HTTPClient = &http.Client{
|
||||||
Transport: web.NewUserAgentTransport(
|
Transport: web.NewUserAgentTransport(
|
||||||
constants.OutpostUserAgent(),
|
constants.UserAgentOutpost(),
|
||||||
web.NewTracingTransport(
|
web.NewTracingTransport(
|
||||||
rsp.Context(),
|
rsp.Context(),
|
||||||
GetTLSTransport(),
|
GetTLSTransport(),
|
||||||
|
@ -38,7 +38,7 @@ func (ac *APIController) initWS(akURL url.URL, outpostUUID string) error {
|
|||||||
|
|
||||||
header := http.Header{
|
header := http.Header{
|
||||||
"Authorization": []string{authHeader},
|
"Authorization": []string{authHeader},
|
||||||
"User-Agent": []string{constants.OutpostUserAgent()},
|
"User-Agent": []string{constants.UserAgentOutpost()},
|
||||||
}
|
}
|
||||||
|
|
||||||
dialer := websocket.Dialer{
|
dialer := websocket.Dialer{
|
||||||
|
@ -3,6 +3,8 @@ package ak
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"crypto/x509"
|
||||||
|
"encoding/pem"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"goauthentik.io/api/v3"
|
"goauthentik.io/api/v3"
|
||||||
@ -67,16 +69,34 @@ func (cs *CryptoStore) Fetch(uuid string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
x509cert, err := tls.X509KeyPair([]byte(cert.Data), []byte(key.Data))
|
var tcert tls.Certificate
|
||||||
if err != nil {
|
if key.Data != "" {
|
||||||
return err
|
x509cert, err := tls.X509KeyPair([]byte(cert.Data), []byte(key.Data))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tcert = x509cert
|
||||||
|
} else {
|
||||||
|
p, _ := pem.Decode([]byte(cert.Data))
|
||||||
|
x509cert, err := x509.ParseCertificate(p.Bytes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tcert = tls.Certificate{
|
||||||
|
Certificate: [][]byte{x509cert.Raw},
|
||||||
|
Leaf: x509cert,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cs.certificates[uuid] = &x509cert
|
cs.certificates[uuid] = &tcert
|
||||||
cs.fingerprints[uuid] = cfp
|
cs.fingerprints[uuid] = cfp
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *CryptoStore) Get(uuid string) *tls.Certificate {
|
func (cs *CryptoStore) Get(uuid string) *tls.Certificate {
|
||||||
|
c, ok := cs.certificates[uuid]
|
||||||
|
if ok {
|
||||||
|
return c
|
||||||
|
}
|
||||||
err := cs.Fetch(uuid)
|
err := cs.Fetch(uuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cs.log.WithError(err).Warning("failed to fetch certificate")
|
cs.log.WithError(err).Warning("failed to fetch certificate")
|
||||||
|
@ -55,7 +55,7 @@ func doGlobalSetup(outpost api.Outpost, globalConfig *api.Config) {
|
|||||||
EnableTracing: true,
|
EnableTracing: true,
|
||||||
TracesSampler: sentryutils.SamplerFunc(float64(globalConfig.ErrorReporting.TracesSampleRate)),
|
TracesSampler: sentryutils.SamplerFunc(float64(globalConfig.ErrorReporting.TracesSampleRate)),
|
||||||
Release: fmt.Sprintf("authentik@%s", constants.VERSION),
|
Release: fmt.Sprintf("authentik@%s", constants.VERSION),
|
||||||
HTTPTransport: webutils.NewUserAgentTransport(constants.OutpostUserAgent(), http.DefaultTransport),
|
HTTPTransport: webutils.NewUserAgentTransport(constants.UserAgentOutpost(), http.DefaultTransport),
|
||||||
IgnoreErrors: []string{
|
IgnoreErrors: []string{
|
||||||
http.ErrAbortHandler.Error(),
|
http.ErrAbortHandler.Error(),
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,7 @@ func NewFlowExecutor(ctx context.Context, flowSlug string, refConfig *api.Config
|
|||||||
l.WithError(err).Warning("Failed to create cookiejar")
|
l.WithError(err).Warning("Failed to create cookiejar")
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
transport := web.NewUserAgentTransport(constants.OutpostUserAgent(), web.NewTracingTransport(rsp.Context(), ak.GetTLSTransport()))
|
transport := web.NewUserAgentTransport(constants.UserAgentOutpost(), web.NewTracingTransport(rsp.Context(), ak.GetTLSTransport()))
|
||||||
fe := &FlowExecutor{
|
fe := &FlowExecutor{
|
||||||
Params: url.Values{},
|
Params: url.Values{},
|
||||||
Answers: make(map[StageComponent]string),
|
Answers: make(map[StageComponent]string),
|
||||||
|
@ -52,7 +52,7 @@ func (a *Application) addHeaders(headers http.Header, c *Claims) {
|
|||||||
headers.Set("X-authentik-meta-outpost", a.outpostName)
|
headers.Set("X-authentik-meta-outpost", a.outpostName)
|
||||||
headers.Set("X-authentik-meta-provider", a.proxyConfig.Name)
|
headers.Set("X-authentik-meta-provider", a.proxyConfig.Name)
|
||||||
headers.Set("X-authentik-meta-app", a.proxyConfig.AssignedApplicationSlug)
|
headers.Set("X-authentik-meta-app", a.proxyConfig.AssignedApplicationSlug)
|
||||||
headers.Set("X-authentik-meta-version", constants.OutpostUserAgent())
|
headers.Set("X-authentik-meta-version", constants.UserAgentOutpost())
|
||||||
|
|
||||||
if c.Proxy == nil {
|
if c.Proxy == nil {
|
||||||
return
|
return
|
||||||
|
@ -31,7 +31,7 @@ func (ps *ProxyServer) Refresh() error {
|
|||||||
ua := fmt.Sprintf(" (provider=%s)", provider.Name)
|
ua := fmt.Sprintf(" (provider=%s)", provider.Name)
|
||||||
hc := &http.Client{
|
hc := &http.Client{
|
||||||
Transport: web.NewUserAgentTransport(
|
Transport: web.NewUserAgentTransport(
|
||||||
constants.OutpostUserAgent()+ua,
|
constants.UserAgentOutpost()+ua,
|
||||||
web.NewTracingTransport(
|
web.NewTracingTransport(
|
||||||
rsp.Context(),
|
rsp.Context(),
|
||||||
ak.GetTLSTransport(),
|
ak.GetTLSTransport(),
|
||||||
|
@ -61,7 +61,7 @@ func (c *Connection) initSocket(forChannel string) error {
|
|||||||
|
|
||||||
header := http.Header{
|
header := http.Header{
|
||||||
"Authorization": []string{authHeader},
|
"Authorization": []string{authHeader},
|
||||||
"User-Agent": []string{constants.OutpostUserAgent()},
|
"User-Agent": []string{constants.UserAgentOutpost()},
|
||||||
}
|
}
|
||||||
|
|
||||||
dialer := websocket.Dialer{
|
dialer := websocket.Dialer{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -9,6 +10,14 @@ import (
|
|||||||
"goauthentik.io/internal/config"
|
"goauthentik.io/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type allowedProxyRequestContext string
|
||||||
|
|
||||||
|
const allowedProxyRequest allowedProxyRequestContext = ""
|
||||||
|
|
||||||
|
func IsRequestFromTrustedProxy(r *http.Request) bool {
|
||||||
|
return r.Context().Value(allowedProxyRequest) != nil
|
||||||
|
}
|
||||||
|
|
||||||
// ProxyHeaders Set proxy headers like X-Forwarded-For and such, but only if the direct connection
|
// ProxyHeaders Set proxy headers like X-Forwarded-For and such, but only if the direct connection
|
||||||
// comes from a client that's in a list of trusted CIDRs
|
// comes from a client that's in a list of trusted CIDRs
|
||||||
func ProxyHeaders() func(http.Handler) http.Handler {
|
func ProxyHeaders() func(http.Handler) http.Handler {
|
||||||
@ -20,7 +29,6 @@ func ProxyHeaders() func(http.Handler) http.Handler {
|
|||||||
}
|
}
|
||||||
nets = append(nets, cidr)
|
nets = append(nets, cidr)
|
||||||
}
|
}
|
||||||
ph := handlers.ProxyHeaders
|
|
||||||
return func(h http.Handler) http.Handler {
|
return func(h http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||||
@ -30,7 +38,8 @@ func ProxyHeaders() func(http.Handler) http.Handler {
|
|||||||
for _, allowedCidr := range nets {
|
for _, allowedCidr := range nets {
|
||||||
if remoteAddr != nil && allowedCidr.Contains(remoteAddr) {
|
if remoteAddr != nil && allowedCidr.Contains(remoteAddr) {
|
||||||
log.WithField("remoteAddr", remoteAddr).WithField("cidr", allowedCidr.String()).Trace("Setting proxy headers")
|
log.WithField("remoteAddr", remoteAddr).WithField("cidr", allowedCidr.String()).Trace("Setting proxy headers")
|
||||||
ph(h).ServeHTTP(w, r)
|
rr := r.WithContext(context.WithValue(r.Context(), allowedProxyRequest, true))
|
||||||
|
handlers.ProxyHeaders(h).ServeHTTP(w, rr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package brand_tls
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"crypto/x509"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -56,22 +57,37 @@ func (w *Watcher) Check() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, b := range brands {
|
for _, b := range brands {
|
||||||
kp := b.WebCertificate.Get()
|
kp := b.GetWebCertificate()
|
||||||
if kp == nil {
|
if kp != "" {
|
||||||
continue
|
err := w.cs.AddKeypair(kp)
|
||||||
|
if err != nil {
|
||||||
|
w.log.WithError(err).WithField("kp", kp).Warning("failed to add web certificate")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err := w.cs.AddKeypair(*kp)
|
for _, crt := range b.GetClientCertificates() {
|
||||||
if err != nil {
|
if crt != "" {
|
||||||
w.log.WithError(err).Warning("failed to add certificate")
|
err := w.cs.AddKeypair(crt)
|
||||||
|
if err != nil {
|
||||||
|
w.log.WithError(err).WithField("kp", kp).Warning("failed to add client certificate")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.brands = brands
|
w.brands = brands
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Watcher) GetCertificate(ch *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
type CertificateConfig struct {
|
||||||
|
Web *tls.Certificate
|
||||||
|
Client *x509.CertPool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Watcher) GetCertificate(ch *tls.ClientHelloInfo) *CertificateConfig {
|
||||||
var bestSelection *api.Brand
|
var bestSelection *api.Brand
|
||||||
|
config := CertificateConfig{
|
||||||
|
Web: w.fallback,
|
||||||
|
}
|
||||||
for _, t := range w.brands {
|
for _, t := range w.brands {
|
||||||
if t.WebCertificate.Get() == nil {
|
if !t.WebCertificate.IsSet() && len(t.GetClientCertificates()) < 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if *t.Default {
|
if *t.Default {
|
||||||
@ -82,11 +98,20 @@ func (w *Watcher) GetCertificate(ch *tls.ClientHelloInfo) (*tls.Certificate, err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if bestSelection == nil {
|
if bestSelection == nil {
|
||||||
return w.fallback, nil
|
return &config
|
||||||
}
|
}
|
||||||
cert := w.cs.Get(bestSelection.GetWebCertificate())
|
if bestSelection.GetWebCertificate() != "" {
|
||||||
if cert == nil {
|
if cert := w.cs.Get(bestSelection.GetWebCertificate()); cert != nil {
|
||||||
return w.fallback, nil
|
config.Web = cert
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cert, nil
|
if len(bestSelection.GetClientCertificates()) > 0 {
|
||||||
|
config.Client = x509.NewCertPool()
|
||||||
|
for _, kp := range bestSelection.GetClientCertificates() {
|
||||||
|
if cert := w.cs.Get(kp); cert != nil {
|
||||||
|
config.Client.AddCert(cert.Leaf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &config
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/gorilla/securecookie"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
@ -18,8 +14,6 @@ import (
|
|||||||
"goauthentik.io/internal/utils/sentry"
|
"goauthentik.io/internal/utils/sentry"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MetricsKeyFile = "authentik-core-metrics.key"
|
|
||||||
|
|
||||||
var Requests = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
var Requests = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
||||||
Name: "authentik_main_request_duration_seconds",
|
Name: "authentik_main_request_duration_seconds",
|
||||||
Help: "API request latencies in seconds",
|
Help: "API request latencies in seconds",
|
||||||
@ -27,14 +21,6 @@ var Requests = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
|||||||
|
|
||||||
func (ws *WebServer) runMetricsServer() {
|
func (ws *WebServer) runMetricsServer() {
|
||||||
l := log.WithField("logger", "authentik.router.metrics")
|
l := log.WithField("logger", "authentik.router.metrics")
|
||||||
tmp := os.TempDir()
|
|
||||||
key := base64.StdEncoding.EncodeToString(securecookie.GenerateRandomKey(64))
|
|
||||||
keyPath := path.Join(tmp, MetricsKeyFile)
|
|
||||||
err := os.WriteFile(keyPath, []byte(key), 0o600)
|
|
||||||
if err != nil {
|
|
||||||
l.WithError(err).Warning("failed to save metrics key")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
m := mux.NewRouter()
|
m := mux.NewRouter()
|
||||||
m.Use(sentry.SentryNoSampleMiddleware)
|
m.Use(sentry.SentryNoSampleMiddleware)
|
||||||
@ -51,7 +37,7 @@ func (ws *WebServer) runMetricsServer() {
|
|||||||
l.WithError(err).Warning("failed to get upstream metrics")
|
l.WithError(err).Warning("failed to get upstream metrics")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
re.Header.Set("Authorization", fmt.Sprintf("Bearer %s", key))
|
re.Header.Set("Authorization", fmt.Sprintf("Bearer %s", ws.metricsKey))
|
||||||
res, err := ws.upstreamHttpClient().Do(re)
|
res, err := ws.upstreamHttpClient().Do(re)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.WithError(err).Warning("failed to get upstream metrics")
|
l.WithError(err).Warning("failed to get upstream metrics")
|
||||||
@ -64,13 +50,9 @@ func (ws *WebServer) runMetricsServer() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
l.WithField("listen", config.Get().Listen.Metrics).Info("Starting Metrics server")
|
l.WithField("listen", config.Get().Listen.Metrics).Info("Starting Metrics server")
|
||||||
err = http.ListenAndServe(config.Get().Listen.Metrics, m)
|
err := http.ListenAndServe(config.Get().Listen.Metrics, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.WithError(err).Warning("Failed to start metrics server")
|
l.WithError(err).Warning("Failed to start metrics server")
|
||||||
}
|
}
|
||||||
l.WithField("listen", config.Get().Listen.Metrics).Info("Stopping Metrics server")
|
l.WithField("listen", config.Get().Listen.Metrics).Info("Stopping Metrics server")
|
||||||
err = os.Remove(keyPath)
|
|
||||||
if err != nil {
|
|
||||||
l.WithError(err).Warning("failed to remove metrics key file")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,29 @@ package web
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"encoding/pem"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"goauthentik.io/internal/config"
|
"goauthentik.io/internal/config"
|
||||||
"goauthentik.io/internal/utils/sentry"
|
"goauthentik.io/internal/utils/sentry"
|
||||||
|
"goauthentik.io/internal/utils/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrAuthentikStarting = errors.New("authentik starting")
|
ErrAuthentikStarting = errors.New("authentik starting")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
maxBodyBytes = 32 * 1024 * 1024
|
||||||
|
)
|
||||||
|
|
||||||
func (ws *WebServer) configureProxy() {
|
func (ws *WebServer) configureProxy() {
|
||||||
// Reverse proxy to the application server
|
// Reverse proxy to the application server
|
||||||
director := func(req *http.Request) {
|
director := func(req *http.Request) {
|
||||||
@ -26,8 +34,25 @@ func (ws *WebServer) configureProxy() {
|
|||||||
// explicitly disable User-Agent so it's not set to default value
|
// explicitly disable User-Agent so it's not set to default value
|
||||||
req.Header.Set("User-Agent", "")
|
req.Header.Set("User-Agent", "")
|
||||||
}
|
}
|
||||||
|
if !web.IsRequestFromTrustedProxy(req) {
|
||||||
|
// If the request isn't coming from a trusted proxy, delete MTLS headers
|
||||||
|
req.Header.Del("SSL-Client-Cert") // nginx-ingress
|
||||||
|
req.Header.Del("X-Forwarded-TLS-Client-Cert") // traefik
|
||||||
|
req.Header.Del("X-Forwarded-Client-Cert") // envoy
|
||||||
|
}
|
||||||
if req.TLS != nil {
|
if req.TLS != nil {
|
||||||
req.Header.Set("X-Forwarded-Proto", "https")
|
req.Header.Set("X-Forwarded-Proto", "https")
|
||||||
|
if len(req.TLS.PeerCertificates) > 0 {
|
||||||
|
pems := make([]string, len(req.TLS.PeerCertificates))
|
||||||
|
for i, crt := range req.TLS.PeerCertificates {
|
||||||
|
pem := pem.EncodeToMemory(&pem.Block{
|
||||||
|
Type: "CERTIFICATE",
|
||||||
|
Bytes: crt.Raw,
|
||||||
|
})
|
||||||
|
pems[i] = "Cert=" + url.QueryEscape(string(pem))
|
||||||
|
}
|
||||||
|
req.Header.Set("X-Forwarded-Client-Cert", strings.Join(pems, ","))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ws.log.WithField("url", req.URL.String()).WithField("headers", req.Header).Trace("tracing request to backend")
|
ws.log.WithField("url", req.URL.String()).WithField("headers", req.Header).Trace("tracing request to backend")
|
||||||
}
|
}
|
||||||
@ -57,7 +82,7 @@ func (ws *WebServer) configureProxy() {
|
|||||||
Requests.With(prometheus.Labels{
|
Requests.With(prometheus.Labels{
|
||||||
"dest": "core",
|
"dest": "core",
|
||||||
}).Observe(float64(elapsed) / float64(time.Second))
|
}).Observe(float64(elapsed) / float64(time.Second))
|
||||||
r.Body = http.MaxBytesReader(rw, r.Body, 32*1024*1024)
|
r.Body = http.MaxBytesReader(rw, r.Body, maxBodyBytes)
|
||||||
rp.ServeHTTP(rw, r)
|
rp.ServeHTTP(rw, r)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package web
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
@ -13,17 +14,27 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/handlers"
|
"github.com/gorilla/handlers"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/gorilla/securecookie"
|
||||||
"github.com/pires/go-proxyproto"
|
"github.com/pires/go-proxyproto"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"goauthentik.io/api/v3"
|
||||||
"goauthentik.io/internal/config"
|
"goauthentik.io/internal/config"
|
||||||
|
"goauthentik.io/internal/constants"
|
||||||
"goauthentik.io/internal/gounicorn"
|
"goauthentik.io/internal/gounicorn"
|
||||||
|
"goauthentik.io/internal/outpost/ak"
|
||||||
"goauthentik.io/internal/outpost/proxyv2"
|
"goauthentik.io/internal/outpost/proxyv2"
|
||||||
"goauthentik.io/internal/utils"
|
"goauthentik.io/internal/utils"
|
||||||
"goauthentik.io/internal/utils/web"
|
"goauthentik.io/internal/utils/web"
|
||||||
"goauthentik.io/internal/web/brand_tls"
|
"goauthentik.io/internal/web/brand_tls"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
IPCKeyFile = "authentik-core-ipc.key"
|
||||||
|
MetricsKeyFile = "authentik-core-metrics.key"
|
||||||
|
UnixSocketName = "authentik-core.sock"
|
||||||
|
)
|
||||||
|
|
||||||
type WebServer struct {
|
type WebServer struct {
|
||||||
Bind string
|
Bind string
|
||||||
BindTLS bool
|
BindTLS bool
|
||||||
@ -40,9 +51,10 @@ type WebServer struct {
|
|||||||
log *log.Entry
|
log *log.Entry
|
||||||
upstreamClient *http.Client
|
upstreamClient *http.Client
|
||||||
upstreamURL *url.URL
|
upstreamURL *url.URL
|
||||||
}
|
|
||||||
|
|
||||||
const UnixSocketName = "authentik-core.sock"
|
metricsKey string
|
||||||
|
ipcKey string
|
||||||
|
}
|
||||||
|
|
||||||
func NewWebServer() *WebServer {
|
func NewWebServer() *WebServer {
|
||||||
l := log.WithField("logger", "authentik.router")
|
l := log.WithField("logger", "authentik.router")
|
||||||
@ -76,7 +88,7 @@ func NewWebServer() *WebServer {
|
|||||||
mainRouter: mainHandler,
|
mainRouter: mainHandler,
|
||||||
loggingRouter: loggingHandler,
|
loggingRouter: loggingHandler,
|
||||||
log: l,
|
log: l,
|
||||||
gunicornReady: true,
|
gunicornReady: false,
|
||||||
upstreamClient: upstreamClient,
|
upstreamClient: upstreamClient,
|
||||||
upstreamURL: u,
|
upstreamURL: u,
|
||||||
}
|
}
|
||||||
@ -103,7 +115,59 @@ func NewWebServer() *WebServer {
|
|||||||
return ws
|
return ws
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ws *WebServer) prepareKeys() {
|
||||||
|
tmp := os.TempDir()
|
||||||
|
key := base64.StdEncoding.EncodeToString(securecookie.GenerateRandomKey(64))
|
||||||
|
err := os.WriteFile(path.Join(tmp, MetricsKeyFile), []byte(key), 0o600)
|
||||||
|
if err != nil {
|
||||||
|
ws.log.WithError(err).Warning("failed to save metrics key")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ws.metricsKey = key
|
||||||
|
|
||||||
|
key = base64.StdEncoding.EncodeToString(securecookie.GenerateRandomKey(64))
|
||||||
|
err = os.WriteFile(path.Join(tmp, IPCKeyFile), []byte(key), 0o600)
|
||||||
|
if err != nil {
|
||||||
|
ws.log.WithError(err).Warning("failed to save ipc key")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ws.ipcKey = key
|
||||||
|
}
|
||||||
|
|
||||||
func (ws *WebServer) Start() {
|
func (ws *WebServer) Start() {
|
||||||
|
ws.prepareKeys()
|
||||||
|
|
||||||
|
u, err := url.Parse(fmt.Sprintf("http://%s%s", config.Get().Listen.HTTP, config.Get().Web.Path))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
apiConfig := api.NewConfiguration()
|
||||||
|
apiConfig.Host = u.Host
|
||||||
|
apiConfig.Scheme = u.Scheme
|
||||||
|
apiConfig.HTTPClient = &http.Client{
|
||||||
|
Transport: web.NewUserAgentTransport(
|
||||||
|
constants.UserAgentIPC(),
|
||||||
|
ak.GetTLSTransport(),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
apiConfig.Servers = api.ServerConfigurations{
|
||||||
|
{
|
||||||
|
URL: fmt.Sprintf("%sapi/v3", u.Path),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
apiConfig.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", ws.ipcKey))
|
||||||
|
|
||||||
|
// create the API client, with the transport
|
||||||
|
apiClient := api.NewAPIClient(apiConfig)
|
||||||
|
|
||||||
|
// Init brand_tls here too since it requires an API Client,
|
||||||
|
// so we just reuse the same one as the outpost uses
|
||||||
|
tw := brand_tls.NewWatcher(apiClient)
|
||||||
|
ws.BrandTLS = tw
|
||||||
|
ws.g.AddHealthyCallback(func() {
|
||||||
|
go tw.Start()
|
||||||
|
})
|
||||||
|
|
||||||
go ws.runMetricsServer()
|
go ws.runMetricsServer()
|
||||||
go ws.attemptStartBackend()
|
go ws.attemptStartBackend()
|
||||||
go ws.listenPlain()
|
go ws.listenPlain()
|
||||||
@ -112,23 +176,23 @@ func (ws *WebServer) Start() {
|
|||||||
|
|
||||||
func (ws *WebServer) attemptStartBackend() {
|
func (ws *WebServer) attemptStartBackend() {
|
||||||
for {
|
for {
|
||||||
if !ws.gunicornReady {
|
if ws.gunicornReady {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := ws.g.Start()
|
err := ws.g.Start()
|
||||||
log.WithField("logger", "authentik.router").WithError(err).Warning("gunicorn process died, restarting")
|
ws.log.WithError(err).Warning("gunicorn process died, restarting")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithField("logger", "authentik.router").WithError(err).Error("gunicorn failed to start, restarting")
|
ws.log.WithError(err).Error("gunicorn failed to start, restarting")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
failedChecks := 0
|
failedChecks := 0
|
||||||
for range time.NewTicker(30 * time.Second).C {
|
for range time.NewTicker(30 * time.Second).C {
|
||||||
if !ws.g.IsRunning() {
|
if !ws.g.IsRunning() {
|
||||||
log.WithField("logger", "authentik.router").Warningf("gunicorn process failed healthcheck %d times", failedChecks)
|
ws.log.Warningf("gunicorn process failed healthcheck %d times", failedChecks)
|
||||||
failedChecks += 1
|
failedChecks += 1
|
||||||
}
|
}
|
||||||
if failedChecks >= 3 {
|
if failedChecks >= 3 {
|
||||||
log.WithField("logger", "authentik.router").WithError(err).Error("gunicorn process failed healthcheck three times, restarting")
|
ws.log.WithError(err).Error("gunicorn process failed healthcheck three times, restarting")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,6 +210,15 @@ func (ws *WebServer) upstreamHttpClient() *http.Client {
|
|||||||
func (ws *WebServer) Shutdown() {
|
func (ws *WebServer) Shutdown() {
|
||||||
ws.log.Info("shutting down gunicorn")
|
ws.log.Info("shutting down gunicorn")
|
||||||
ws.g.Kill()
|
ws.g.Kill()
|
||||||
|
tmp := os.TempDir()
|
||||||
|
err := os.Remove(path.Join(tmp, MetricsKeyFile))
|
||||||
|
if err != nil {
|
||||||
|
ws.log.WithError(err).Warning("failed to remove metrics key file")
|
||||||
|
}
|
||||||
|
err = os.Remove(path.Join(tmp, IPCKeyFile))
|
||||||
|
if err != nil {
|
||||||
|
ws.log.WithError(err).Warning("failed to remove ipc key file")
|
||||||
|
}
|
||||||
ws.stop <- struct{}{}
|
ws.stop <- struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,40 +12,57 @@ import (
|
|||||||
"goauthentik.io/internal/utils/web"
|
"goauthentik.io/internal/utils/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ws *WebServer) GetCertificate() func(ch *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
func (ws *WebServer) GetCertificate() func(ch *tls.ClientHelloInfo) (*tls.Config, error) {
|
||||||
cert, err := crypto.GenerateSelfSignedCert()
|
fallback, err := crypto.GenerateSelfSignedCert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ws.log.WithError(err).Error("failed to generate default cert")
|
ws.log.WithError(err).Error("failed to generate default cert")
|
||||||
}
|
}
|
||||||
return func(ch *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
return func(ch *tls.ClientHelloInfo) (*tls.Config, error) {
|
||||||
|
cfg := utils.GetTLSConfig()
|
||||||
if ch.ServerName == "" {
|
if ch.ServerName == "" {
|
||||||
return &cert, nil
|
cfg.Certificates = []tls.Certificate{fallback}
|
||||||
|
return cfg, nil
|
||||||
}
|
}
|
||||||
if ws.ProxyServer != nil {
|
if ws.ProxyServer != nil {
|
||||||
appCert := ws.ProxyServer.GetCertificate(ch.ServerName)
|
appCert := ws.ProxyServer.GetCertificate(ch.ServerName)
|
||||||
if appCert != nil {
|
if appCert != nil {
|
||||||
return appCert, nil
|
cfg.Certificates = []tls.Certificate{*appCert}
|
||||||
|
return cfg, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ws.BrandTLS != nil {
|
if ws.BrandTLS != nil {
|
||||||
return ws.BrandTLS.GetCertificate(ch)
|
bcert := ws.BrandTLS.GetCertificate(ch)
|
||||||
|
cfg.Certificates = []tls.Certificate{*bcert.Web}
|
||||||
|
ws.log.Trace("using brand web Certificate")
|
||||||
|
if bcert.Client != nil {
|
||||||
|
cfg.ClientCAs = bcert.Client
|
||||||
|
cfg.ClientAuth = tls.RequestClientCert
|
||||||
|
ws.log.Trace("using brand client Certificate")
|
||||||
|
}
|
||||||
|
return cfg, nil
|
||||||
}
|
}
|
||||||
ws.log.Trace("using default, self-signed certificate")
|
ws.log.Trace("using default, self-signed certificate")
|
||||||
return &cert, nil
|
cfg.Certificates = []tls.Certificate{fallback}
|
||||||
|
return cfg, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeHTTPS constructs a net.Listener and starts handling HTTPS requests
|
// ServeHTTPS constructs a net.Listener and starts handling HTTPS requests
|
||||||
func (ws *WebServer) listenTLS() {
|
func (ws *WebServer) listenTLS() {
|
||||||
tlsConfig := utils.GetTLSConfig()
|
tlsConfig := utils.GetTLSConfig()
|
||||||
tlsConfig.GetCertificate = ws.GetCertificate()
|
tlsConfig.GetConfigForClient = ws.GetCertificate()
|
||||||
|
|
||||||
ln, err := net.Listen("tcp", config.Get().Listen.HTTPS)
|
ln, err := net.Listen("tcp", config.Get().Listen.HTTPS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ws.log.WithError(err).Warning("failed to listen (TLS)")
|
ws.log.WithError(err).Warning("failed to listen (TLS)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
proxyListener := &proxyproto.Listener{Listener: web.TCPKeepAliveListener{TCPListener: ln.(*net.TCPListener)}, ConnPolicy: utils.GetProxyConnectionPolicy()}
|
proxyListener := &proxyproto.Listener{
|
||||||
|
Listener: web.TCPKeepAliveListener{
|
||||||
|
TCPListener: ln.(*net.TCPListener),
|
||||||
|
},
|
||||||
|
ConnPolicy: utils.GetProxyConnectionPolicy(),
|
||||||
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
err := proxyListener.Close()
|
err := proxyListener.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
8
lifecycle/aws/package-lock.json
generated
8
lifecycle/aws/package-lock.json
generated
@ -9,7 +9,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"aws-cdk": "^2.1014.0",
|
"aws-cdk": "^2.1016.0",
|
||||||
"cross-env": "^7.0.3"
|
"cross-env": "^7.0.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -17,9 +17,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/aws-cdk": {
|
"node_modules/aws-cdk": {
|
||||||
"version": "2.1014.0",
|
"version": "2.1016.0",
|
||||||
"resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.1014.0.tgz",
|
"resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.1016.0.tgz",
|
||||||
"integrity": "sha512-es101rtRAClix9BncNL54iW90MiOyRv4iCC5tv/firGDnidS6pPinuK0IIFt0RO6w0+3heRxWBXg8HY+f9877w==",
|
"integrity": "sha512-zdJ/tQp0iE/s8l8zLQPgdUJUHpS6KblkzdP5nOYC/NbD5OCdhS8QS7vLBkT8M7mNyZh3Ep3C+/m6NsxrurRe0A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"aws-cdk": "^2.1014.0",
|
"aws-cdk": "^2.1016.0",
|
||||||
"cross-env": "^7.0.3"
|
"cross-env": "^7.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ Parameters:
|
|||||||
Description: authentik Docker image
|
Description: authentik Docker image
|
||||||
AuthentikVersion:
|
AuthentikVersion:
|
||||||
Type: String
|
Type: String
|
||||||
Default: 2025.4.0
|
Default: 2025.4.1
|
||||||
Description: authentik Docker image tag
|
Description: authentik Docker image tag
|
||||||
AuthentikServerCPU:
|
AuthentikServerCPU:
|
||||||
Type: Number
|
Type: Number
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@goauthentik/authentik",
|
"name": "@goauthentik/authentik",
|
||||||
"version": "2025.4.0",
|
"version": "2025.4.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "authentik"
|
name = "authentik"
|
||||||
version = "2025.4.0"
|
version = "2025.4.1"
|
||||||
description = ""
|
description = ""
|
||||||
authors = [{ name = "authentik Team", email = "hello@goauthentik.io" }]
|
authors = [{ name = "authentik Team", email = "hello@goauthentik.io" }]
|
||||||
requires-python = "==3.13.*"
|
requires-python = "==3.13.*"
|
||||||
@ -19,7 +19,7 @@ dependencies = [
|
|||||||
"django-filter==25.1",
|
"django-filter==25.1",
|
||||||
"django-guardian<3.0.0",
|
"django-guardian<3.0.0",
|
||||||
"django-model-utils==5.0.0",
|
"django-model-utils==5.0.0",
|
||||||
"django-pglock==1.7.1",
|
"django-pglock==1.7.2",
|
||||||
"django-prometheus==2.3.1",
|
"django-prometheus==2.3.1",
|
||||||
"django-redis==5.4.0",
|
"django-redis==5.4.0",
|
||||||
"django-storages[s3]==1.14.6",
|
"django-storages[s3]==1.14.6",
|
||||||
|
476
schema.yml
476
schema.yml
@ -1,7 +1,7 @@
|
|||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: authentik
|
title: authentik
|
||||||
version: 2025.4.0
|
version: 2025.4.1
|
||||||
description: Making authentication simple.
|
description: Making authentication simple.
|
||||||
contact:
|
contact:
|
||||||
email: hello@goauthentik.io
|
email: hello@goauthentik.io
|
||||||
@ -4460,6 +4460,15 @@ paths:
|
|||||||
name: branding_title
|
name: branding_title
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: client_certificates
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
explode: true
|
||||||
|
style: form
|
||||||
- in: query
|
- in: query
|
||||||
name: default
|
name: default
|
||||||
schema:
|
schema:
|
||||||
@ -24978,6 +24987,7 @@ paths:
|
|||||||
- authentik_stages_identification.identificationstage
|
- authentik_stages_identification.identificationstage
|
||||||
- authentik_stages_invitation.invitation
|
- authentik_stages_invitation.invitation
|
||||||
- authentik_stages_invitation.invitationstage
|
- authentik_stages_invitation.invitationstage
|
||||||
|
- authentik_stages_mtls.mutualtlsstage
|
||||||
- authentik_stages_password.passwordstage
|
- authentik_stages_password.passwordstage
|
||||||
- authentik_stages_prompt.prompt
|
- authentik_stages_prompt.prompt
|
||||||
- authentik_stages_prompt.promptstage
|
- authentik_stages_prompt.promptstage
|
||||||
@ -25226,6 +25236,7 @@ paths:
|
|||||||
- authentik_stages_identification.identificationstage
|
- authentik_stages_identification.identificationstage
|
||||||
- authentik_stages_invitation.invitation
|
- authentik_stages_invitation.invitation
|
||||||
- authentik_stages_invitation.invitationstage
|
- authentik_stages_invitation.invitationstage
|
||||||
|
- authentik_stages_mtls.mutualtlsstage
|
||||||
- authentik_stages_password.passwordstage
|
- authentik_stages_password.passwordstage
|
||||||
- authentik_stages_prompt.prompt
|
- authentik_stages_prompt.prompt
|
||||||
- authentik_stages_prompt.promptstage
|
- authentik_stages_prompt.promptstage
|
||||||
@ -37718,6 +37729,311 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/GenericError'
|
$ref: '#/components/schemas/GenericError'
|
||||||
description: ''
|
description: ''
|
||||||
|
/stages/mtls/:
|
||||||
|
get:
|
||||||
|
operationId: stages_mtls_list
|
||||||
|
description: MutualTLSStage Viewset
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: cert_attribute
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- common_name
|
||||||
|
- email
|
||||||
|
- subject
|
||||||
|
- in: query
|
||||||
|
name: certificate_authorities
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
explode: true
|
||||||
|
style: form
|
||||||
|
- in: query
|
||||||
|
name: mode
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- optional
|
||||||
|
- required
|
||||||
|
- in: query
|
||||||
|
name: name
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: ordering
|
||||||
|
required: false
|
||||||
|
in: query
|
||||||
|
description: Which field to use when ordering the results.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: page
|
||||||
|
required: false
|
||||||
|
in: query
|
||||||
|
description: A page number within the paginated result set.
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
- name: page_size
|
||||||
|
required: false
|
||||||
|
in: query
|
||||||
|
description: Number of results to return per page.
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
- name: search
|
||||||
|
required: false
|
||||||
|
in: query
|
||||||
|
description: A search term.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: stage_uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
- in: query
|
||||||
|
name: user_attribute
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- email
|
||||||
|
- username
|
||||||
|
tags:
|
||||||
|
- stages
|
||||||
|
security:
|
||||||
|
- authentik: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/PaginatedMutualTLSStageList'
|
||||||
|
description: ''
|
||||||
|
'400':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ValidationError'
|
||||||
|
description: ''
|
||||||
|
'403':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericError'
|
||||||
|
description: ''
|
||||||
|
post:
|
||||||
|
operationId: stages_mtls_create
|
||||||
|
description: MutualTLSStage Viewset
|
||||||
|
tags:
|
||||||
|
- stages
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStageRequest'
|
||||||
|
required: true
|
||||||
|
security:
|
||||||
|
- authentik: []
|
||||||
|
responses:
|
||||||
|
'201':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStage'
|
||||||
|
description: ''
|
||||||
|
'400':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ValidationError'
|
||||||
|
description: ''
|
||||||
|
'403':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericError'
|
||||||
|
description: ''
|
||||||
|
/stages/mtls/{stage_uuid}/:
|
||||||
|
get:
|
||||||
|
operationId: stages_mtls_retrieve
|
||||||
|
description: MutualTLSStage Viewset
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: stage_uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mutual TLS Stage.
|
||||||
|
required: true
|
||||||
|
tags:
|
||||||
|
- stages
|
||||||
|
security:
|
||||||
|
- authentik: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStage'
|
||||||
|
description: ''
|
||||||
|
'400':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ValidationError'
|
||||||
|
description: ''
|
||||||
|
'403':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericError'
|
||||||
|
description: ''
|
||||||
|
put:
|
||||||
|
operationId: stages_mtls_update
|
||||||
|
description: MutualTLSStage Viewset
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: stage_uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mutual TLS Stage.
|
||||||
|
required: true
|
||||||
|
tags:
|
||||||
|
- stages
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStageRequest'
|
||||||
|
required: true
|
||||||
|
security:
|
||||||
|
- authentik: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStage'
|
||||||
|
description: ''
|
||||||
|
'400':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ValidationError'
|
||||||
|
description: ''
|
||||||
|
'403':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericError'
|
||||||
|
description: ''
|
||||||
|
patch:
|
||||||
|
operationId: stages_mtls_partial_update
|
||||||
|
description: MutualTLSStage Viewset
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: stage_uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mutual TLS Stage.
|
||||||
|
required: true
|
||||||
|
tags:
|
||||||
|
- stages
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/PatchedMutualTLSStageRequest'
|
||||||
|
security:
|
||||||
|
- authentik: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStage'
|
||||||
|
description: ''
|
||||||
|
'400':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ValidationError'
|
||||||
|
description: ''
|
||||||
|
'403':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericError'
|
||||||
|
description: ''
|
||||||
|
delete:
|
||||||
|
operationId: stages_mtls_destroy
|
||||||
|
description: MutualTLSStage Viewset
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: stage_uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mutual TLS Stage.
|
||||||
|
required: true
|
||||||
|
tags:
|
||||||
|
- stages
|
||||||
|
security:
|
||||||
|
- authentik: []
|
||||||
|
responses:
|
||||||
|
'204':
|
||||||
|
description: No response body
|
||||||
|
'400':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ValidationError'
|
||||||
|
description: ''
|
||||||
|
'403':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericError'
|
||||||
|
description: ''
|
||||||
|
/stages/mtls/{stage_uuid}/used_by/:
|
||||||
|
get:
|
||||||
|
operationId: stages_mtls_used_by_list
|
||||||
|
description: Get a list of all objects that use this object
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: stage_uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: A UUID string identifying this Mutual TLS Stage.
|
||||||
|
required: true
|
||||||
|
tags:
|
||||||
|
- stages
|
||||||
|
security:
|
||||||
|
- authentik: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/UsedBy'
|
||||||
|
description: ''
|
||||||
|
'400':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ValidationError'
|
||||||
|
description: ''
|
||||||
|
'403':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericError'
|
||||||
|
description: ''
|
||||||
/stages/password/:
|
/stages/password/:
|
||||||
get:
|
get:
|
||||||
operationId: stages_password_list
|
operationId: stages_password_list
|
||||||
@ -40946,6 +41262,7 @@ components:
|
|||||||
- authentik.enterprise.providers.microsoft_entra
|
- authentik.enterprise.providers.microsoft_entra
|
||||||
- authentik.enterprise.providers.ssf
|
- authentik.enterprise.providers.ssf
|
||||||
- authentik.enterprise.stages.authenticator_endpoint_gdtc
|
- authentik.enterprise.stages.authenticator_endpoint_gdtc
|
||||||
|
- authentik.enterprise.stages.mtls
|
||||||
- authentik.enterprise.stages.source
|
- authentik.enterprise.stages.source
|
||||||
- authentik.events
|
- authentik.events
|
||||||
type: string
|
type: string
|
||||||
@ -42609,6 +42926,12 @@ components:
|
|||||||
format: uuid
|
format: uuid
|
||||||
nullable: true
|
nullable: true
|
||||||
description: Web Certificate used by the authentik Core webserver.
|
description: Web Certificate used by the authentik Core webserver.
|
||||||
|
client_certificates:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Certificates used for client authentication.
|
||||||
attributes: {}
|
attributes: {}
|
||||||
required:
|
required:
|
||||||
- brand_uuid
|
- brand_uuid
|
||||||
@ -42673,6 +42996,12 @@ components:
|
|||||||
format: uuid
|
format: uuid
|
||||||
nullable: true
|
nullable: true
|
||||||
description: Web Certificate used by the authentik Core webserver.
|
description: Web Certificate used by the authentik Core webserver.
|
||||||
|
client_certificates:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Certificates used for client authentication.
|
||||||
attributes: {}
|
attributes: {}
|
||||||
required:
|
required:
|
||||||
- domain
|
- domain
|
||||||
@ -42842,6 +43171,12 @@ components:
|
|||||||
- name
|
- name
|
||||||
- private_key
|
- private_key
|
||||||
- public_key
|
- public_key
|
||||||
|
CertAttributeEnum:
|
||||||
|
enum:
|
||||||
|
- subject
|
||||||
|
- common_name
|
||||||
|
- email
|
||||||
|
type: string
|
||||||
CertificateData:
|
CertificateData:
|
||||||
type: object
|
type: object
|
||||||
description: Get CertificateKeyPair's data
|
description: Get CertificateKeyPair's data
|
||||||
@ -48368,6 +48703,7 @@ components:
|
|||||||
- authentik_providers_microsoft_entra.microsoftentraprovidermapping
|
- authentik_providers_microsoft_entra.microsoftentraprovidermapping
|
||||||
- authentik_providers_ssf.ssfprovider
|
- authentik_providers_ssf.ssfprovider
|
||||||
- authentik_stages_authenticator_endpoint_gdtc.authenticatorendpointgdtcstage
|
- authentik_stages_authenticator_endpoint_gdtc.authenticatorendpointgdtcstage
|
||||||
|
- authentik_stages_mtls.mutualtlsstage
|
||||||
- authentik_stages_source.sourcestage
|
- authentik_stages_source.sourcestage
|
||||||
- authentik_events.event
|
- authentik_events.event
|
||||||
- authentik_events.notificationtransport
|
- authentik_events.notificationtransport
|
||||||
@ -48375,6 +48711,96 @@ components:
|
|||||||
- authentik_events.notificationrule
|
- authentik_events.notificationrule
|
||||||
- authentik_events.notificationwebhookmapping
|
- authentik_events.notificationwebhookmapping
|
||||||
type: string
|
type: string
|
||||||
|
MutualTLSStage:
|
||||||
|
type: object
|
||||||
|
description: MutualTLSStage Serializer
|
||||||
|
properties:
|
||||||
|
pk:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
readOnly: true
|
||||||
|
title: Stage uuid
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
component:
|
||||||
|
type: string
|
||||||
|
description: Get object type so that we know how to edit the object
|
||||||
|
readOnly: true
|
||||||
|
verbose_name:
|
||||||
|
type: string
|
||||||
|
description: Return object's verbose_name
|
||||||
|
readOnly: true
|
||||||
|
verbose_name_plural:
|
||||||
|
type: string
|
||||||
|
description: Return object's plural verbose_name
|
||||||
|
readOnly: true
|
||||||
|
meta_model_name:
|
||||||
|
type: string
|
||||||
|
description: Return internal model name
|
||||||
|
readOnly: true
|
||||||
|
flow_set:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/FlowSet'
|
||||||
|
mode:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStageModeEnum'
|
||||||
|
certificate_authorities:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Configure certificate authorities to validate the certificate
|
||||||
|
against. This option has a higher priority than the `client_certificate`
|
||||||
|
option on `Brand`.
|
||||||
|
cert_attribute:
|
||||||
|
$ref: '#/components/schemas/CertAttributeEnum'
|
||||||
|
user_attribute:
|
||||||
|
$ref: '#/components/schemas/UserAttributeEnum'
|
||||||
|
required:
|
||||||
|
- cert_attribute
|
||||||
|
- component
|
||||||
|
- meta_model_name
|
||||||
|
- mode
|
||||||
|
- name
|
||||||
|
- pk
|
||||||
|
- user_attribute
|
||||||
|
- verbose_name
|
||||||
|
- verbose_name_plural
|
||||||
|
MutualTLSStageModeEnum:
|
||||||
|
enum:
|
||||||
|
- optional
|
||||||
|
- required
|
||||||
|
type: string
|
||||||
|
MutualTLSStageRequest:
|
||||||
|
type: object
|
||||||
|
description: MutualTLSStage Serializer
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
|
flow_set:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/FlowSetRequest'
|
||||||
|
mode:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStageModeEnum'
|
||||||
|
certificate_authorities:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Configure certificate authorities to validate the certificate
|
||||||
|
against. This option has a higher priority than the `client_certificate`
|
||||||
|
option on `Brand`.
|
||||||
|
cert_attribute:
|
||||||
|
$ref: '#/components/schemas/CertAttributeEnum'
|
||||||
|
user_attribute:
|
||||||
|
$ref: '#/components/schemas/UserAttributeEnum'
|
||||||
|
required:
|
||||||
|
- cert_attribute
|
||||||
|
- mode
|
||||||
|
- name
|
||||||
|
- user_attribute
|
||||||
NameIdPolicyEnum:
|
NameIdPolicyEnum:
|
||||||
enum:
|
enum:
|
||||||
- urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
|
- urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
|
||||||
@ -50220,6 +50646,18 @@ components:
|
|||||||
required:
|
required:
|
||||||
- pagination
|
- pagination
|
||||||
- results
|
- results
|
||||||
|
PaginatedMutualTLSStageList:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
pagination:
|
||||||
|
$ref: '#/components/schemas/Pagination'
|
||||||
|
results:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStage'
|
||||||
|
required:
|
||||||
|
- pagination
|
||||||
|
- results
|
||||||
PaginatedNotificationList:
|
PaginatedNotificationList:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -51896,6 +52334,12 @@ components:
|
|||||||
format: uuid
|
format: uuid
|
||||||
nullable: true
|
nullable: true
|
||||||
description: Web Certificate used by the authentik Core webserver.
|
description: Web Certificate used by the authentik Core webserver.
|
||||||
|
client_certificates:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Certificates used for client authentication.
|
||||||
attributes: {}
|
attributes: {}
|
||||||
PatchedCaptchaStageRequest:
|
PatchedCaptchaStageRequest:
|
||||||
type: object
|
type: object
|
||||||
@ -53079,6 +53523,31 @@ components:
|
|||||||
type: boolean
|
type: boolean
|
||||||
description: When enabled, provider will not modify or create objects in
|
description: When enabled, provider will not modify or create objects in
|
||||||
the remote system.
|
the remote system.
|
||||||
|
PatchedMutualTLSStageRequest:
|
||||||
|
type: object
|
||||||
|
description: MutualTLSStage Serializer
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
|
flow_set:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/FlowSetRequest'
|
||||||
|
mode:
|
||||||
|
$ref: '#/components/schemas/MutualTLSStageModeEnum'
|
||||||
|
certificate_authorities:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Configure certificate authorities to validate the certificate
|
||||||
|
against. This option has a higher priority than the `client_certificate`
|
||||||
|
option on `Brand`.
|
||||||
|
cert_attribute:
|
||||||
|
$ref: '#/components/schemas/CertAttributeEnum'
|
||||||
|
user_attribute:
|
||||||
|
$ref: '#/components/schemas/UserAttributeEnum'
|
||||||
PatchedNotificationRequest:
|
PatchedNotificationRequest:
|
||||||
type: object
|
type: object
|
||||||
description: Notification Serializer
|
description: Notification Serializer
|
||||||
@ -59793,6 +60262,11 @@ components:
|
|||||||
- pk
|
- pk
|
||||||
- uid
|
- uid
|
||||||
- username
|
- username
|
||||||
|
UserAttributeEnum:
|
||||||
|
enum:
|
||||||
|
- username
|
||||||
|
- email
|
||||||
|
type: string
|
||||||
UserConsent:
|
UserConsent:
|
||||||
type: object
|
type: object
|
||||||
description: UserConsent Serializer
|
description: UserConsent Serializer
|
||||||
|
@ -6,7 +6,7 @@ services:
|
|||||||
network_mode: host
|
network_mode: host
|
||||||
restart: always
|
restart: always
|
||||||
mailpit:
|
mailpit:
|
||||||
image: docker.io/axllent/mailpit:v1.24.2
|
image: docker.io/axllent/mailpit:v1.25.0
|
||||||
ports:
|
ports:
|
||||||
- 1025:1025
|
- 1025:1025
|
||||||
- 8025:8025
|
- 8025:8025
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
"""test default login flow"""
|
"""test default login flow"""
|
||||||
|
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
|
from authentik.flows.models import Flow
|
||||||
from tests.e2e.utils import SeleniumTestCase, retry
|
from tests.e2e.utils import SeleniumTestCase, retry
|
||||||
|
|
||||||
|
|
||||||
class TestFlowsLogin(SeleniumTestCase):
|
class TestFlowsLogin(SeleniumTestCase):
|
||||||
"""test default login flow"""
|
"""test default login flow"""
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
# Reset authentication flow's compatibility mode; we need to do this as its
|
||||||
|
# not specified in the blueprint
|
||||||
|
Flow.objects.filter(slug="default-authentication-flow").update(compatibility_mode=False)
|
||||||
|
return super().tearDown()
|
||||||
|
|
||||||
@retry()
|
@retry()
|
||||||
@apply_blueprint(
|
@apply_blueprint(
|
||||||
"default/flow-default-authentication-flow.yaml",
|
"default/flow-default-authentication-flow.yaml",
|
||||||
@ -23,3 +30,21 @@ class TestFlowsLogin(SeleniumTestCase):
|
|||||||
self.login()
|
self.login()
|
||||||
self.wait_for_url(self.if_user_url("/library"))
|
self.wait_for_url(self.if_user_url("/library"))
|
||||||
self.assert_user(self.user)
|
self.assert_user(self.user)
|
||||||
|
|
||||||
|
@retry()
|
||||||
|
@apply_blueprint(
|
||||||
|
"default/flow-default-authentication-flow.yaml",
|
||||||
|
"default/flow-default-invalidation-flow.yaml",
|
||||||
|
)
|
||||||
|
def test_login_compatibility_mode(self):
|
||||||
|
"""test default login flow with compatibility mode enabled"""
|
||||||
|
Flow.objects.filter(slug="default-authentication-flow").update(compatibility_mode=True)
|
||||||
|
self.driver.get(
|
||||||
|
self.url(
|
||||||
|
"authentik_core:if-flow",
|
||||||
|
flow_slug="default-authentication-flow",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.login(shadow_dom=False)
|
||||||
|
self.wait_for_url(self.if_user_url("/library"))
|
||||||
|
self.assert_user(self.user)
|
||||||
|
@ -29,6 +29,7 @@ from selenium.webdriver.common.keys import Keys
|
|||||||
from selenium.webdriver.remote.command import Command
|
from selenium.webdriver.remote.command import Command
|
||||||
from selenium.webdriver.remote.webdriver import WebDriver
|
from selenium.webdriver.remote.webdriver import WebDriver
|
||||||
from selenium.webdriver.remote.webelement import WebElement
|
from selenium.webdriver.remote.webelement import WebElement
|
||||||
|
from selenium.webdriver.support import expected_conditions as ec
|
||||||
from selenium.webdriver.support.wait import WebDriverWait
|
from selenium.webdriver.support.wait import WebDriverWait
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
@ -37,8 +38,8 @@ from authentik.core.models import User
|
|||||||
from authentik.core.tests.utils import create_test_admin_user
|
from authentik.core.tests.utils import create_test_admin_user
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
|
|
||||||
RETRIES = int(environ.get("RETRIES", "3"))
|
|
||||||
IS_CI = "CI" in environ
|
IS_CI = "CI" in environ
|
||||||
|
RETRIES = int(environ.get("RETRIES", "3")) if IS_CI else 1
|
||||||
|
|
||||||
|
|
||||||
def get_docker_tag() -> str:
|
def get_docker_tag() -> str:
|
||||||
@ -240,10 +241,30 @@ class SeleniumTestCase(DockerTestCase, StaticLiveServerTestCase):
|
|||||||
element = self.driver.execute_script("return arguments[0].shadowRoot", shadow_root)
|
element = self.driver.execute_script("return arguments[0].shadowRoot", shadow_root)
|
||||||
return element
|
return element
|
||||||
|
|
||||||
def login(self):
|
def shady_dom(self) -> WebElement:
|
||||||
|
class wrapper:
|
||||||
|
def __init__(self, container: WebDriver):
|
||||||
|
self.container = container
|
||||||
|
|
||||||
|
def find_element(self, by: str, selector: str) -> WebElement:
|
||||||
|
return self.container.execute_script(
|
||||||
|
"return document.__shady_native_querySelector(arguments[0])", selector
|
||||||
|
)
|
||||||
|
|
||||||
|
return wrapper(self.driver)
|
||||||
|
|
||||||
|
def login(self, shadow_dom=True):
|
||||||
"""Do entire login flow"""
|
"""Do entire login flow"""
|
||||||
flow_executor = self.get_shadow_root("ak-flow-executor")
|
|
||||||
identification_stage = self.get_shadow_root("ak-stage-identification", flow_executor)
|
if shadow_dom:
|
||||||
|
flow_executor = self.get_shadow_root("ak-flow-executor")
|
||||||
|
identification_stage = self.get_shadow_root("ak-stage-identification", flow_executor)
|
||||||
|
else:
|
||||||
|
flow_executor = self.shady_dom()
|
||||||
|
identification_stage = self.shady_dom()
|
||||||
|
|
||||||
|
wait = WebDriverWait(identification_stage, self.wait_timeout)
|
||||||
|
wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "input[name=uidField]")))
|
||||||
|
|
||||||
identification_stage.find_element(By.CSS_SELECTOR, "input[name=uidField]").click()
|
identification_stage.find_element(By.CSS_SELECTOR, "input[name=uidField]").click()
|
||||||
identification_stage.find_element(By.CSS_SELECTOR, "input[name=uidField]").send_keys(
|
identification_stage.find_element(By.CSS_SELECTOR, "input[name=uidField]").send_keys(
|
||||||
@ -253,8 +274,16 @@ class SeleniumTestCase(DockerTestCase, StaticLiveServerTestCase):
|
|||||||
Keys.ENTER
|
Keys.ENTER
|
||||||
)
|
)
|
||||||
|
|
||||||
flow_executor = self.get_shadow_root("ak-flow-executor")
|
if shadow_dom:
|
||||||
password_stage = self.get_shadow_root("ak-stage-password", flow_executor)
|
flow_executor = self.get_shadow_root("ak-flow-executor")
|
||||||
|
password_stage = self.get_shadow_root("ak-stage-password", flow_executor)
|
||||||
|
else:
|
||||||
|
flow_executor = self.shady_dom()
|
||||||
|
password_stage = self.shady_dom()
|
||||||
|
|
||||||
|
wait = WebDriverWait(password_stage, self.wait_timeout)
|
||||||
|
wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "input[name=password]")))
|
||||||
|
|
||||||
password_stage.find_element(By.CSS_SELECTOR, "input[name=password]").send_keys(
|
password_stage.find_element(By.CSS_SELECTOR, "input[name=password]").send_keys(
|
||||||
self.user.username
|
self.user.username
|
||||||
)
|
)
|
||||||
|
10
uv.lock
generated
10
uv.lock
generated
@ -164,7 +164,7 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "authentik"
|
name = "authentik"
|
||||||
version = "2025.4.0"
|
version = "2025.4.1"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "argon2-cffi" },
|
{ name = "argon2-cffi" },
|
||||||
@ -279,7 +279,7 @@ requires-dist = [
|
|||||||
{ name = "django-filter", specifier = "==25.1" },
|
{ name = "django-filter", specifier = "==25.1" },
|
||||||
{ name = "django-guardian", specifier = "<3.0.0" },
|
{ name = "django-guardian", specifier = "<3.0.0" },
|
||||||
{ name = "django-model-utils", specifier = "==5.0.0" },
|
{ name = "django-model-utils", specifier = "==5.0.0" },
|
||||||
{ name = "django-pglock", specifier = "==1.7.1" },
|
{ name = "django-pglock", specifier = "==1.7.2" },
|
||||||
{ name = "django-prometheus", specifier = "==2.3.1" },
|
{ name = "django-prometheus", specifier = "==2.3.1" },
|
||||||
{ name = "django-redis", specifier = "==5.4.0" },
|
{ name = "django-redis", specifier = "==5.4.0" },
|
||||||
{ name = "django-storages", extras = ["s3"], specifier = "==1.14.6" },
|
{ name = "django-storages", extras = ["s3"], specifier = "==1.14.6" },
|
||||||
@ -1063,15 +1063,15 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "django-pglock"
|
name = "django-pglock"
|
||||||
version = "1.7.1"
|
version = "1.7.2"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "django" },
|
{ name = "django" },
|
||||||
{ name = "django-pgactivity" },
|
{ name = "django-pgactivity" },
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/ca/9f/3b4b2f7021b626b3981646254f04fcc2db681d7ba7b24be563552368be70/django_pglock-1.7.1.tar.gz", hash = "sha256:69050bdb522fd34585d49bb8a4798dbfbab9ec4754dd1927b1b9eef2ec0edadf", size = 16907, upload-time = "2024-12-16T01:53:47.29Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/9e/1a/6c552b75d0a6b380215c919a667072e4949a3123f275506c6e6ff82f6b76/django_pglock-1.7.2.tar.gz", hash = "sha256:d1d8521b382a5819e8d14978d0e8e63ab2763cb784f5a6bfdbe5de807da4a61a", size = 17287, upload-time = "2025-05-15T22:07:23.744Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/15/bf/6fc72033801279b4ae2003c5b93cc22dfe0814ca1f56432f7cd06975381d/django_pglock-1.7.1-py3-none-any.whl", hash = "sha256:15db418fb56bee37fc8707038495b5085af9b8c203ebfa300202572127bdb3f0", size = 17343, upload-time = "2024-12-16T01:53:45.243Z" },
|
{ url = "https://files.pythonhosted.org/packages/fb/d2/21f19531945f03021460d40654bc2fc3b0c474b57b279d5f5a1c34be7f1b/django_pglock-1.7.2-py3-none-any.whl", hash = "sha256:2f9335527779445fe86507b37e26cfde485a32b91d982a8f80039d3bcd25d596", size = 17674, upload-time = "2025-05-15T22:07:22.618Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
import { create } from "@storybook/theming/create";
|
|
||||||
|
|
||||||
const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
||||||
|
|
||||||
export default create({
|
|
||||||
base: isDarkMode ? "dark" : "light",
|
|
||||||
brandTitle: "authentik Storybook",
|
|
||||||
brandUrl: "https://goauthentik.io",
|
|
||||||
brandImage: "https://goauthentik.io/img/icon_left_brand_colour.svg",
|
|
||||||
brandTarget: "_self",
|
|
||||||
});
|
|
70
web/.storybook/main.js
Normal file
70
web/.storybook/main.js
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* @file Storybook configuration.
|
||||||
|
* @import { StorybookConfig } from "@storybook/web-components-vite";
|
||||||
|
* @import { InlineConfig, Plugin } from "vite";
|
||||||
|
*/
|
||||||
|
import postcssLit from "rollup-plugin-postcss-lit";
|
||||||
|
import tsconfigPaths from "vite-tsconfig-paths";
|
||||||
|
|
||||||
|
const CSSImportPattern = /import [\w$]+ from .+\.(css)/g;
|
||||||
|
const JavaScriptFilePattern = /\.m?(js|ts|tsx)$/;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @satisfies {Plugin<never>}
|
||||||
|
*/
|
||||||
|
const inlineCSSPlugin = {
|
||||||
|
name: "inline-css-plugin",
|
||||||
|
transform: (source, id) => {
|
||||||
|
if (!JavaScriptFilePattern.test(id)) return;
|
||||||
|
|
||||||
|
const code = source.replace(CSSImportPattern, (match) => {
|
||||||
|
return `${match}?inline`;
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
code,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @satisfies {InlineConfig}
|
||||||
|
*/
|
||||||
|
// const viteFinal = ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @satisfies {StorybookConfig}
|
||||||
|
*/
|
||||||
|
const config = {
|
||||||
|
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
||||||
|
addons: [
|
||||||
|
"@storybook/addon-controls",
|
||||||
|
"@storybook/addon-links",
|
||||||
|
"@storybook/addon-essentials",
|
||||||
|
"storybook-addon-mock",
|
||||||
|
],
|
||||||
|
framework: {
|
||||||
|
name: "@storybook/web-components-vite",
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
docs: {
|
||||||
|
autodocs: "tag",
|
||||||
|
},
|
||||||
|
async viteFinal(config) {
|
||||||
|
const [{ mergeConfig }, { createBundleDefinitions }] = await Promise.all([
|
||||||
|
import("vite"),
|
||||||
|
import("@goauthentik/web/bundler/utils/node"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @satisfies {InlineConfig}
|
||||||
|
*/
|
||||||
|
const overrides = {
|
||||||
|
define: createBundleDefinitions(),
|
||||||
|
plugins: [inlineCSSPlugin, postcssLit(), tsconfigPaths()],
|
||||||
|
};
|
||||||
|
|
||||||
|
return mergeConfig(config, overrides);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default config;
|
@ -1,81 +0,0 @@
|
|||||||
import replace from "@rollup/plugin-replace";
|
|
||||||
import type { StorybookConfig } from "@storybook/web-components-vite";
|
|
||||||
import { cwd } from "process";
|
|
||||||
import modify from "rollup-plugin-modify";
|
|
||||||
import postcssLit from "rollup-plugin-postcss-lit";
|
|
||||||
import tsconfigPaths from "vite-tsconfig-paths";
|
|
||||||
|
|
||||||
export const isProdBuild = process.env.NODE_ENV === "production";
|
|
||||||
export const apiBasePath = process.env.AK_API_BASE_PATH || "";
|
|
||||||
|
|
||||||
const importInlinePatterns = [
|
|
||||||
'import AKGlobal from "(\\.\\./)*common/styles/authentik\\.css',
|
|
||||||
'import AKGlobal from "@goauthentik/common/styles/authentik\\.css',
|
|
||||||
'import PF.+ from "@patternfly/patternfly/\\S+\\.css',
|
|
||||||
'import ThemeDark from "@goauthentik/common/styles/theme-dark\\.css',
|
|
||||||
'import OneDark from "@goauthentik/common/styles/one-dark\\.css',
|
|
||||||
'import styles from "\\./LibraryPageImpl\\.css',
|
|
||||||
];
|
|
||||||
|
|
||||||
const importInlineRegexp = new RegExp(importInlinePatterns.map((a) => `(${a})`).join("|"));
|
|
||||||
|
|
||||||
const config: StorybookConfig = {
|
|
||||||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
|
||||||
addons: [
|
|
||||||
"@storybook/addon-controls",
|
|
||||||
"@storybook/addon-links",
|
|
||||||
"@storybook/addon-essentials",
|
|
||||||
"storybook-addon-mock",
|
|
||||||
],
|
|
||||||
staticDirs: [
|
|
||||||
{
|
|
||||||
from: "../node_modules/@patternfly/patternfly/patternfly-base.css",
|
|
||||||
to: "@patternfly/patternfly/patternfly-base.css",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
from: "../src/common/styles/authentik.css",
|
|
||||||
to: "@goauthentik/common/styles/authentik.css",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
from: "../src/common/styles/theme-dark.css",
|
|
||||||
to: "@goauthentik/common/styles/theme-dark.css",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
from: "../src/common/styles/one-dark.css",
|
|
||||||
to: "@goauthentik/common/styles/one-dark.css",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
framework: {
|
|
||||||
name: "@storybook/web-components-vite",
|
|
||||||
options: {},
|
|
||||||
},
|
|
||||||
docs: {
|
|
||||||
autodocs: "tag",
|
|
||||||
},
|
|
||||||
async viteFinal(config) {
|
|
||||||
return {
|
|
||||||
...config,
|
|
||||||
plugins: [
|
|
||||||
modify({
|
|
||||||
find: importInlineRegexp,
|
|
||||||
replace: (match: RegExpMatchArray) => {
|
|
||||||
return `${match}?inline`;
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
replace({
|
|
||||||
"process.env.NODE_ENV": JSON.stringify(
|
|
||||||
isProdBuild ? "production" : "development",
|
|
||||||
),
|
|
||||||
"process.env.CWD": JSON.stringify(cwd()),
|
|
||||||
"process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath),
|
|
||||||
"preventAssignment": true,
|
|
||||||
}),
|
|
||||||
...config.plugins,
|
|
||||||
postcssLit(),
|
|
||||||
tsconfigPaths(),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
38
web/.storybook/manager.js
Normal file
38
web/.storybook/manager.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* @file Storybook manager configuration.
|
||||||
|
*
|
||||||
|
* @import { ThemeVarsPartial } from "storybook/internal/theming";
|
||||||
|
*/
|
||||||
|
import { createUIThemeEffect, resolveUITheme } from "@goauthentik/web/common/theme.ts";
|
||||||
|
import { addons } from "@storybook/manager-api";
|
||||||
|
import { create } from "@storybook/theming/create";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @satisfies {Partial<ThemeVarsPartial>}
|
||||||
|
*/
|
||||||
|
const baseTheme = {
|
||||||
|
brandTitle: "authentik Storybook",
|
||||||
|
brandUrl: "https://goauthentik.io",
|
||||||
|
brandImage: "https://goauthentik.io/img/icon_left_brand_colour.svg",
|
||||||
|
brandTarget: "_self",
|
||||||
|
};
|
||||||
|
|
||||||
|
const uiTheme = resolveUITheme();
|
||||||
|
|
||||||
|
addons.setConfig({
|
||||||
|
theme: create({
|
||||||
|
...baseTheme,
|
||||||
|
base: uiTheme,
|
||||||
|
}),
|
||||||
|
enableShortcuts: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
createUIThemeEffect((nextUITheme) => {
|
||||||
|
addons.setConfig({
|
||||||
|
theme: create({
|
||||||
|
...baseTheme,
|
||||||
|
base: nextUITheme,
|
||||||
|
}),
|
||||||
|
enableShortcuts: false,
|
||||||
|
});
|
||||||
|
});
|
@ -1,9 +0,0 @@
|
|||||||
// .storybook/manager.js
|
|
||||||
import { addons } from "@storybook/manager-api";
|
|
||||||
|
|
||||||
import authentikTheme from "./authentikTheme";
|
|
||||||
|
|
||||||
addons.setConfig({
|
|
||||||
theme: authentikTheme,
|
|
||||||
enableShortcuts: false,
|
|
||||||
});
|
|
@ -1,5 +1,3 @@
|
|||||||
<link rel="stylesheet" href="@patternfly/patternfly/patternfly-base.css" />
|
|
||||||
<link rel="stylesheet" href="@goauthentik/common/styles/authentik.css" />
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
|
32
web/.storybook/preview.js
Normal file
32
web/.storybook/preview.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/// <reference types="../types/css.js" />
|
||||||
|
/**
|
||||||
|
* @file Storybook manager configuration.
|
||||||
|
*
|
||||||
|
* @import { Preview } from "@storybook/web-components";
|
||||||
|
*/
|
||||||
|
import { applyDocumentTheme } from "@goauthentik/web/common/theme.ts";
|
||||||
|
|
||||||
|
applyDocumentTheme();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @satisfies {Preview}
|
||||||
|
*/
|
||||||
|
const preview = {
|
||||||
|
parameters: {
|
||||||
|
options: {
|
||||||
|
storySort: {
|
||||||
|
method: "alphabetical",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
actions: { argTypesRegex: "^on[A-Z].*" },
|
||||||
|
|
||||||
|
controls: {
|
||||||
|
matchers: {
|
||||||
|
color: /(background|color)$/i,
|
||||||
|
date: /Date$/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default preview;
|
@ -1,30 +0,0 @@
|
|||||||
import type { Preview } from "@storybook/web-components";
|
|
||||||
|
|
||||||
import "@goauthentik/common/styles/authentik.css";
|
|
||||||
// import "@goauthentik/common/styles/theme-dark.css";
|
|
||||||
import "@patternfly/patternfly/components/Brand/brand.css";
|
|
||||||
import "@patternfly/patternfly/components/Page/page.css";
|
|
||||||
// .storybook/preview.js
|
|
||||||
import "@patternfly/patternfly/patternfly-base.css";
|
|
||||||
|
|
||||||
const preview: Preview = {
|
|
||||||
parameters: {
|
|
||||||
options: {
|
|
||||||
storySort: {
|
|
||||||
method: "alphabetical",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
||||||
cssUserPrefs: {
|
|
||||||
"prefers-color-scheme": "light",
|
|
||||||
},
|
|
||||||
controls: {
|
|
||||||
matchers: {
|
|
||||||
color: /(background|color)$/i,
|
|
||||||
date: /Date$/,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default preview;
|
|
@ -1,10 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
|
* @file MDX plugin for ESBuild.
|
||||||
|
*
|
||||||
* @import {
|
* @import {
|
||||||
OnLoadArgs,
|
* OnLoadArgs,
|
||||||
OnLoadResult,
|
* OnLoadResult,
|
||||||
Plugin,
|
* Plugin,
|
||||||
PluginBuild
|
* PluginBuild
|
||||||
* } from 'esbuild'
|
* } from "esbuild"
|
||||||
*/
|
*/
|
||||||
import * as fs from "node:fs/promises";
|
import * as fs from "node:fs/promises";
|
||||||
import * as path from "node:path";
|
import * as path from "node:path";
|
29
web/bundler/utils/node.js
Normal file
29
web/bundler/utils/node.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* @file Bundler utilities.
|
||||||
|
*/
|
||||||
|
import { NodeEnvironment, serializeEnvironmentVars } from "@goauthentik/core/environment/node";
|
||||||
|
import { AuthentikVersion } from "@goauthentik/core/version/node";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a mapping of environment variables to their respective runtime constants.
|
||||||
|
*/
|
||||||
|
export function createBundleDefinitions() {
|
||||||
|
const SerializedNodeEnvironment = /** @type {`"development"` | `"production"`} */ (
|
||||||
|
JSON.stringify(NodeEnvironment)
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @satisfies {Record<ESBuildImportEnvKey, string>}
|
||||||
|
*/
|
||||||
|
const envRecord = {
|
||||||
|
AK_VERSION: AuthentikVersion,
|
||||||
|
AK_API_BASE_PATH: process.env.AK_API_BASE_PATH ?? "",
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...serializeEnvironmentVars(envRecord),
|
||||||
|
// We need to explicitly set this for NPM packages that use `process`
|
||||||
|
// to determine their environment.
|
||||||
|
"process.env.NODE_ENV": SerializedNodeEnvironment,
|
||||||
|
};
|
||||||
|
}
|
@ -12,6 +12,7 @@ export default [
|
|||||||
{
|
{
|
||||||
ignores: [
|
ignores: [
|
||||||
"dist/",
|
"dist/",
|
||||||
|
"out/",
|
||||||
// don't lint the cache
|
// don't lint the cache
|
||||||
".wireit/",
|
".wireit/",
|
||||||
// let packages have their own configurations
|
// let packages have their own configurations
|
||||||
@ -71,7 +72,7 @@ export default [
|
|||||||
...globals.node,
|
...globals.node,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
files: ["scripts/**/*.mjs", "*.ts", "*.mjs"],
|
files: ["scripts/**/*.mjs", "*.ts", "*.mjs", "**/node.js"],
|
||||||
rules: {
|
rules: {
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
// We WANT our scripts to output to the console!
|
// We WANT our scripts to output to the console!
|
||||||
|
3488
web/package-lock.json
generated
3488
web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -35,8 +35,52 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./package.json": "./package.json",
|
"./package.json": "./package.json",
|
||||||
"./paths": "./paths.js",
|
"./elements/*": "./src/elements/*",
|
||||||
"./scripts/*": "./scripts/*.mjs"
|
"./common/*": "./src/common/*",
|
||||||
|
"./components/*": "./src/components/*",
|
||||||
|
"./flow/*": "./src/flow/*",
|
||||||
|
"./locales/*": "./src/locales/*",
|
||||||
|
"./user/*": "./src/user/*",
|
||||||
|
"./admin/*": "./src/admin/*",
|
||||||
|
"./*/browser": {
|
||||||
|
"types": "./out/*/browser.d.ts",
|
||||||
|
"import": "./*/browser.js"
|
||||||
|
},
|
||||||
|
"./*/node": {
|
||||||
|
"types": "./out/*/node.d.ts",
|
||||||
|
"import": "./*/node.js"
|
||||||
|
},
|
||||||
|
"./*": {
|
||||||
|
"types": "./out/*/index.d.ts",
|
||||||
|
"import": "./*/index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imports": {
|
||||||
|
"#common/*.css": "./src/common/*.css",
|
||||||
|
"#common/*": "./src/common/*.js",
|
||||||
|
"#elements/*.css": "./src/elements/*.css",
|
||||||
|
"#elements/*": "./src/elements/*.js",
|
||||||
|
"#components/*.css": "./src/components/*.css",
|
||||||
|
"#components/*": "./src/components/*.js",
|
||||||
|
"#user/*.css": "./src/user/*.css",
|
||||||
|
"#user/*": "./src/user/*.js",
|
||||||
|
"#admin/*.css": "./src/admin/*.css",
|
||||||
|
"#admin/*": "./src/admin/*.js",
|
||||||
|
"#flow/*.css": "./src/flow/*.css",
|
||||||
|
"#flow/*": "./src/flow/*.js",
|
||||||
|
"#stories/*": "./src/stories/*.js",
|
||||||
|
"#*/browser": {
|
||||||
|
"types": "./out/*/browser.d.ts",
|
||||||
|
"import": "./*/browser.js"
|
||||||
|
},
|
||||||
|
"#*/node": {
|
||||||
|
"types": "./out/*/node.d.ts",
|
||||||
|
"import": "./*/node.js"
|
||||||
|
},
|
||||||
|
"#*": {
|
||||||
|
"types": "./out/*/index.d.ts",
|
||||||
|
"import": "./*/index.js"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/lang-css": "^6.3.1",
|
"@codemirror/lang-css": "^6.3.1",
|
||||||
@ -49,7 +93,7 @@
|
|||||||
"@floating-ui/dom": "^1.6.11",
|
"@floating-ui/dom": "^1.6.11",
|
||||||
"@formatjs/intl-listformat": "^7.5.7",
|
"@formatjs/intl-listformat": "^7.5.7",
|
||||||
"@fortawesome/fontawesome-free": "^6.6.0",
|
"@fortawesome/fontawesome-free": "^6.6.0",
|
||||||
"@goauthentik/api": "^2025.4.0-1746018955",
|
"@goauthentik/api": "^2025.4.1-1747687715",
|
||||||
"@lit/context": "^1.1.2",
|
"@lit/context": "^1.1.2",
|
||||||
"@lit/localize": "^0.12.2",
|
"@lit/localize": "^0.12.2",
|
||||||
"@lit/reactive-element": "^2.0.4",
|
"@lit/reactive-element": "^2.0.4",
|
||||||
@ -98,21 +142,21 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.11.1",
|
"@eslint/js": "^9.11.1",
|
||||||
|
"@goauthentik/core": "^1.0.0",
|
||||||
"@goauthentik/esbuild-plugin-live-reload": "^1.0.4",
|
"@goauthentik/esbuild-plugin-live-reload": "^1.0.4",
|
||||||
"@goauthentik/monorepo": "^1.0.0",
|
|
||||||
"@goauthentik/prettier-config": "^1.0.4",
|
"@goauthentik/prettier-config": "^1.0.4",
|
||||||
"@goauthentik/tsconfig": "^1.0.4",
|
"@goauthentik/tsconfig": "^1.0.4",
|
||||||
"@hcaptcha/types": "^1.0.4",
|
"@hcaptcha/types": "^1.0.4",
|
||||||
"@lit/localize-tools": "^0.8.0",
|
"@lit/localize-tools": "^0.8.0",
|
||||||
"@rollup/plugin-replace": "^6.0.1",
|
"@rollup/plugin-replace": "^6.0.1",
|
||||||
"@storybook/addon-essentials": "^8.3.4",
|
"@storybook/addon-essentials": "^8.6.14",
|
||||||
"@storybook/addon-links": "^8.3.4",
|
"@storybook/addon-links": "^8.6.12",
|
||||||
"@storybook/api": "^7.6.17",
|
"@storybook/blocks": "^8.6.12",
|
||||||
"@storybook/blocks": "^8.3.4",
|
"@storybook/experimental-addon-test": "^8.6.14",
|
||||||
"@storybook/builder-vite": "^8.3.4",
|
"@storybook/manager-api": "^8.6.14",
|
||||||
"@storybook/manager-api": "^8.3.4",
|
"@storybook/test": "^8.6.14",
|
||||||
"@storybook/web-components": "^8.3.4",
|
"@storybook/web-components": "^8.6.14",
|
||||||
"@storybook/web-components-vite": "^8.3.4",
|
"@storybook/web-components-vite": "^8.6.14",
|
||||||
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
||||||
"@types/chart.js": "^2.9.41",
|
"@types/chart.js": "^2.9.41",
|
||||||
"@types/codemirror": "^5.60.15",
|
"@types/codemirror": "^5.60.15",
|
||||||
@ -144,12 +188,11 @@
|
|||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"pseudolocale": "^2.1.0",
|
"pseudolocale": "^2.1.0",
|
||||||
"rollup-plugin-modify": "^3.0.0",
|
|
||||||
"rollup-plugin-postcss-lit": "^2.1.0",
|
"rollup-plugin-postcss-lit": "^2.1.0",
|
||||||
"storybook": "^8.3.4",
|
"storybook": "^8.6.14",
|
||||||
"storybook-addon-mock": "^5.0.0",
|
"storybook-addon-mock": "^5.0.0",
|
||||||
"turnstile-types": "^1.2.3",
|
"turnstile-types": "^1.2.3",
|
||||||
"typescript": "^5.6.2",
|
"typescript": "^5.8.3",
|
||||||
"typescript-eslint": "^8.8.0",
|
"typescript-eslint": "^8.8.0",
|
||||||
"vite-plugin-lit-css": "^2.0.0",
|
"vite-plugin-lit-css": "^2.0.0",
|
||||||
"vite-tsconfig-paths": "^5.0.1",
|
"vite-tsconfig-paths": "^5.0.1",
|
||||||
@ -376,16 +419,15 @@
|
|||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
".",
|
|
||||||
"./packages/*"
|
"./packages/*"
|
||||||
],
|
],
|
||||||
"prettier": "@goauthentik/prettier-config",
|
"prettier": "@goauthentik/prettier-config",
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"rapidoc": {
|
|
||||||
"@apitools/openapi-parser@": "0.0.37"
|
|
||||||
},
|
|
||||||
"chromedriver": {
|
"chromedriver": {
|
||||||
"axios": "^1.8.4"
|
"axios": "^1.8.4"
|
||||||
|
},
|
||||||
|
"rapidoc": {
|
||||||
|
"@apitools/openapi-parser@": "0.0.37"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# `@goauthentik/monorepo`
|
# `@goauthentik/core`
|
||||||
|
|
||||||
This package contains utility scripts common to all TypeScript and JavaScript packages in the
|
This package contains utility scripts common to all TypeScript and JavaScript packages in the
|
||||||
`@goauthentik` monorepo.
|
`@goauthentik` monorepo.
|
66
web/packages/core/environment/node.js
Normal file
66
web/packages/core/environment/node.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/**
|
||||||
|
* @file Utility functions for working with environment variables.
|
||||||
|
*/
|
||||||
|
/// <reference types="../types/node.js" />
|
||||||
|
|
||||||
|
//#region Constants
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current Node.js environment, defaulting to "development" when not set.
|
||||||
|
*
|
||||||
|
* Note, this should only be used during the build process.
|
||||||
|
*
|
||||||
|
* If you need to check the environment at runtime, use `process.env.NODE_ENV` to
|
||||||
|
* ensure that module tree-shaking works correctly.
|
||||||
|
*
|
||||||
|
* @category Environment
|
||||||
|
* @runtime node
|
||||||
|
*/
|
||||||
|
export const NodeEnvironment = process.env.NODE_ENV || "development";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A source environment variable, which can be a string, number, boolean, null, or undefined.
|
||||||
|
* @typedef {string | number | boolean | null | undefined} EnvironmentVariable
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A type helper for serializing environment variables.
|
||||||
|
*
|
||||||
|
* @category Environment
|
||||||
|
* @template {EnvironmentVariable} T
|
||||||
|
* @typedef {T extends string ? `"${T}"` : T} JSONify
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region Utilities
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an object of environment variables, serializes them into a mapping of
|
||||||
|
* environment variable names to their respective runtime constants.
|
||||||
|
*
|
||||||
|
* This is useful for defining environment variables while bundling with ESBuild, Vite, etc.
|
||||||
|
*
|
||||||
|
* @category Environment
|
||||||
|
* @runtime node
|
||||||
|
*
|
||||||
|
* @template {Record<string, EnvironmentVariable>} EnvRecord
|
||||||
|
* @template {string} [Prefix='import.meta.env.']
|
||||||
|
*
|
||||||
|
* @param {EnvRecord} input
|
||||||
|
* @param {Prefix} [prefix='import.meta.env.']
|
||||||
|
*
|
||||||
|
* @returns {{[K in keyof EnvRecord as `${Prefix}${K}`]: JSONify<EnvRecord[K]>}}
|
||||||
|
*/
|
||||||
|
export function serializeEnvironmentVars(
|
||||||
|
input,
|
||||||
|
prefix = /** @type {Prefix} */ ("import.meta.env."),
|
||||||
|
) {
|
||||||
|
const env = Object.fromEntries(
|
||||||
|
Object.entries(input).map(([key, value]) => [prefix + key, JSON.stringify(value ?? "")]),
|
||||||
|
);
|
||||||
|
|
||||||
|
return /** @type {any} */ (env);
|
||||||
|
}
|
||||||
|
|
||||||
|
//#endregion
|
12
web/packages/core/index.js
Normal file
12
web/packages/core/index.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* @file Dummy entry point for the `core` package.
|
||||||
|
*
|
||||||
|
* This exists to make TypeScript's module resolution more predictable.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
|
||||||
|
export {};
|
||||||
|
|
||||||
|
export default {};
|
59
web/packages/core/package.json
Normal file
59
web/packages/core/package.json
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
"name": "@goauthentik/core",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Core functionality for the authentik monorepo",
|
||||||
|
"license": "MIT",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc -p .",
|
||||||
|
"prettier": "prettier --write .",
|
||||||
|
"prettier-check": "prettier --check ."
|
||||||
|
},
|
||||||
|
"main": "index.js",
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
|
"./*/browser": {
|
||||||
|
"types": "./out/*/browser.d.ts",
|
||||||
|
"import": "./*/browser.js"
|
||||||
|
},
|
||||||
|
"./*/node": {
|
||||||
|
"types": "./out/*/node.d.ts",
|
||||||
|
"import": "./*/node.js"
|
||||||
|
},
|
||||||
|
"./*": {
|
||||||
|
"types": "./out/*/index.d.ts",
|
||||||
|
"import": "./*/index.js"
|
||||||
|
},
|
||||||
|
".": {
|
||||||
|
"import": "./index.js",
|
||||||
|
"types": "./out/index.d.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imports": {
|
||||||
|
"#*/browser": {
|
||||||
|
"types": "./out/*/browser.d.ts",
|
||||||
|
"import": "./*/browser.js"
|
||||||
|
},
|
||||||
|
"#*/node": {
|
||||||
|
"types": "./out/*/node.d.ts",
|
||||||
|
"import": "./*/node.js"
|
||||||
|
},
|
||||||
|
"#*": {
|
||||||
|
"types": "./out/*/index.d.ts",
|
||||||
|
"import": "./*/index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@goauthentik/prettier-config": "^1.0.4",
|
||||||
|
"@goauthentik/tsconfig": "^1.0.4",
|
||||||
|
"@types/node": "^22.14.1",
|
||||||
|
"prettier": "^3.3.3",
|
||||||
|
"typescript": "^5.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.11"
|
||||||
|
},
|
||||||
|
"types": "./out/index.d.ts",
|
||||||
|
"prettier": "@goauthentik/prettier-config"
|
||||||
|
}
|
@ -10,22 +10,26 @@ const relativeDirname = dirname(fileURLToPath(import.meta.url));
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The root of the authentik monorepo.
|
* The root of the authentik monorepo.
|
||||||
|
*
|
||||||
|
* @runtime node
|
||||||
*/
|
*/
|
||||||
// TODO: Revise when this package is moved to the monorepo's `packages/monorepo` directory.
|
|
||||||
export const MonoRepoRoot = /** @type {MonoRepoRoot} */ (
|
export const MonoRepoRoot = /** @type {MonoRepoRoot} */ (
|
||||||
resolve(relativeDirname, "..", "..", "..")
|
resolve(relativeDirname, "..", "..", "..", "..")
|
||||||
);
|
);
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve a package name to its location in the monorepo to the single node_modules directory.
|
* Resolve a package name to its location in the monorepo to the single node_modules directory.
|
||||||
* @param {string} packageName
|
|
||||||
*
|
*
|
||||||
|
* @param {string} packageName
|
||||||
|
* @param {ImportMeta} [meta] The `import.meta` object of the module.
|
||||||
|
*
|
||||||
|
* @runtime node
|
||||||
* @returns {string} The resolved path to the package.
|
* @returns {string} The resolved path to the package.
|
||||||
* @throws {Error} If the package cannot be resolved.
|
* @throws {Error} If the package cannot be resolved.
|
||||||
*/
|
*/
|
||||||
export function resolvePackage(packageName) {
|
export function resolvePackage(packageName, meta) {
|
||||||
|
const require = createRequire(meta ? meta.url : import.meta.url);
|
||||||
|
|
||||||
const relativePackageJSONPath = join(packageName, "package.json");
|
const relativePackageJSONPath = join(packageName, "package.json");
|
||||||
|
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
@ -34,7 +38,7 @@ export function resolvePackage(packageName) {
|
|||||||
try {
|
try {
|
||||||
absolutePackageJSONPath = require.resolve(relativePackageJSONPath);
|
absolutePackageJSONPath = require.resolve(relativePackageJSONPath);
|
||||||
} catch (cause) {
|
} catch (cause) {
|
||||||
const error = new Error(`Failed to resolve package "${packageName}"`);
|
const error = new Error(`🚫 Failed to resolve package "${packageName}"`);
|
||||||
|
|
||||||
error.cause = cause;
|
error.cause = cause;
|
||||||
|
|
@ -9,6 +9,7 @@ import { fileURLToPath } from "node:url";
|
|||||||
* @param {ImportMeta} meta The `import.meta` object of the module.
|
* @param {ImportMeta} meta The `import.meta` object of the module.
|
||||||
*
|
*
|
||||||
* @return {boolean} Whether the module was run directly.
|
* @return {boolean} Whether the module was run directly.
|
||||||
|
* @runtime node
|
||||||
*/
|
*/
|
||||||
export function isMain(meta) {
|
export function isMain(meta) {
|
||||||
// Are we not in a module context?
|
// Are we not in a module context?
|
@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
"extends": "@goauthentik/tsconfig",
|
"extends": "@goauthentik/tsconfig",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
|
"allowJs": true,
|
||||||
"emitDeclarationOnly": true
|
"emitDeclarationOnly": true
|
||||||
}
|
}
|
||||||
}
|
}
|
54
web/packages/core/types/node.d.ts
vendored
Normal file
54
web/packages/core/types/node.d.ts
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* @file Global variables provided by Node.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare module "module" {
|
||||||
|
global {
|
||||||
|
/**
|
||||||
|
* @deprecated This is not present in ESM files.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import { dirname } from "node:path";
|
||||||
|
* import { fileURLToPath } from "node:url";
|
||||||
|
*
|
||||||
|
* const relativeDirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line no-var
|
||||||
|
var __dirname: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module "process" {
|
||||||
|
global {
|
||||||
|
namespace NodeJS {
|
||||||
|
interface ProcessEnv {
|
||||||
|
/**
|
||||||
|
* The port used by the Docker Compose HTTP service.
|
||||||
|
*/
|
||||||
|
COMPOSE_PORT_HTTP?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The port used by the Docker Compose HTTPS service.
|
||||||
|
*/
|
||||||
|
COMPOSE_PORT_HTTPS?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An environment variable used to determine
|
||||||
|
* whether Node.js is running in production mode.
|
||||||
|
*
|
||||||
|
* @see {@link https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production | The difference between development and production}
|
||||||
|
* @runtime node
|
||||||
|
*/
|
||||||
|
readonly NODE_ENV?: "development" | "production";
|
||||||
|
/**
|
||||||
|
* @todo Determine where this is used and if it is needed,
|
||||||
|
* give it a better name.
|
||||||
|
* @deprecated
|
||||||
|
* @runtime node
|
||||||
|
*/
|
||||||
|
readonly AK_API_BASE_PATH?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
web/packages/core/version/index.js
Normal file
21
web/packages/core/version/index.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* @file Utility functions for working with semantic versions.
|
||||||
|
*
|
||||||
|
* @runtime common
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a URL to the release notes for the given version.
|
||||||
|
*
|
||||||
|
* @param {string} semver
|
||||||
|
* @returns {URL}
|
||||||
|
* @runtime common
|
||||||
|
*/
|
||||||
|
export function createReleaseNotesURL(semver) {
|
||||||
|
const segments = semver.split(".");
|
||||||
|
const versionFamily = segments.slice(0, -1).join(".");
|
||||||
|
|
||||||
|
const release = `${versionFamily}#fixed-in-${segments.join("")}`;
|
||||||
|
|
||||||
|
return new URL(`/docs/releases/${release}`, "https://goauthentik.io");
|
||||||
|
}
|
@ -1,16 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* @file Utility functions for working with semantic versions.
|
||||||
|
*
|
||||||
|
* @runtime node
|
||||||
|
*/
|
||||||
|
import { MonoRepoRoot } from "#paths/node";
|
||||||
import { execSync } from "node:child_process";
|
import { execSync } from "node:child_process";
|
||||||
|
|
||||||
import PackageJSON from "../../../package.json" with { type: "json" };
|
import PackageJSON from "../../../../package.json" with { type: "json" };
|
||||||
import { MonoRepoRoot } from "./paths.js";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current version of authentik in SemVer format.
|
* The current version of authentik in SemVer format.
|
||||||
*
|
*
|
||||||
|
* @runtime node
|
||||||
*/
|
*/
|
||||||
export const AuthentikVersion = /**@type {`${number}.${number}.${number}`} */ (PackageJSON.version);
|
export const AuthentikVersion = /**@type {`${number}.${number}.${number}`} */ (PackageJSON.version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the last commit hash from the current git repository.
|
* Reads the last commit hash from the current git repository.
|
||||||
|
*
|
||||||
|
* @runtime node
|
||||||
*/
|
*/
|
||||||
export function readGitBuildHash() {
|
export function readGitBuildHash() {
|
||||||
try {
|
try {
|
||||||
@ -34,6 +42,7 @@ export function readGitBuildHash() {
|
|||||||
*
|
*
|
||||||
* This must match the behavior defined in authentik's server-side `get_full_version` function.
|
* This must match the behavior defined in authentik's server-side `get_full_version` function.
|
||||||
*
|
*
|
||||||
|
* @runtime node
|
||||||
* @see {@link "authentik\_\_init\_\_.py"}
|
* @see {@link "authentik\_\_init\_\_.py"}
|
||||||
*/
|
*/
|
||||||
export function readBuildIdentifier() {
|
export function readBuildIdentifier() {
|
@ -21,7 +21,7 @@ const log = console.debug.bind(console, logPrefix);
|
|||||||
* ESBuild may tree-shake it out of production builds.
|
* ESBuild may tree-shake it out of production builds.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* if (process.env.NODE_ENV === "development") {
|
* if (process.env.NODE_ENV=== "development") {
|
||||||
* await import("@goauthentik/esbuild-plugin-live-reload/client")
|
* await import("@goauthentik/esbuild-plugin-live-reload/client")
|
||||||
* .catch(() => console.warn("Failed to import watcher"))
|
* .catch(() => console.warn("Failed to import watcher"))
|
||||||
* }
|
* }
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user