streamby-core 0.24.5 → 0.24.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -158,15 +158,25 @@ function exportRouter(config) {
|
|
|
158
158
|
}
|
|
159
159
|
const origin = req.headers.origin;
|
|
160
160
|
let effectiveAllowedOrigins = exportMetadata.allowedOrigin;
|
|
161
|
-
|
|
161
|
+
const projectOrigins = project.allowedOrigin;
|
|
162
|
+
// If export's allowedOrigin is ['*'] or it's not set, it inherits from the project.
|
|
162
163
|
if (!effectiveAllowedOrigins || (effectiveAllowedOrigins.length === 1 && effectiveAllowedOrigins[0] === '*')) {
|
|
163
|
-
effectiveAllowedOrigins =
|
|
164
|
+
effectiveAllowedOrigins = projectOrigins;
|
|
164
165
|
}
|
|
165
|
-
|
|
166
|
+
else {
|
|
167
|
+
// If the export has its own list, ensure it's a subset of the project's list (if project is not public).
|
|
168
|
+
if (projectOrigins && !projectOrigins.includes('*')) {
|
|
169
|
+
const isSubset = effectiveAllowedOrigins.every((o) => projectOrigins.includes(o));
|
|
170
|
+
if (!isSubset) {
|
|
171
|
+
return res.status(403).json({ message: 'Unauthorized: Export origins are not allowed by the parent project.' });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// If there's no origin header, deny access unless the effective scope is public.
|
|
166
176
|
if (!origin && !(effectiveAllowedOrigins && effectiveAllowedOrigins.includes('*'))) {
|
|
167
177
|
return res.status(403).json({ message: 'Origin header required' });
|
|
168
178
|
}
|
|
169
|
-
// Check for public access ('*') or if the origin is in the list.
|
|
179
|
+
// Check for public access ('*') or if the request's origin is in the effective list.
|
|
170
180
|
const isAllowed = effectiveAllowedOrigins && (effectiveAllowedOrigins.includes('*') || (origin && effectiveAllowedOrigins.includes(origin)));
|
|
171
181
|
if (!isAllowed) {
|
|
172
182
|
return res.status(403).json({ message: 'Unauthorized' });
|