blueprints: handle model referencing non-existent app/model (#10796)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -328,7 +328,10 @@ class Find(YAMLTag):
|
|||||||
else:
|
else:
|
||||||
model_name = self.model_name
|
model_name = self.model_name
|
||||||
|
|
||||||
model_class = apps.get_model(*model_name.split("."))
|
try:
|
||||||
|
model_class = apps.get_model(*model_name.split("."))
|
||||||
|
except LookupError as exc:
|
||||||
|
raise EntryInvalidError.from_entry(exc, entry) from exc
|
||||||
|
|
||||||
query = Q()
|
query = Q()
|
||||||
for cond in self.conditions:
|
for cond in self.conditions:
|
||||||
|
|||||||
@ -231,14 +231,17 @@ class Importer:
|
|||||||
|
|
||||||
return main_query | sub_query
|
return main_query | sub_query
|
||||||
|
|
||||||
def _validate_single(self, entry: BlueprintEntry) -> BaseSerializer | None:
|
def _validate_single(self, entry: BlueprintEntry) -> BaseSerializer | None: # noqa: PLR0915
|
||||||
"""Validate a single entry"""
|
"""Validate a single entry"""
|
||||||
if not entry.check_all_conditions_match(self._import):
|
if not entry.check_all_conditions_match(self._import):
|
||||||
self.logger.debug("One or more conditions of this entry are not fulfilled, skipping")
|
self.logger.debug("One or more conditions of this entry are not fulfilled, skipping")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
model_app_label, model_name = entry.get_model(self._import).split(".")
|
model_app_label, model_name = entry.get_model(self._import).split(".")
|
||||||
model: type[SerializerModel] = registry.get_model(model_app_label, model_name)
|
try:
|
||||||
|
model: type[SerializerModel] = registry.get_model(model_app_label, model_name)
|
||||||
|
except LookupError as exc:
|
||||||
|
raise EntryInvalidError.from_entry(exc, entry) from exc
|
||||||
# Don't use isinstance since we don't want to check for inheritance
|
# Don't use isinstance since we don't want to check for inheritance
|
||||||
if not is_model_allowed(model):
|
if not is_model_allowed(model):
|
||||||
raise EntryInvalidError.from_entry(f"Model {model} not allowed", entry)
|
raise EntryInvalidError.from_entry(f"Model {model} not allowed", entry)
|
||||||
@ -313,10 +316,7 @@ class Importer:
|
|||||||
try:
|
try:
|
||||||
full_data = self.__update_pks_for_attrs(entry.get_attrs(self._import))
|
full_data = self.__update_pks_for_attrs(entry.get_attrs(self._import))
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise EntryInvalidError.from_entry(
|
raise EntryInvalidError.from_entry(exc, entry) from exc
|
||||||
exc,
|
|
||||||
entry,
|
|
||||||
) from exc
|
|
||||||
always_merger.merge(full_data, updated_identifiers)
|
always_merger.merge(full_data, updated_identifiers)
|
||||||
serializer_kwargs["data"] = full_data
|
serializer_kwargs["data"] = full_data
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,7 @@ class RadiusProvider(OutpostModel, Provider):
|
|||||||
|
|
||||||
|
|
||||||
class RadiusProviderPropertyMapping(PropertyMapping):
|
class RadiusProviderPropertyMapping(PropertyMapping):
|
||||||
|
"""Add additional attributes to Radius authentication responses."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def component(self) -> str:
|
def component(self) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user