blueprints: use relative path in @apply_blueprint
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		| @ -30,7 +30,7 @@ RUN pip install --no-cache-dir poetry && \ | |||||||
|     poetry export -f requirements.txt --dev --output requirements-dev.txt |     poetry export -f requirements.txt --dev --output requirements-dev.txt | ||||||
|  |  | ||||||
| # Stage 4: Build go proxy | # Stage 4: Build go proxy | ||||||
| FROM docker.io/golang:1.19.0-bullseye AS builder | FROM docker.io/golang:1.19.0-bullseye AS go-builder | ||||||
|  |  | ||||||
| WORKDIR /work | WORKDIR /work | ||||||
|  |  | ||||||
| @ -46,7 +46,7 @@ COPY ./go.sum /work/go.sum | |||||||
| RUN go build -o /work/authentik ./cmd/server/main.go | RUN go build -o /work/authentik ./cmd/server/main.go | ||||||
|  |  | ||||||
| # Stage 5: Run | # Stage 5: Run | ||||||
| FROM docker.io/python:3.10.6-slim-bullseye | FROM docker.io/python:3.10.6-slim-bullseye AS final-image | ||||||
|  |  | ||||||
| LABEL org.opencontainers.image.url https://goauthentik.io | LABEL org.opencontainers.image.url https://goauthentik.io | ||||||
| LABEL org.opencontainers.image.description goauthentik.io Main server image, see https://goauthentik.io for more info. | LABEL org.opencontainers.image.description goauthentik.io Main server image, see https://goauthentik.io for more info. | ||||||
|  | |||||||
| @ -1,10 +1,12 @@ | |||||||
| """Blueprint helpers""" | """Blueprint helpers""" | ||||||
| from functools import wraps | from functools import wraps | ||||||
|  | from pathlib import Path | ||||||
| from typing import Callable | from typing import Callable | ||||||
|  |  | ||||||
| from django.apps import apps | from django.apps import apps | ||||||
|  |  | ||||||
| from authentik.blueprints.manager import ManagedAppConfig | from authentik.blueprints.manager import ManagedAppConfig | ||||||
|  | from authentik.lib.config import CONFIG | ||||||
|  |  | ||||||
|  |  | ||||||
| def apply_blueprint(*files: str): | def apply_blueprint(*files: str): | ||||||
| @ -17,8 +19,10 @@ def apply_blueprint(*files: str): | |||||||
|  |  | ||||||
|         @wraps(func) |         @wraps(func) | ||||||
|         def wrapper(*args, **kwargs): |         def wrapper(*args, **kwargs): | ||||||
|  |             base_path = Path(CONFIG.y("blueprints_dir")) | ||||||
|             for file in files: |             for file in files: | ||||||
|                 with open(file, "r+", encoding="utf-8") as _file: |                 full_path = Path(base_path, file) | ||||||
|  |                 with full_path.open("r", encoding="utf-8") as _file: | ||||||
|                     Importer(_file.read()).apply() |                     Importer(_file.read()).apply() | ||||||
|             return func(*args, **kwargs) |             return func(*args, **kwargs) | ||||||
|  |  | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ from authentik.tenants.models import Tenant | |||||||
| class TestBundled(TransactionTestCase): | class TestBundled(TransactionTestCase): | ||||||
|     """Empty class, test methods are added dynamically""" |     """Empty class, test methods are added dynamically""" | ||||||
|  |  | ||||||
|     @apply_blueprint("blueprints/default/90-default-tenant.yaml") |     @apply_blueprint("default/90-default-tenant.yaml") | ||||||
|     def test_decorator_static(self): |     def test_decorator_static(self): | ||||||
|         """Test @apply_blueprint decorator""" |         """Test @apply_blueprint decorator""" | ||||||
|         self.assertTrue(Tenant.objects.filter(domain="authentik-default").exists()) |         self.assertTrue(Tenant.objects.filter(domain="authentik-default").exists()) | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ from authentik.providers.oauth2.tests.utils import OAuthTestCase | |||||||
| class TestTokenClientCredentials(OAuthTestCase): | class TestTokenClientCredentials(OAuthTestCase): | ||||||
|     """Test token (client_credentials) view""" |     """Test token (client_credentials) view""" | ||||||
|  |  | ||||||
|     @apply_blueprint("blueprints/system/providers-oauth2.yaml") |     @apply_blueprint("system/providers-oauth2.yaml") | ||||||
|     def setUp(self) -> None: |     def setUp(self) -> None: | ||||||
|         super().setUp() |         super().setUp() | ||||||
|         self.factory = RequestFactory() |         self.factory = RequestFactory() | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ from authentik.sources.oauth.models import OAuthSource | |||||||
| class TestTokenClientCredentialsJWTSource(OAuthTestCase): | class TestTokenClientCredentialsJWTSource(OAuthTestCase): | ||||||
|     """Test token (client_credentials, with JWT) view""" |     """Test token (client_credentials, with JWT) view""" | ||||||
|  |  | ||||||
|     @apply_blueprint("blueprints/system/providers-oauth2.yaml") |     @apply_blueprint("system/providers-oauth2.yaml") | ||||||
|     def setUp(self) -> None: |     def setUp(self) -> None: | ||||||
|         super().setUp() |         super().setUp() | ||||||
|         self.factory = RequestFactory() |         self.factory = RequestFactory() | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ from authentik.providers.oauth2.tests.utils import OAuthTestCase | |||||||
| class TestUserinfo(OAuthTestCase): | class TestUserinfo(OAuthTestCase): | ||||||
|     """Test token view""" |     """Test token view""" | ||||||
|  |  | ||||||
|     @apply_blueprint("blueprints/system/providers-oauth2.yaml") |     @apply_blueprint("system/providers-oauth2.yaml") | ||||||
|     def setUp(self) -> None: |     def setUp(self) -> None: | ||||||
|         super().setUp() |         super().setUp() | ||||||
|         self.app = Application.objects.create(name=generate_id(), slug=generate_id()) |         self.app = Application.objects.create(name=generate_id(), slug=generate_id()) | ||||||
|  | |||||||
| @ -74,7 +74,7 @@ qNAZMq1DqpibfCBg | |||||||
| class TestAuthNRequest(TestCase): | class TestAuthNRequest(TestCase): | ||||||
|     """Test AuthN Request generator and parser""" |     """Test AuthN Request generator and parser""" | ||||||
|  |  | ||||||
|     @apply_blueprint("blueprints/system/providers-saml.yaml") |     @apply_blueprint("system/providers-saml.yaml") | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|         cert = create_test_cert() |         cert = create_test_cert() | ||||||
|         self.provider: SAMLProvider = SAMLProvider.objects.create( |         self.provider: SAMLProvider = SAMLProvider.objects.create( | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ from authentik.sources.saml.processors.request import RequestProcessor | |||||||
| class TestSchema(TestCase): | class TestSchema(TestCase): | ||||||
|     """Test Requests and Responses against schema""" |     """Test Requests and Responses against schema""" | ||||||
|  |  | ||||||
|     @apply_blueprint("blueprints/system/providers-saml.yaml") |     @apply_blueprint("system/providers-saml.yaml") | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|         cert = create_test_cert() |         cert = create_test_cert() | ||||||
|         self.provider: SAMLProvider = SAMLProvider.objects.create( |         self.provider: SAMLProvider = SAMLProvider.objects.create( | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ LDAP_PASSWORD = generate_key() | |||||||
| class LDAPSyncTests(TestCase): | class LDAPSyncTests(TestCase): | ||||||
|     """LDAP Sync tests""" |     """LDAP Sync tests""" | ||||||
|  |  | ||||||
|     @apply_blueprint("blueprints/system/sources-ldap.yaml") |     @apply_blueprint("system/sources-ldap.yaml") | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|         self.source = LDAPSource.objects.create( |         self.source = LDAPSource.objects.create( | ||||||
|             name="ldap", |             name="ldap", | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ LDAP_PASSWORD = generate_key() | |||||||
| class LDAPSyncTests(TestCase): | class LDAPSyncTests(TestCase): | ||||||
|     """LDAP Sync tests""" |     """LDAP Sync tests""" | ||||||
|  |  | ||||||
|     @apply_blueprint("blueprints/system/sources-ldap.yaml") |     @apply_blueprint("system/sources-ldap.yaml") | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|         self.source: LDAPSource = LDAPSource.objects.create( |         self.source: LDAPSource = LDAPSource.objects.create( | ||||||
|             name="ldap", |             name="ldap", | ||||||
|  | |||||||
| @ -55,7 +55,7 @@ class TestFlowsAuthenticator(SeleniumTestCase): | |||||||
|         "blueprints/default/10-flow-default-authentication-flow.yaml", |         "blueprints/default/10-flow-default-authentication-flow.yaml", | ||||||
|         "blueprints/default/10-flow-default-invalidation-flow.yaml", |         "blueprints/default/10-flow-default-invalidation-flow.yaml", | ||||||
|     ) |     ) | ||||||
|     @apply_blueprint("blueprints/default/20-flow-default-authenticator-totp-setup.yaml") |     @apply_blueprint("default/20-flow-default-authenticator-totp-setup.yaml") | ||||||
|     def test_totp_setup(self): |     def test_totp_setup(self): | ||||||
|         """test TOTP Setup stage""" |         """test TOTP Setup stage""" | ||||||
|         flow: Flow = Flow.objects.get(slug="default-authentication-flow") |         flow: Flow = Flow.objects.get(slug="default-authentication-flow") | ||||||
| @ -101,7 +101,7 @@ class TestFlowsAuthenticator(SeleniumTestCase): | |||||||
|         "blueprints/default/10-flow-default-authentication-flow.yaml", |         "blueprints/default/10-flow-default-authentication-flow.yaml", | ||||||
|         "blueprints/default/10-flow-default-invalidation-flow.yaml", |         "blueprints/default/10-flow-default-invalidation-flow.yaml", | ||||||
|     ) |     ) | ||||||
|     @apply_blueprint("blueprints/default/20-flow-default-authenticator-static-setup.yaml") |     @apply_blueprint("default/20-flow-default-authenticator-static-setup.yaml") | ||||||
|     def test_static_setup(self): |     def test_static_setup(self): | ||||||
|         """test Static OTP Setup stage""" |         """test Static OTP Setup stage""" | ||||||
|         flow: Flow = Flow.objects.get(slug="default-authentication-flow") |         flow: Flow = Flow.objects.get(slug="default-authentication-flow") | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ class TestFlowsStageSetup(SeleniumTestCase): | |||||||
|     """test stage setup flows""" |     """test stage setup flows""" | ||||||
|  |  | ||||||
|     @retry() |     @retry() | ||||||
|     @apply_blueprint("blueprints/default/0-flow-password-change.yaml") |     @apply_blueprint("default/0-flow-password-change.yaml") | ||||||
|     @apply_blueprint( |     @apply_blueprint( | ||||||
|         "blueprints/default/10-flow-default-authentication-flow.yaml", |         "blueprints/default/10-flow-default-authentication-flow.yaml", | ||||||
|         "blueprints/default/10-flow-default-invalidation-flow.yaml", |         "blueprints/default/10-flow-default-invalidation-flow.yaml", | ||||||
|  | |||||||
| @ -120,7 +120,7 @@ class TestProviderOAuth2OIDC(SeleniumTestCase): | |||||||
|         "blueprints/default/20-flow-default-provider-authorization-implicit-consent.yaml", |         "blueprints/default/20-flow-default-provider-authorization-implicit-consent.yaml", | ||||||
|     ) |     ) | ||||||
|     @reconcile_app("authentik_crypto") |     @reconcile_app("authentik_crypto") | ||||||
|     @apply_blueprint("blueprints/system/providers-oauth2.yaml") |     @apply_blueprint("system/providers-oauth2.yaml") | ||||||
|     def test_authorization_consent_implied(self): |     def test_authorization_consent_implied(self): | ||||||
|         """test OpenID Provider flow (default authorization flow with implied consent)""" |         """test OpenID Provider flow (default authorization flow with implied consent)""" | ||||||
|         sleep(1) |         sleep(1) | ||||||
| @ -175,7 +175,7 @@ class TestProviderOAuth2OIDC(SeleniumTestCase): | |||||||
|         "blueprints/default/20-flow-default-provider-authorization-implicit-consent.yaml", |         "blueprints/default/20-flow-default-provider-authorization-implicit-consent.yaml", | ||||||
|     ) |     ) | ||||||
|     @reconcile_app("authentik_crypto") |     @reconcile_app("authentik_crypto") | ||||||
|     @apply_blueprint("blueprints/system/providers-oauth2.yaml") |     @apply_blueprint("system/providers-oauth2.yaml") | ||||||
|     def test_authorization_consent_explicit(self): |     def test_authorization_consent_explicit(self): | ||||||
|         """test OpenID Provider flow (default authorization flow with explicit consent)""" |         """test OpenID Provider flow (default authorization flow with explicit consent)""" | ||||||
|         sleep(1) |         sleep(1) | ||||||
|  | |||||||
| @ -120,7 +120,7 @@ class TestProviderOAuth2OIDCImplicit(SeleniumTestCase): | |||||||
|         "blueprints/default/20-flow-default-provider-authorization-implicit-consent.yaml", |         "blueprints/default/20-flow-default-provider-authorization-implicit-consent.yaml", | ||||||
|     ) |     ) | ||||||
|     @reconcile_app("authentik_crypto") |     @reconcile_app("authentik_crypto") | ||||||
|     @apply_blueprint("blueprints/system/providers-oauth2.yaml") |     @apply_blueprint("system/providers-oauth2.yaml") | ||||||
|     def test_authorization_consent_implied(self): |     def test_authorization_consent_implied(self): | ||||||
|         """test OpenID Provider flow (default authorization flow with implied consent)""" |         """test OpenID Provider flow (default authorization flow with implied consent)""" | ||||||
|         sleep(1) |         sleep(1) | ||||||
| @ -170,7 +170,7 @@ class TestProviderOAuth2OIDCImplicit(SeleniumTestCase): | |||||||
|         "blueprints/default/20-flow-default-provider-authorization-implicit-consent.yaml", |         "blueprints/default/20-flow-default-provider-authorization-implicit-consent.yaml", | ||||||
|     ) |     ) | ||||||
|     @reconcile_app("authentik_crypto") |     @reconcile_app("authentik_crypto") | ||||||
|     @apply_blueprint("blueprints/system/providers-oauth2.yaml") |     @apply_blueprint("system/providers-oauth2.yaml") | ||||||
|     def test_authorization_consent_explicit(self): |     def test_authorization_consent_explicit(self): | ||||||
|         """test OpenID Provider flow (default authorization flow with explicit consent)""" |         """test OpenID Provider flow (default authorization flow with explicit consent)""" | ||||||
|         sleep(1) |         sleep(1) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer