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:
parent
47f09ac285
commit
c3398004ff
|
@ -10,7 +10,7 @@ from rest_framework.serializers import Serializer
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.blueprints.v1.importer import SERIALIZER_CONTEXT_BLUEPRINT, is_model_allowed
|
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
|
from authentik.lib.models import SerializerModel
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
|
@ -74,6 +74,9 @@ class Command(BaseCommand):
|
||||||
def build(self):
|
def build(self):
|
||||||
"""Build all models into the schema"""
|
"""Build all models into the schema"""
|
||||||
for model in registry.get_models():
|
for model in registry.get_models():
|
||||||
|
if issubclass(model, BaseMetaModel):
|
||||||
|
serializer_class = model.serializer()
|
||||||
|
else:
|
||||||
if model._meta.abstract:
|
if model._meta.abstract:
|
||||||
continue
|
continue
|
||||||
if not is_model_allowed(model):
|
if not is_model_allowed(model):
|
||||||
|
@ -81,7 +84,8 @@ class Command(BaseCommand):
|
||||||
model_instance: Model = model()
|
model_instance: Model = model()
|
||||||
if not isinstance(model_instance, SerializerModel):
|
if not isinstance(model_instance, SerializerModel):
|
||||||
continue
|
continue
|
||||||
serializer = model_instance.serializer(
|
serializer_class = model_instance.serializer
|
||||||
|
serializer = serializer_class(
|
||||||
context={
|
context={
|
||||||
SERIALIZER_CONTEXT_BLUEPRINT: False,
|
SERIALIZER_CONTEXT_BLUEPRINT: False,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2560,6 +2560,42 @@
|
||||||
"$ref": "#/$defs/model_authentik_core.token"
|
"$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": []
|
"required": []
|
||||||
|
},
|
||||||
|
"model_authentik_blueprints.metaapplyblueprint": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"identifiers": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": true,
|
||||||
|
"title": "Identifiers"
|
||||||
|
},
|
||||||
|
"required": {
|
||||||
|
"type": "boolean",
|
||||||
|
"title": "Required"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue