fix: Check for star actor types when allowing unregistered access (#9037)
This commit is contained in:
1 parent
95a3ac045d
commit
f32091f702
1 file changed
+10
-7
@@ -91,7 +91,7 @@ export const authenticate = (
|
|||||||
if (
|
if (
|
||||||
authContext?.auth_identity_id &&
|
authContext?.auth_identity_id &&
|
||||||
options.allowUnregistered &&
|
options.allowUnregistered &&
|
||||||
actorTypes.includes(authContext?.actor_type)
|
isActorTypePermitted(actorTypes, authContext.actor_type)
|
||||||
) {
|
) {
|
||||||
req_.auth_context = authContext
|
req_.auth_context = authContext
|
||||||
return next()
|
return next()
|
||||||
@@ -162,8 +162,7 @@ const getAuthContextFromSession = (
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
session.auth_context &&
|
session.auth_context &&
|
||||||
(actorTypes.includes("*") ||
|
isActorTypePermitted(actorTypes, session.auth_context?.actor_type)
|
||||||
actorTypes.includes(session.auth_context.actor_type))
|
|
||||||
) {
|
) {
|
||||||
return session.auth_context
|
return session.auth_context
|
||||||
}
|
}
|
||||||
@@ -197,10 +196,7 @@ const getAuthContextFromJwtToken = (
|
|||||||
// verify token and set authUser
|
// verify token and set authUser
|
||||||
try {
|
try {
|
||||||
const verified = verify(token, jwtSecret) as JwtPayload
|
const verified = verify(token, jwtSecret) as JwtPayload
|
||||||
if (
|
if (isActorTypePermitted(actorTypes, verified.actor_type)) {
|
||||||
actorTypes.includes("*") ||
|
|
||||||
actorTypes.includes(verified.actor_type)
|
|
||||||
) {
|
|
||||||
return verified as AuthContext
|
return verified as AuthContext
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -211,3 +207,10 @@ const getAuthContextFromJwtToken = (
|
|||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isActorTypePermitted = (
|
||||||
|
actorTypes: string | string[],
|
||||||
|
currentActorType: string
|
||||||
|
) => {
|
||||||
|
return actorTypes.includes("*") || actorTypes.includes(currentActorType)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user