@@ -260,6 +260,11 @@ def _filter_aas_submodel_references(item: Any, allow_all: bool, allowed_ids: set
260260 return filtered_item
261261
262262
263+ def _is_submodel_refs_path (path : str ) -> bool :
264+ segments = [segment for segment in path .strip ("/" ).split ("/" ) if segment ]
265+ return len (segments ) >= 3 and segments [- 3 ] == "shells" and segments [- 1 ] == "submodel-refs"
266+
267+
263268def _request_query_without_paging () -> list [tuple [str , str ]]:
264269 query_items : list [tuple [str , str ]] = []
265270 for key in request .args :
@@ -434,6 +439,25 @@ def _handle_filtered_collection(path: str, collection: dict[str, Any], access_co
434439 return jsonify (payload ), status_code
435440
436441
442+ def _handle_filtered_submodel_refs (path : str , access_control : dict [str , Any ]) -> Response :
443+ roles = _token_roles ()
444+ original_payload , items , status_code = _fetch_collection (path )
445+ request_path = "/" + path .strip ("/" )
446+ allow_all , allowed_ids = _submodel_reference_access (
447+ access_control ,
448+ roles ,
449+ request_path ,
450+ )
451+ filtered_items = [
452+ reference
453+ for reference in items
454+ if _submodel_reference_allowed (reference , allow_all , allowed_ids )
455+ ]
456+
457+ payload = _filtered_payload (original_payload , filtered_items )
458+ return jsonify (payload ), status_code
459+
460+
437461def _proxy_request (path : str , access_control : dict [str , Any ]) -> Response :
438462 upstream_response = requests .request (
439463 request .method ,
@@ -490,6 +514,17 @@ def repository_proxy(path: str) -> Response:
490514 headers = _response_headers (response ),
491515 )
492516
517+ if _is_submodel_refs_path (normalized_path ):
518+ try :
519+ return _handle_filtered_submodel_refs (path , access_control )
520+ except requests .HTTPError as exc :
521+ response = exc .response
522+ return Response (
523+ response .content ,
524+ status = response .status_code ,
525+ headers = _response_headers (response ),
526+ )
527+
493528 return _proxy_request (path , access_control )
494529
495530
0 commit comments