Skip to content

Commit

Permalink
Merge branch 'main' into web/design/update-wizard-placement
Browse files Browse the repository at this point in the history
* main: (26 commits)
  website: bump docusaurus-plugin-openapi-docs from 4.3.1 to 4.3.2 in /website (#12844)
  core: bump aws-cdk-lib from 2.176.0 to 2.177.0 (#12842)
  lifecycle/aws: bump aws-cdk from 2.176.0 to 2.177.0 in /lifecycle/aws (#12845)
  web: Fix issue where Codemirror partially applies OneDark theme. (#12811)
  ci: fix container build always attempting to push (#12810)
  lifecycle: better pre release test (#12806)
  rbac: exclude permissions for internal models (#12803)
  web: bump store2 from 2.14.3 to 2.14.4 in /web (#12805)
  website: integrations-all: update doc titles to start with "integrate with" (#12775)
  web/flows: fix `login` / `log in` inconsistency (#12526)
  flows: clear flow state before redirecting to final URL (#12788)
  core: bump goauthentik.io/api/v3 from 3.2024122.2 to 3.2024122.3 (#12793)
  core: bump kubernetes from 31.0.0 to 32.0.0 (#12794)
  core: bump pydantic from 2.10.5 to 2.10.6 (#12795)
  core: bump msgraph-sdk from 1.17.0 to 1.18.0 (#12796)
  core: bump selenium from 4.28.0 to 4.28.1 (#12797)
  core: bump ruff from 0.9.2 to 0.9.3 (#12798)
  website/integrations: Add troubleshooting part to Synology guide (#12681)
  core: fix permissions for admin device listing (#12787)
  website/docs: Flesh out Google Workspaces SAML. (#12701)
  ...
  • Loading branch information
kensternberg-authentik committed Jan 27, 2025
2 parents 8c5d384 + 5109af0 commit 38dad7c
Show file tree
Hide file tree
Showing 154 changed files with 678 additions and 249 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/_reusable-docker-build-single.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
id: push
with:
context: .
push: true
push: ${{ steps.ev.outputs.shouldPush == 'true' }}
secrets: |
GEOIPUPDATE_ACCOUNT_ID=${{ secrets.GEOIPUPDATE_ACCOUNT_ID }}
GEOIPUPDATE_LICENSE_KEY=${{ secrets.GEOIPUPDATE_LICENSE_KEY }}
Expand All @@ -89,6 +89,7 @@ jobs:
cache-to: ${{ steps.ev.outputs.cacheTo }}
- uses: actions/attest-build-provenance@v2
id: attest
if: ${{ steps.ev.outputs.shouldPush == 'true' }}
with:
subject-name: ${{ steps.ev.outputs.attestImageNames }}
subject-digest: ${{ steps.push.outputs.digest }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/_reusable-docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
- build-server-arm64
outputs:
tags: ${{ steps.ev.outputs.imageTagsJSON }}
shouldPush: ${{ steps.ev.outputs.shouldPush }}
steps:
- uses: actions/checkout@v4
- name: prepare variables
Expand All @@ -57,6 +58,7 @@ jobs:
image-name: ${{ inputs.image_name }}
merge-server:
runs-on: ubuntu-latest
if: ${{ needs.get-tags.outputs.shouldPush == 'true' }}
needs:
- get-tags
- build-server-amd64
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ jobs:
- uses: actions/checkout@v4
- name: Pre-release test
run: |
echo "PG_PASS=$(openssl rand 32 | base64 -w 0)" >> .env
echo "AUTHENTIK_SECRET_KEY=$(openssl rand 32 | base64 -w 0)" >> .env
docker buildx install
mkdir -p ./gen-ts-api
docker build -t testing:latest .
echo "AUTHENTIK_IMAGE=testing" >> .env
echo "AUTHENTIK_TAG=latest" >> .env
docker compose up --no-start
docker compose start postgresql redis
docker compose run -u root server test-all
make test-docker
- id: generate_token
uses: tibdex/github-app-token@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ RUN --mount=type=secret,id=GEOIPUPDATE_ACCOUNT_ID \
/bin/sh -c "/usr/bin/entry.sh || echo 'Failed to get GeoIP database, disabling'; exit 0"

# Stage 5: Python dependencies
FROM ghcr.io/goauthentik/fips-python:3.12.7-slim-bookworm-fips AS python-deps
FROM ghcr.io/goauthentik/fips-python:3.12.8-slim-bookworm-fips AS python-deps

ARG TARGETARCH
ARG TARGETVARIANT
Expand Down Expand Up @@ -139,7 +139,7 @@ RUN --mount=type=bind,target=./pyproject.toml,src=./pyproject.toml \
poetry install --only=main --no-ansi --no-interaction --no-root"

# Stage 6: Run
FROM ghcr.io/goauthentik/fips-python:3.12.7-slim-bookworm-fips AS final-image
FROM ghcr.io/goauthentik/fips-python:3.12.8-slim-bookworm-fips AS final-image

ARG VERSION
ARG GIT_BUILD_HASH
Expand Down
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ help: ## Show this help
go-test:
go test -timeout 0 -v -race -cover ./...

test-docker: ## Run all tests in a docker-compose
echo "PG_PASS=$(shell openssl rand 32 | base64 -w 0)" >> .env
echo "AUTHENTIK_SECRET_KEY=$(shell openssl rand 32 | base64 -w 0)" >> .env
docker compose pull -q
docker compose up --no-start
docker compose start postgresql redis
docker compose run -u root server test-all
rm -f .env

test: ## Run the server tests and produce a coverage report (locally)
coverage run manage.py test --keepdb authentik
coverage html
Expand Down Expand Up @@ -263,6 +254,9 @@ docker: ## Build a docker image of the current source tree
mkdir -p ${GEN_API_TS}
DOCKER_BUILDKIT=1 docker build . --progress plain --tag ${DOCKER_IMAGE}

test-docker:
./scripts/test_docker.sh

#########################
## CI
#########################
Expand Down
10 changes: 4 additions & 6 deletions authentik/core/api/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.utils.translation import gettext_lazy as _
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, extend_schema
from guardian.shortcuts import get_objects_for_user
from rest_framework.fields import (
BooleanField,
CharField,
Expand All @@ -16,7 +17,6 @@

from authentik.core.api.utils import MetaNameSerializer
from authentik.enterprise.stages.authenticator_endpoint_gdtc.models import EndpointDevice
from authentik.rbac.decorators import permission_required
from authentik.stages.authenticator import device_classes, devices_for_user
from authentik.stages.authenticator.models import Device
from authentik.stages.authenticator_webauthn.models import WebAuthnDevice
Expand Down Expand Up @@ -73,7 +73,9 @@ class AdminDeviceViewSet(ViewSet):
def get_devices(self, **kwargs):
"""Get all devices in all child classes"""
for model in device_classes():
device_set = model.objects.filter(**kwargs)
device_set = get_objects_for_user(
self.request.user, f"{model._meta.app_label}.view_{model._meta.model_name}", model
).filter(**kwargs)
yield from device_set

@extend_schema(
Expand All @@ -86,10 +88,6 @@ def get_devices(self, **kwargs):
],
responses={200: DeviceSerializer(many=True)},
)
@permission_required(
None,
[f"{model._meta.app_label}.view_{model._meta.model_name}" for model in device_classes()],
)
def list(self, request: Request) -> Response:
"""Get all devices for current user"""
kwargs = {}
Expand Down
9 changes: 8 additions & 1 deletion authentik/flows/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def next(self, http_request: HttpRequest | None) -> FlowStageBinding | None:

def pop(self):
"""Pop next pending stage from bottom of list"""
if not self.markers and not self.bindings:
return
self.markers.pop(0)
self.bindings.pop(0)

Expand Down Expand Up @@ -156,8 +158,13 @@ def to_redirect(
final_stage: type[StageView] = self.bindings[-1].stage.view
temp_exec = FlowExecutorView(flow=flow, request=request, plan=self)
temp_exec.current_stage = self.bindings[-1].stage
temp_exec.current_stage_view = final_stage
temp_exec.setup(request, flow.slug)
stage = final_stage(request=request, executor=temp_exec)
return stage.dispatch(request)
response = stage.dispatch(request)
# Ensure we clean the flow state we have in the session before we redirect away
temp_exec.stage_ok()
return response

get_qs = request.GET.copy()
if request.user.is_authenticated and (
Expand Down
5 changes: 3 additions & 2 deletions authentik/flows/views/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class FlowExecutorView(APIView):

permission_classes = [AllowAny]

flow: Flow
flow: Flow = None

plan: FlowPlan | None = None
current_binding: FlowStageBinding | None = None
Expand All @@ -114,7 +114,8 @@ class FlowExecutorView(APIView):

def setup(self, request: HttpRequest, flow_slug: str):
super().setup(request, flow_slug=flow_slug)
self.flow = get_object_or_404(Flow.objects.select_related(), slug=flow_slug)
if not self.flow:
self.flow = get_object_or_404(Flow.objects.select_related(), slug=flow_slug)
self._logger = get_logger().bind(flow_slug=flow_slug)
set_tag("authentik.flow", self.flow.slug)

Expand Down
3 changes: 2 additions & 1 deletion authentik/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ def get_int(self, path: str, default=0) -> int:
def get_optional_int(self, path: str, default=None) -> int | None:
"""Wrapper for get that converts value into int or None if set"""
value = self.get(path, default)

if value is UNSET:
return default
try:
return int(value)
except (ValueError, TypeError) as exc:
Expand Down
4 changes: 2 additions & 2 deletions authentik/providers/oauth2/views/authorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,11 @@ def redirect(self, uri: str) -> HttpResponse:
)

challenge.is_valid()

self.executor.stage_ok()
return HttpChallengeResponse(
challenge=challenge,
)

self.executor.stage_ok()
return HttpResponseRedirectScheme(uri, allowed_schemes=[parsed.scheme])

def post(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
Expand Down
15 changes: 8 additions & 7 deletions authentik/rbac/api/rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.apps import apps
from django.contrib.auth.models import Permission
from django.db.models import QuerySet
from django.db.models import Q, QuerySet
from django_filters.filters import ModelChoiceFilter
from django_filters.filterset import FilterSet
from django_filters.rest_framework import DjangoFilterBackend
Expand All @@ -18,6 +18,7 @@
from rest_framework.permissions import IsAuthenticated
from rest_framework.viewsets import ReadOnlyModelViewSet

from authentik.blueprints.v1.importer import excluded_models
from authentik.core.api.utils import ModelSerializer, PassiveSerializer
from authentik.core.models import User
from authentik.lib.validators import RequiredTogetherValidator
Expand Down Expand Up @@ -105,13 +106,13 @@ class RBACPermissionViewSet(ReadOnlyModelViewSet):
]

def get_queryset(self) -> QuerySet:
return (
Permission.objects.all()
.select_related("content_type")
.filter(
content_type__app_label__startswith="authentik",
query = Q()
for model in excluded_models():
query |= Q(
content_type__app_label=model._meta.app_label,
content_type__model=model._meta.model_name,
)
)
return Permission.objects.all().select_related("content_type").exclude(query)


class PermissionAssignSerializer(PassiveSerializer):
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/kerberos/api/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class KerberosSourceViewSet(UsedByMixin, ModelViewSet):
serializer_class = KerberosSourceSerializer
lookup_field = "slug"
filterset_fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/ldap/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class LDAPSourceViewSet(UsedByMixin, ModelViewSet):
serializer_class = LDAPSourceSerializer
lookup_field = "slug"
filterset_fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/oauth/api/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def filter_has_jwks(self, queryset, name, value): # pragma: no cover
class Meta:
model = OAuthSource
fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/plex/api/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class PlexSourceViewSet(UsedByMixin, ModelViewSet):
serializer_class = PlexSourceSerializer
lookup_field = "slug"
filterset_fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/saml/api/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SAMLSourceViewSet(UsedByMixin, ModelViewSet):
serializer_class = SAMLSourceSerializer
lookup_field = "slug"
filterset_fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
2 changes: 1 addition & 1 deletion authentik/sources/scim/api/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ class SCIMSourceViewSet(UsedByMixin, ModelViewSet):
queryset = SCIMSource.objects.all()
serializer_class = SCIMSourceSerializer
lookup_field = "slug"
filterset_fields = ["name", "slug"]
filterset_fields = ["pbm_uuid", "name", "slug"]
search_fields = ["name", "slug", "token__identifier", "token__user__username"]
ordering = ["name"]
4 changes: 4 additions & 0 deletions authentik/stages/prompt/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from types import MethodType
from typing import Any

from django.contrib.messages import INFO, add_message
from django.db.models.query import QuerySet
from django.http import HttpRequest, HttpResponse
from django.http.request import QueryDict
Expand Down Expand Up @@ -147,6 +148,9 @@ def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:
result = engine.result
if not result.passing:
raise ValidationError(list(result.messages))
else:
for msg in result.messages:
add_message(self.request, INFO, msg)
return attrs


Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.10.0
github.com/wwt/guac v1.3.2
goauthentik.io/api/v3 v3.2024122.2
goauthentik.io/api/v3 v3.2024122.3
golang.org/x/exp v0.0.0-20230210204819-062eb4c674ab
golang.org/x/oauth2 v0.25.0
golang.org/x/sync v0.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,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.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
goauthentik.io/api/v3 v3.2024122.2 h1:QC+ZQ+AxlPwl9OG1X/Z62EVepmTGyfvJUxhUdFjs+4s=
goauthentik.io/api/v3 v3.2024122.2/go.mod h1:zz+mEZg8rY/7eEjkMGWJ2DnGqk+zqxuybGCGrR2O4Kw=
goauthentik.io/api/v3 v3.2024122.3 h1:+cqoDpPtFLY2IkClIR3pd4zDKatEpYauA4nRYPXZ+ao=
goauthentik.io/api/v3 v3.2024122.3/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-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
4 changes: 2 additions & 2 deletions lifecycle/ak
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env -S bash -e
#!/usr/bin/env -S bash
set -e -o pipefail
MODE_FILE="${TMPDIR}/authentik-mode"

function log {
Expand Down Expand Up @@ -87,7 +88,6 @@ elif [[ "$1" == "bash" ]]; then
elif [[ "$1" == "test-all" ]]; then
prepare_debug
chmod 777 /root
pip install --force-reinstall /wheels/*
check_if_root "python -m manage test authentik"
elif [[ "$1" == "healthcheck" ]]; then
run_authentik healthcheck $(cat $MODE_FILE)
Expand Down
8 changes: 4 additions & 4 deletions lifecycle/aws/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lifecycle/aws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"node": ">=20"
},
"devDependencies": {
"aws-cdk": "^2.176.0",
"aws-cdk": "^2.177.0",
"cross-env": "^7.0.3"
}
}
Loading

0 comments on commit 38dad7c

Please sign in to comment.