blueprints: add meta models to schema (#5611)

these models were previously ignored

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-05-15 14:39:48 +02:00 committed by GitHub
parent 47f09ac285
commit c3398004ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 9 deletions

View File

@ -10,7 +10,7 @@ from rest_framework.serializers import Serializer
from structlog.stdlib import get_logger
from authentik.blueprints.v1.importer import SERIALIZER_CONTEXT_BLUEPRINT, is_model_allowed
from authentik.blueprints.v1.meta.registry import registry
from authentik.blueprints.v1.meta.registry import BaseMetaModel, registry
from authentik.lib.models import SerializerModel
LOGGER = get_logger()
@ -74,6 +74,9 @@ class Command(BaseCommand):
def build(self):
"""Build all models into the schema"""
for model in registry.get_models():
if issubclass(model, BaseMetaModel):
serializer_class = model.serializer()
else:
if model._meta.abstract:
continue
if not is_model_allowed(model):
@ -81,7 +84,8 @@ class Command(BaseCommand):
model_instance: Model = model()
if not isinstance(model_instance, SerializerModel):
continue
serializer = model_instance.serializer(
serializer_class = model_instance.serializer
serializer = serializer_class(
context={
SERIALIZER_CONTEXT_BLUEPRINT: False,
}

View File

@ -2560,6 +2560,42 @@
"$ref": "#/$defs/model_authentik_core.token"
}
}
},
{
"type": "object",
"required": [
"model",
"identifiers"
],
"properties": {
"model": {
"const": "authentik_blueprints.metaapplyblueprint"
},
"id": {
"type": "string"
},
"state": {
"type": "string",
"enum": [
"absent",
"present",
"created"
],
"default": "present"
},
"conditions": {
"type": "array",
"items": {
"type": "boolean"
}
},
"attrs": {
"$ref": "#/$defs/model_authentik_blueprints.metaapplyblueprint"
},
"identifiers": {
"$ref": "#/$defs/model_authentik_blueprints.metaapplyblueprint"
}
}
}
]
}
@ -8314,6 +8350,21 @@
}
},
"required": []
},
"model_authentik_blueprints.metaapplyblueprint": {
"type": "object",
"properties": {
"identifiers": {
"type": "object",
"additionalProperties": true,
"title": "Identifiers"
},
"required": {
"type": "boolean",
"title": "Required"
}
},
"required": []
}
}
}