7696 - Make it possible to query public data without cognito auth (#176)

This commit is contained in:
Anders Gustafsson
2025-06-13 10:17:55 +02:00
committed by GitHub
parent d93ec646e2
commit 39cd0e533e
2 changed files with 18 additions and 2 deletions
+12
View File
@@ -17,6 +17,7 @@ export enum Scopes {
CATEGORIES_WRITE = 'categories.write',
MARKETS_READ = 'markets.read',
KEYWORDS_READ = 'keywords.read',
KEYWORDS_PUBLIC_READ = 'keywords.public.read',
KEYWORDS_WRITE = 'keywords.write',
LOCALES_READ = 'locales.read',
TEXTS_READ = 'texts.read',
@@ -102,6 +103,17 @@ export const ScopeAccess = (() => {
return validationObject(Object.values(Scopes));
}
if (user.userName === 'public_access_user') {
// Public access user has all public scopes
return validationObject([
Scopes.CATEGORIES_PUBLIC_READ,
Scopes.DESIGNERS_PUBLIC_READ,
Scopes.INTERIORS_PUBLIC_READ,
Scopes.PRODUCTS_PUBLIC_READ,
Scopes.KEYWORDS_PUBLIC_READ,
]);
}
// AccessToken with scopes
return validationObject(getScopes(user));
},
+6 -2
View File
@@ -221,9 +221,13 @@ const verifyAuthentication = async (req: IncomingMessage) => {
accessToken: null,
idToken: null,
};
} else {
notAuthorizedError();
}
return {
userName: 'public_access_user',
isValid: true,
accessToken: null,
idToken: null,
};
};
export { verifyToken, verifyAuthentication };