Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/generics/constants/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ module.exports = {
KEYCLOAK_PUBLIC_KEY: 'keycloak_public_key',
},
ENGLISH_LANGUGE_CODE: 'en',
GUEST_URLS: ['/entities/details'],
}
18 changes: 18 additions & 0 deletions src/generics/middleware/authenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ module.exports = async function (req, res, next, token = '') {

token = req.headers['x-auth-token']

// Allow endpoints for non-logged in users.
let guestAccess = false
let guestAccessPaths = CONSTANTS.common.GUEST_URLS
// Check if the request path matches any of the guest access paths
// If it does, set guestAccess to true
await Promise.all(
guestAccessPaths.map(async function (path) {
if (req.path.includes(path)) {
guestAccess = true
}
})
)

if (guestAccess == true && !token) {
next()
return
}

let internalAccessApiPaths = CONSTANTS.common.INTERNAL_ACCESS_URLS
let performInternalAccessTokenCheck = false
await Promise.all(
Expand Down