!1134 any app auth result reuse

Merge pull request !1134 from 陈伟健/master
This commit is contained in:
openharmony_ci 2024-11-21 06:07:36 +00:00 committed by Gitee
commit 044fbd29eb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 22 additions and 2 deletions

View File

@ -897,11 +897,21 @@ napi_value ReuseModeConstructor(napi_env env)
napi_value reuseMode = nullptr;
napi_value auth_type_relevant = nullptr;
napi_value auth_type_irrelevant = nullptr;
napi_value caller_irrelevant_auth_type_relevant = nullptr;
napi_value caller_irrelevant_auth_type_irrelevant = nullptr;
NAPI_CALL(env, napi_create_object(env, &reuseMode));
NAPI_CALL(env, napi_create_int32(env, ReuseMode::AUTH_TYPE_RELEVANT, &auth_type_relevant));
NAPI_CALL(env, napi_create_int32(env, ReuseMode::AUTH_TYPE_IRRELEVANT, &auth_type_irrelevant));
NAPI_CALL(env, napi_create_int32(
env, ReuseMode::CALLER_IRRELEVANT_AUTH_TYPE_RELEVANT, &caller_irrelevant_auth_type_relevant));
NAPI_CALL(env, napi_create_int32(
env, ReuseMode::CALLER_IRRELEVANT_AUTH_TYPE_IRRELEVANT, &caller_irrelevant_auth_type_irrelevant));
NAPI_CALL(env, napi_set_named_property(env, reuseMode, "AUTH_TYPE_RELEVANT", auth_type_relevant));
NAPI_CALL(env, napi_set_named_property(env, reuseMode, "AUTH_TYPE_IRRELEVANT", auth_type_irrelevant));
NAPI_CALL(env, napi_set_named_property(
env, reuseMode, "CALLER_IRRELEVANT_AUTH_TYPE_RELEVANT", caller_irrelevant_auth_type_relevant));
NAPI_CALL(env, napi_set_named_property(
env, reuseMode, "CALLER_IRRELEVANT_AUTH_TYPE_IRRELEVANT", caller_irrelevant_auth_type_irrelevant));
return reuseMode;
}

View File

@ -618,7 +618,9 @@ bool UserAuthNapiHelper::CheckAuthTrustLevel(uint32_t authTrustLevel)
bool UserAuthNapiHelper::CheckReuseUnlockResult(ReuseUnlockResult reuseUnlockResult)
{
if (reuseUnlockResult.reuseMode != ReuseMode::AUTH_TYPE_RELEVANT &&
reuseUnlockResult.reuseMode != ReuseMode::AUTH_TYPE_IRRELEVANT) {
reuseUnlockResult.reuseMode != ReuseMode::AUTH_TYPE_IRRELEVANT &&
reuseUnlockResult.reuseMode != ReuseMode::CALLER_IRRELEVANT_AUTH_TYPE_RELEVANT &&
reuseUnlockResult.reuseMode != ReuseMode::CALLER_IRRELEVANT_AUTH_TYPE_IRRELEVANT) {
IAM_LOGE("reuseMode check fail:%{public}u", reuseUnlockResult.reuseMode);
return false;
}

View File

@ -86,6 +86,12 @@ enum ReuseMode : uint32_t {
/** Authentication type irrelevant.The unlock authentication result can be reused as long as the result is within
* valid duration. */
AUTH_TYPE_IRRELEVANT = 2,
/** Caller irrelevant authentication type relevant.The unlock authentication result can be reused only when the
* result is within valid duration as well as it comes from one of specified UserAuthTypes of the AuthParam. */
CALLER_IRRELEVANT_AUTH_TYPE_RELEVANT = 3,
/** Caller irrelevant authentication type irrelevant.The unlock authentication result can be reused as long as the
* result is within valid duration. */
CALLER_IRRELEVANT_AUTH_TYPE_IRRELEVANT = 4,
};
/**

View File

@ -191,7 +191,9 @@ int32_t AuthWidgetHelper::CheckReuseUnlockResult(const ContextFactory::AuthWidge
if (!authParam.reuseUnlockResult.isReuse || authParam.reuseUnlockResult.reuseDuration == 0 ||
authParam.reuseUnlockResult.reuseDuration > MAX_ALLOWABLE_REUSE_DURATION ||
(authParam.reuseUnlockResult.reuseMode != AUTH_TYPE_RELEVANT &&
authParam.reuseUnlockResult.reuseMode != AUTH_TYPE_IRRELEVANT)) {
authParam.reuseUnlockResult.reuseMode != AUTH_TYPE_IRRELEVANT &&
authParam.reuseUnlockResult.reuseMode != CALLER_IRRELEVANT_AUTH_TYPE_RELEVANT &&
authParam.reuseUnlockResult.reuseMode != CALLER_IRRELEVANT_AUTH_TYPE_IRRELEVANT)) {
IAM_LOGE("CheckReuseUnlockResult invalid param");
return INVALID_PARAMETERS;
}