|
| 1 | +import itertools |
1 | 2 | import json |
2 | 3 | import logging |
3 | 4 | import traceback |
@@ -54,63 +55,66 @@ def __init__(self, backend: Backend): |
54 | 55 | self.log = logging.getLogger("SCIMProvider") |
55 | 56 |
|
56 | 57 | # Register the URL mapping. The endpoint refers to the name of the function to be called in this SCIMProvider ("call_" + endpoint). |
57 | | - self.url_map = Map( |
| 58 | + rules = itertools.chain.from_iterable( |
58 | 59 | [ |
59 | 60 | Rule( |
60 | | - "/v2/ServiceProviderConfig", |
| 61 | + f"{prefix}/ServiceProviderConfig", |
61 | 62 | endpoint="service_provider_config", |
62 | 63 | methods=("GET",), |
63 | 64 | ), |
64 | 65 | Rule( |
65 | | - "/v2/ResourceTypes", |
| 66 | + f"{prefix}/ResourceTypes", |
66 | 67 | endpoint="resource_types", |
67 | 68 | methods=("GET",), |
68 | 69 | ), |
69 | 70 | Rule( |
70 | | - "/v2/ResourceTypes/<string:resource_type>", |
| 71 | + f"{prefix}/ResourceTypes/<string:resource_type>", |
71 | 72 | endpoint="resource_type", |
72 | 73 | methods=("GET",), |
73 | 74 | ), |
74 | 75 | Rule( |
75 | | - "/v2/Schemas", |
| 76 | + f"{prefix}/Schemas", |
76 | 77 | endpoint="schemas", |
77 | 78 | methods=("GET",), |
78 | 79 | ), |
79 | 80 | Rule( |
80 | | - "/v2/Schemas/<string:schema_id>", |
| 81 | + f"{prefix}/Schemas/<string:schema_id>", |
81 | 82 | endpoint="schema", |
82 | 83 | methods=("GET",), |
83 | 84 | ), |
84 | 85 | Rule( |
85 | | - "/v2/Me", |
| 86 | + f"{prefix}/Me", |
86 | 87 | endpoint="me", |
87 | 88 | methods=("GET", "POST", "PUT", "PATCH", "DELETE"), |
88 | 89 | ), |
89 | 90 | Rule( |
90 | | - "/v2/<string:resource_endpoint>", |
| 91 | + f"{prefix}/<string:resource_endpoint>", |
91 | 92 | endpoint="resource", |
92 | 93 | methods=("GET", "POST"), |
93 | 94 | ), |
94 | 95 | Rule( |
95 | | - "/v2/<string:resource_endpoint>/.search", |
| 96 | + f"{prefix}/<string:resource_endpoint>/.search", |
96 | 97 | endpoint="resource_search", |
97 | 98 | methods=("POST",), |
98 | 99 | ), |
99 | 100 | Rule( |
100 | | - "/v2/<string:resource_endpoint>/<string:resource_id>", |
| 101 | + f"{prefix}/<string:resource_endpoint>/<string:resource_id>", |
101 | 102 | endpoint="single_resource", |
102 | 103 | methods=("GET", "PUT", "PATCH", "DELETE"), |
103 | 104 | ), |
104 | 105 | Rule( |
105 | | - "/v2/Bulk", |
| 106 | + f"{prefix}/Bulk", |
106 | 107 | endpoint="bulk", |
107 | 108 | methods=("POST",), |
108 | 109 | ), |
109 | | - Rule("/v2/", endpoint="query_all", methods=("GET",)), |
110 | | - Rule("/v2/.search", endpoint="query_all", methods=("POST",)), |
| 110 | + Rule(f"{prefix}/", endpoint="query_all", methods=("GET",)), |
| 111 | + Rule(f"{prefix}/.search", endpoint="query_all", methods=("POST",)), |
111 | 112 | ] |
| 113 | + for prefix in ("", "/v2") |
112 | 114 | ) |
113 | 115 |
|
| 116 | + self.url_map = Map(rules) |
| 117 | + |
114 | 118 | @staticmethod |
115 | 119 | def adjust_location( |
116 | 120 | request: Request, resource: Resource, cp=False |
|
0 commit comments