[wip] a2 agent: preconfigure SAML SP authn (#80164)
gitea/hobo/pipeline/head This commit looks good Details

This commit is contained in:
Paul Marillonnet 2023-07-31 15:27:59 +02:00
parent 75a466672c
commit e407832d28
2 changed files with 15 additions and 0 deletions

View File

@ -36,6 +36,8 @@ class Command(hobo_deploy.Command):
def deploy_specifics(self, hobo_environment, tenant):
# generate SAML keys
self.generate_saml_keys(tenant)
# pre-configure Publik as a SAML service provider
self.generate_saml_keys(tenant, prefix='sp-')
self.configure_theme(hobo_environment, tenant)
with tenant_context(tenant):

View File

@ -8,11 +8,13 @@ from unittest import mock
import pytest
from authentic2.a2_rbac.models import OrganizationalUnit, Role
from authentic2.data_transfer import export_site
from django.conf import UserSettingsHolder
from django.core.management import call_command
from django.db import connection
from requests import RequestException
from hobo.multitenant.middleware import TenantMiddleware
from hobo.multitenant.settings_loaders import Mellon
os.sys.path.append('%s/tests' % os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@ -372,6 +374,17 @@ def test_hobo_deploy(monkeypatch, tenant_base, mocker, skeleton_dir, tmp_path):
assert os.path.exists(os.path.join(tenant_directory, 'saml.crt'))
assert os.path.exists(os.path.join(tenant_directory, 'saml.key'))
# check SAML SP preconfiguratino
assert os.path.exists(os.path.join(tenant_directory, 'sp-saml.crt'))
assert os.path.exists(os.path.join(tenant_directory, 'sp-saml.key'))
tenant_settings = UserSettingsHolder({})
loader = Mellon()
loader.update_settings(tenant_settings, tenant)
assert tenant_settings.MELLON_PUBLIC_KEYS == [os.path.join(tenant_directory, 'sp-saml.crt')]
assert tenant_settings.MELLON_PRIVATE_KEY == os.path.join(tenant_directory, 'sp-saml.key')
from tenant_schemas.utils import tenant_context
with tenant_context(tenant):