enh: add authVersion for user privilege
This commit is contained in:
parent
3009df865b
commit
384fed49f9
|
@ -106,6 +106,7 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
|
||||||
SDB_SET_INT64(pRaw, dataPos, pUser->createdTime, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pUser->createdTime, _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pUser->updateTime, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pUser->updateTime, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pUser->superUser, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pUser->superUser, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pUser->authVersion, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, numOfReadDbs, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, numOfReadDbs, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, numOfWriteDbs, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, numOfWriteDbs, _OVER)
|
||||||
|
|
||||||
|
@ -161,6 +162,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pUser->createdTime, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pUser->createdTime, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pUser->updateTime, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pUser->updateTime, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pUser->superUser, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pUser->superUser, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pUser->authVersion, _OVER)
|
||||||
|
|
||||||
int32_t numOfReadDbs = 0;
|
int32_t numOfReadDbs = 0;
|
||||||
int32_t numOfWriteDbs = 0;
|
int32_t numOfWriteDbs = 0;
|
||||||
|
@ -588,7 +590,7 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp) {
|
static int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp) {
|
||||||
memcpy(pRsp->user, pUser->user, TSDB_USER_LEN);
|
memcpy(pRsp->user, pUser->user, TSDB_USER_LEN);
|
||||||
pRsp->superAuth = pUser->superUser;
|
pRsp->superAuth = pUser->superUser;
|
||||||
pRsp->version = pUser->authVersion;
|
pRsp->version = pUser->authVersion;
|
||||||
|
@ -601,7 +603,7 @@ static int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUser
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -659,7 +661,7 @@ static int32_t mndProcessGetUserAuthReq(SNodeMsg *pReq) {
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
mndReleaseUser(pMnode, pUser);
|
||||||
tFreeSGetUserAuthRsp(&authRsp);
|
tFreeSGetUserAuthRsp(&authRsp);
|
||||||
|
|
||||||
|
@ -711,7 +713,8 @@ static void mndCancelGetNextUser(SMnode *pMnode, void *pIter) {
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp, int32_t *pRspLen) {
|
int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp,
|
||||||
|
int32_t *pRspLen) {
|
||||||
SUserAuthBatchRsp batchRsp = {0};
|
SUserAuthBatchRsp batchRsp = {0};
|
||||||
batchRsp.pArray = taosArrayInit(numOfUses, sizeof(SGetUserAuthRsp));
|
batchRsp.pArray = taosArrayInit(numOfUses, sizeof(SGetUserAuthRsp));
|
||||||
if (batchRsp.pArray == NULL) {
|
if (batchRsp.pArray == NULL) {
|
||||||
|
@ -731,7 +734,7 @@ int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_
|
||||||
mndReleaseUser(pMnode, pUser);
|
mndReleaseUser(pMnode, pUser);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGetUserAuthRsp rsp = {0};
|
SGetUserAuthRsp rsp = {0};
|
||||||
code = mndSetUserAuthRsp(pMnode, pUser, &rsp);
|
code = mndSetUserAuthRsp(pMnode, pUser, &rsp);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -740,7 +743,6 @@ int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
taosArrayPush(batchRsp.pArray, &rsp);
|
taosArrayPush(batchRsp.pArray, &rsp);
|
||||||
mndReleaseUser(pMnode, pUser);
|
mndReleaseUser(pMnode, pUser);
|
||||||
}
|
}
|
||||||
|
@ -748,7 +750,7 @@ int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_
|
||||||
if (taosArrayGetSize(batchRsp.pArray) <= 0) {
|
if (taosArrayGetSize(batchRsp.pArray) <= 0) {
|
||||||
*ppRsp = NULL;
|
*ppRsp = NULL;
|
||||||
*pRspLen = 0;
|
*pRspLen = 0;
|
||||||
|
|
||||||
tFreeSUserAuthBatchRsp(&batchRsp);
|
tFreeSUserAuthBatchRsp(&batchRsp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -772,10 +774,7 @@ _OVER:
|
||||||
|
|
||||||
*ppRsp = NULL;
|
*ppRsp = NULL;
|
||||||
*pRspLen = 0;
|
*pRspLen = 0;
|
||||||
|
|
||||||
tFreeSUserAuthBatchRsp(&batchRsp);
|
tFreeSUserAuthBatchRsp(&batchRsp);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 59e0ebaf4905e4cb6d95a01c58b3fa507abc5a20
|
Subproject commit 2f3dfddd4d9a869e706ba3cf98fb6d769404cd7c
|
Loading…
Reference in New Issue