You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 22, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 22, 2023. It is now read-only.
However, due to ordering of the policies, if the session is expired, the produced error reason is AccessKeyNotAccepted, instead of the expected reason NotAuthenticated. Client SDK would not refresh the session automatically and breaks the session.
To fix it, the order should be changed so that NotAuthenticated would be produced.
I still do not understand why this happened. If we treat the anyOf and allOf having short circuit behavior.
The boolean expression of the above policy is MasterKey || (API Key && ValidSession).
If it is Master Key, then it passes.
Otherwise if it is not API Key, then it fails with invalid API Key.
Otherwise if it is valid session, then it passes.
Otherwise if it is invalid session, then it fails with invalid session.
The problem is that it's not a simple true/false checks; it returns an error.
SDK refresh session only if error has reason NotAuthenticated, which is produced by RequireValidUser policy. In expired session case, the compound policy got both AccessKeyNotAccepted and NotAuthenticated errors, and return first error (i.e. AccessKeyNotAccepted). This breaks the SDK refreshing behavior.
I guess the AccessKeyNotAccepted error is produced by RequireMasterKey, am I correct?
In JavaScript, false || 0 evaluates to 0. Following the short circuit behavior, MasterKey || (API Key && ValidSession) should return the error of ValidSession
I guess the AccessKeyNotAccepted error is produced by RequireMasterKey, am I correct?
Yes.
In JavaScript, false || 0 evaluates to 0. Following the short circuit behavior, MasterKey || (API Key && ValidSession) should return the error of ValidSession
Suppose errors are falsy values. In case of expired session, MasterKey() returns error AccessKeyNotAccepted, APIKey() returns ok (i.e. truthy value), and ValidSession() returns error NotAuthenticated. Then, MasterKey() || (APIKey() && ValidSession()) returns NotAuthenticated. Therefore, we should change AnyOf to return last error, instead of first error. Do you mean this?
Activity
louischan-oursky commentedon Feb 26, 2020
I still do not understand why this happened. If we treat the anyOf and allOf having short circuit behavior.
The boolean expression of the above policy is
MasterKey || (API Key && ValidSession).If it is Master Key, then it passes.
Otherwise if it is not API Key, then it fails with invalid API Key.
Otherwise if it is valid session, then it passes.
Otherwise if it is invalid session, then it fails with invalid session.
kiootic commentedon Feb 26, 2020
The problem is that it's not a simple true/false checks; it returns an error.
SDK refresh session only if error has reason
NotAuthenticated, which is produced byRequireValidUserpolicy. In expired session case, the compound policy got bothAccessKeyNotAcceptedandNotAuthenticatederrors, and return first error (i.e.AccessKeyNotAccepted). This breaks the SDK refreshing behavior.louischan-oursky commentedon Feb 26, 2020
I guess the
AccessKeyNotAcceptederror is produced byRequireMasterKey, am I correct?In JavaScript,
false || 0evaluates to 0. Following the short circuit behavior,MasterKey || (API Key && ValidSession)should return the error ofValidSessionkiootic commentedon Feb 26, 2020
Yes.
Suppose errors are falsy values. In case of expired session,
MasterKey()returns errorAccessKeyNotAccepted,APIKey()returns ok (i.e. truthy value), andValidSession()returns errorNotAuthenticated. Then,MasterKey() || (APIKey() && ValidSession())returnsNotAuthenticated. Therefore, we should changeAnyOfto return last error, instead of first error. Do you mean this?louischan-oursky commentedon Feb 26, 2020
Yes. AnyOf should return the last error.
louischan-oursky commentedon Feb 26, 2020
Since the behavior of AnyOf is changed, please check if any existing code is relying on the old behavior (returning the first error)
kiootic commentedon Feb 26, 2020
The only API that uses
AnyOfis this case, so there is no problem.Fix compound authz policy short-circuit behavior