Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
035451b0
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
035451b0
编写于
5月 12, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-276] add user auth
上级
55a18d8c
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
92 addition
and
29 deletion
+92
-29
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+1
-0
src/dnode/src/dnodePeer.c
src/dnode/src/dnodePeer.c
+8
-1
src/dnode/src/dnodeShell.c
src/dnode/src/dnodeShell.c
+29
-1
src/inc/dnode.h
src/inc/dnode.h
+1
-0
src/inc/mnode.h
src/inc/mnode.h
+4
-2
src/inc/taosmsg.h
src/inc/taosmsg.h
+9
-0
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+0
-24
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+40
-1
未找到文件。
src/client/src/tscSystem.c
浏览文件 @
035451b0
...
...
@@ -63,6 +63,7 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) {
rpcInit
.
user
=
(
char
*
)
user
;
rpcInit
.
idleTime
=
2000
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
spi
=
1
;
rpcInit
.
secret
=
secretEncrypt
;
*
pDnodeConn
=
rpcOpen
(
&
rpcInit
);
...
...
src/dnode/src/dnodePeer.c
浏览文件 @
035451b0
...
...
@@ -52,6 +52,7 @@ int32_t dnodeInitServer() {
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_CONFIG_VNODE
]
=
mgmtProcessReqMsgFromDnode
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_GRANT
]
=
mgmtProcessReqMsgFromDnode
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_STATUS
]
=
mgmtProcessReqMsgFromDnode
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_AUTH
]
=
mgmtProcessReqMsgFromDnode
;
SRpcInit
rpcInit
;
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
...
...
@@ -163,3 +164,9 @@ void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
void
dnodeSendMsgToDnode
(
SRpcIpSet
*
ipSet
,
SRpcMsg
*
rpcMsg
)
{
rpcSendRequest
(
tsDnodeClientRpc
,
ipSet
,
rpcMsg
);
}
void
dnodeSendMsgToDnodeRecv
(
SRpcMsg
*
rpcMsg
,
SRpcMsg
*
rpcRsp
)
{
SRpcIpSet
ipSet
=
{
0
};
dnodeGetMnodeDnodeIpSet
(
&
ipSet
);
rpcSendRecv
(
tsDnodeClientRpc
,
&
ipSet
,
rpcMsg
,
rpcRsp
);
}
src/dnode/src/dnodeShell.c
浏览文件 @
035451b0
...
...
@@ -21,6 +21,7 @@
#include "trpc.h"
#include "tglobal.h"
#include "http.h"
#include "mnode.h"
#include "dnode.h"
#include "dnodeInt.h"
#include "dnodeVRead.h"
...
...
@@ -138,7 +139,34 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
}
static
int
dnodeRetrieveUserAuthInfo
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
return
TSDB_CODE_SUCCESS
;
int
code
=
mgmtRetriveAuth
(
user
,
spi
,
encrypt
,
secret
,
ckey
);
if
(
code
!=
TSDB_CODE_NOT_READY
)
return
code
;
SDMAuthMsg
*
pMsg
=
rpcMallocCont
(
sizeof
(
SDMAuthMsg
));
strcpy
(
pMsg
->
user
,
user
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pMsg
;
rpcMsg
.
contLen
=
sizeof
(
SDMAuthMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_DM_AUTH
;
dTrace
(
"user:%s, send auth msg to mnode"
,
user
);
SRpcMsg
rpcRsp
=
{
0
};
dnodeSendMsgToDnodeRecv
(
&
rpcMsg
,
&
rpcRsp
);
if
(
rpcRsp
.
code
!=
0
)
{
dError
(
"user:%s, auth msg received from mnode, error:%s"
,
user
,
tstrerror
(
rpcRsp
.
code
));
}
else
{
dTrace
(
"user:%s, auth msg received from mnode"
,
user
);
SDMAuthRsp
*
pRsp
=
rpcRsp
.
pCont
;
memcpy
(
secret
,
pRsp
->
secret
,
TSDB_KEY_LEN
);
memcpy
(
ckey
,
pRsp
->
ckey
,
TSDB_KEY_LEN
);
*
spi
=
pRsp
->
spi
;
*
encrypt
=
pRsp
->
encrypt
;
}
rpcFreeCont
(
rpcRsp
.
pCont
);
return
rpcRsp
.
code
;
}
SDnodeStatisInfo
dnodeGetStatisInfo
()
{
...
...
src/inc/dnode.h
浏览文件 @
035451b0
...
...
@@ -52,6 +52,7 @@ int32_t dnodeGetDnodeId();
void
dnodeAddClientRspHandle
(
uint8_t
msgType
,
void
(
*
fp
)(
SRpcMsg
*
rpcMsg
));
void
dnodeAddServerMsgHandle
(
uint8_t
msgType
,
void
(
*
fp
)(
SRpcMsg
*
rpcMsg
));
void
dnodeSendMsgToDnode
(
SRpcIpSet
*
ipSet
,
SRpcMsg
*
rpcMsg
);
void
dnodeSendMsgToDnodeRecv
(
SRpcMsg
*
rpcMsg
,
SRpcMsg
*
rpcRsp
);
#ifdef __cplusplus
}
...
...
src/inc/mnode.h
浏览文件 @
035451b0
...
...
@@ -26,9 +26,11 @@ void mgmtCleanUpSystem();
void
mgmtStopSystem
();
void
sdbUpdateSync
();
int32_t
mgmtRetriveAuth
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
void
mgmtProcessMsgFromShell
(
SRpcMsg
*
rpcMsg
);
void
mgmtProcessReqMsgFromDnode
(
SRpcMsg
*
rpcMsg
);
#ifdef __cplusplus
}
#endif
...
...
src/inc/taosmsg.h
浏览文件 @
035451b0
...
...
@@ -100,6 +100,7 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_TABLE, "config-table" )
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DM_CONFIG_VNODE
,
"config-vnode"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DM_STATUS
,
"status"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DM_GRANT
,
"grant"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DM_AUTH
,
"auth"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DUMMY12
,
"dummy12"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DUMMY13
,
"dummy13"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DUMMY14
,
"dummy14"
)
...
...
@@ -737,6 +738,14 @@ typedef struct {
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
}
SMDAlterStreamMsg
;
typedef
struct
{
char
user
[
TSDB_USER_LEN
+
1
];
char
spi
;
char
encrypt
;
char
secret
[
TSDB_KEY_LEN
+
1
];
char
ckey
[
TSDB_KEY_LEN
+
1
];
}
SDMAuthMsg
,
SDMAuthRsp
;
#pragma pack(pop)
#ifdef __cplusplus
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
035451b0
...
...
@@ -41,7 +41,6 @@
typedef
int32_t
(
*
SShowMetaFp
)(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
typedef
int32_t
(
*
SShowRetrieveFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
//static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
static
bool
mgmtCheckMsgReadOnly
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessUnSupportMsg
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessShowMsg
(
SQueuedMsg
*
queuedMsg
);
...
...
@@ -343,29 +342,6 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) {
rpcSendResponse
(
&
rpcRsp
);
}
/*
static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
*spi = 1;
*encrypt = 0;
*ckey = 0;
if (!sdbIsMaster()) {
*secret = 0;
return TSDB_CODE_NOT_READY;
}
SUserObj *pUser = mgmtGetUser(user);
if (pUser == NULL) {
*secret = 0;
return TSDB_CODE_INVALID_USER;
} else {
memcpy(secret, pUser->pass, TSDB_KEY_LEN);
mgmtDecUserRef(pUser);
return TSDB_CODE_SUCCESS;
}
}
*/
static
void
mgmtProcessConnectMsg
(
SQueuedMsg
*
pMsg
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SCMConnectMsg
*
pConnectMsg
=
pMsg
->
pCont
;
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
035451b0
...
...
@@ -37,6 +37,7 @@ static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void
static
void
mgmtProcessCreateUserMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessAlterUserMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessDropUserMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessAuthMsg
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mgmtUserActionDestroy
(
SSdbOper
*
pOper
)
{
tfree
(
pOper
->
pObj
);
...
...
@@ -140,6 +141,7 @@ int32_t mgmtInitUsers() {
mgmtAddShellMsgHandle
(
TSDB_MSG_TYPE_CM_DROP_USER
,
mgmtProcessDropUserMsg
);
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_USER
,
mgmtGetUserMeta
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_USER
,
mgmtRetrieveUsers
);
dnodeAddServerMsgHandle
(
TSDB_MSG_TYPE_DM_AUTH
,
mgmtProcessAuthMsg
);
mTrace
(
"table:%s, hash is created"
,
tableDesc
.
tableName
);
return
0
;
...
...
@@ -529,3 +531,40 @@ void mgmtDropAllUsers(SAcctObj *pAcct) {
mTrace
(
"acct:%s, all users:%d is dropped from sdb"
,
pAcct
->
user
,
numOfUsers
);
}
int32_t
mgmtRetriveAuth
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
if
(
!
sdbIsMaster
())
{
*
secret
=
0
;
mTrace
(
"user:%s, failed to auth user, reason:%s"
,
user
,
tstrerror
(
TSDB_CODE_NOT_READY
));
return
TSDB_CODE_NOT_READY
;
}
SUserObj
*
pUser
=
mgmtGetUser
(
user
);
if
(
pUser
==
NULL
)
{
*
secret
=
0
;
mError
(
"user:%s, failed to auth user, reason:%s"
,
user
,
tstrerror
(
TSDB_CODE_INVALID_USER
));
return
TSDB_CODE_INVALID_USER
;
}
else
{
*
spi
=
1
;
*
encrypt
=
0
;
*
ckey
=
0
;
memcpy
(
secret
,
pUser
->
pass
,
TSDB_KEY_LEN
);
mgmtDecUserRef
(
pUser
);
mTrace
(
"user:%s, auth info is returned"
,
user
);
return
TSDB_CODE_SUCCESS
;
}
}
static
void
mgmtProcessAuthMsg
(
SRpcMsg
*
rpcMsg
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
rpcMsg
->
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SDMAuthMsg
*
pAuthMsg
=
rpcMsg
->
pCont
;
SDMAuthRsp
*
pAuthRsp
=
rpcMallocCont
(
sizeof
(
SDMAuthRsp
));
rpcRsp
.
code
=
mgmtRetriveAuth
(
pAuthMsg
->
user
,
&
pAuthRsp
->
spi
,
&
pAuthRsp
->
encrypt
,
pAuthRsp
->
secret
,
pAuthRsp
->
ckey
);
rpcRsp
.
pCont
=
pAuthRsp
;
rpcRsp
.
contLen
=
sizeof
(
SDMAuthRsp
);
rpcSendResponse
(
&
rpcRsp
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录