Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cdy816
Mars
提交
99234927
Mars
项目概览
cdy816
/
Mars
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mars
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
99234927
编写于
8月 31, 2020
作者:
cdy816
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新接口安全信息
上级
8f110b08
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
74 addition
and
13 deletion
+74
-13
Common/Cdy.Tag.Consume/IRuntimeSecurity.cs
Common/Cdy.Tag.Consume/IRuntimeSecurity.cs
+5
-0
Proxy/DBGrpcApi.Client/Client.cs
Proxy/DBGrpcApi.Client/Client.cs
+13
-3
Proxy/DBGrpcApi.Client/Protos/Security.proto
Proxy/DBGrpcApi.Client/Protos/Security.proto
+3
-0
Proxy/DBGrpcApi/Protos/Security.proto
Proxy/DBGrpcApi/Protos/Security.proto
+3
-0
Proxy/DBGrpcApi/Services/SecurityService.cs
Proxy/DBGrpcApi/Services/SecurityService.cs
+8
-1
Proxy/DbInRunWebApi/Controllers/LoginController.cs
Proxy/DbInRunWebApi/Controllers/LoginController.cs
+14
-5
Proxy/DbInRunWebApi/Model/Requestbase.cs
Proxy/DbInRunWebApi/Model/Requestbase.cs
+12
-1
RunTime/DBRuntime.Real/Security/SecurityRunner.cs
RunTime/DBRuntime.Real/Security/SecurityRunner.cs
+16
-3
未找到文件。
Common/Cdy.Tag.Consume/IRuntimeSecurity.cs
浏览文件 @
99234927
...
...
@@ -33,6 +33,11 @@ namespace Cdy.Tag
#
region
...
Properties
...
/// <summary>
///
/// </summary>
int
TimeOut
{
get
;
}
#
endregion
...
Properties
...
#
region
...
Methods
...
...
...
Proxy/DBGrpcApi.Client/Client.cs
浏览文件 @
99234927
...
...
@@ -70,6 +70,15 @@ namespace DBGrpcApi
}
}
/// <summary>
/// 超时时间
/// </summary>
public
int
TimeOut
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
DateTime
LoginTime
{
get
;
set
;
}
#
endregion
...
Properties
...
...
...
@@ -95,8 +104,6 @@ namespace DBGrpcApi
mSecurityClient
=
new
Security
.
SecurityClient
(
grpcChannel
);
}
catch
(
Exception
ex
)
{
...
...
@@ -118,7 +125,10 @@ namespace DBGrpcApi
{
try
{
mLoginId
=
mSecurityClient
.
Login
(
new
LoginRequest
()
{
Name
=
username
,
Password
=
password
}).
Token
;
var
re
=
mSecurityClient
.
Login
(
new
LoginRequest
()
{
Name
=
username
,
Password
=
password
});
TimeOut
=
re
.
Timeout
;
LoginTime
=
DateTime
.
FromBinary
(
re
.
Time
).
ToLocalTime
();
mLoginId
=
re
.
Token
;
}
catch
{
...
...
Proxy/DBGrpcApi.Client/Protos/Security.proto
浏览文件 @
99234927
...
...
@@ -23,10 +23,13 @@ message LoginRequest {
// The response message containing the greetings.
message
LoginReply
{
string
Token
=
1
;
int64
Time
=
2
;
int32
Timeout
=
3
;
}
message
HartRequest
{
string
Token
=
1
;
int64
Time
=
2
;
}
...
...
Proxy/DBGrpcApi/Protos/Security.proto
浏览文件 @
99234927
...
...
@@ -23,10 +23,13 @@ message LoginRequest {
// The response message containing the greetings.
message
LoginReply
{
string
Token
=
1
;
int64
Time
=
2
;
int32
Timeout
=
3
;
}
message
HartRequest
{
string
Token
=
1
;
int64
Time
=
2
;
}
...
...
Proxy/DBGrpcApi/Services/SecurityService.cs
浏览文件 @
99234927
...
...
@@ -24,7 +24,7 @@ namespace DBGrpcApi
public
override
Task
<
LoginReply
>
Login
(
LoginRequest
request
,
ServerCallContext
context
)
{
string
Token
=
Cdy
.
Tag
.
ServiceLocator
.
Locator
.
Resolve
<
Cdy
.
Tag
.
IRuntimeSecurity
>().
Login
(
request
.
Name
,
request
.
Password
);
return
Task
.
FromResult
(
new
LoginReply
()
{
Token
=
Token
});
return
Task
.
FromResult
(
new
LoginReply
()
{
Token
=
Token
,
Time
=
DateTime
.
UtcNow
.
ToBinary
(),
Timeout
=
Cdy
.
Tag
.
ServiceLocator
.
Locator
.
Resolve
<
Cdy
.
Tag
.
IRuntimeSecurity
>().
TimeOut
});
}
...
...
@@ -49,6 +49,13 @@ namespace DBGrpcApi
/// <returns></returns>
public
override
Task
<
HartReply
>
Hart
(
HartRequest
request
,
ServerCallContext
context
)
{
var
dt
=
DateTime
.
FromBinary
(
request
.
Time
);
if
((
DateTime
.
UtcNow
-
dt
).
TotalSeconds
>
Cdy
.
Tag
.
ServiceLocator
.
Locator
.
Resolve
<
Cdy
.
Tag
.
IRuntimeSecurity
>().
TimeOut
)
{
return
Task
.
FromResult
(
new
HartReply
()
{
Result
=
false
});
}
Cdy
.
Tag
.
ServiceLocator
.
Locator
.
Resolve
<
Cdy
.
Tag
.
IRuntimeSecurity
>().
FreshUserId
(
request
.
Token
);
return
Task
.
FromResult
(
new
HartReply
()
{
Result
=
true
});
}
...
...
Proxy/DbInRunWebApi/Controllers/LoginController.cs
浏览文件 @
99234927
...
...
@@ -16,9 +16,9 @@ namespace DbInRunWebApi.Controllers
[
HttpPost
(
"TryLogin"
)]
public
LoginResponse
Login
([
FromBody
]
LoginUser
user
)
{
string
Token
=
Cdy
.
Tag
.
ServiceLocator
.
Locator
.
Resolve
<
Cdy
.
Tag
.
IRuntimeSecurity
>().
Login
(
user
.
UserName
,
user
.
Password
);
//return null
;
return
new
LoginResponse
()
{
Token
=
Token
,
Result
=
!
string
.
IsNullOrEmpty
(
Token
),
Time
=
DateTime
.
Now
};
var
service
=
Cdy
.
Tag
.
ServiceLocator
.
Locator
.
Resolve
<
Cdy
.
Tag
.
IRuntimeSecurity
>(
);
string
Token
=
service
.
Login
(
user
.
UserName
,
user
.
Password
)
;
return
new
LoginResponse
()
{
Token
=
Token
,
Result
=
!
string
.
IsNullOrEmpty
(
Token
),
LoginTime
=
DateTime
.
UtcNow
.
ToBinary
(),
TimeOut
=
service
.
TimeOut
};
}
/// <summary>
...
...
@@ -29,7 +29,17 @@ namespace DbInRunWebApi.Controllers
[
HttpPost
(
"Hart"
)]
public
bool
Hart
([
FromBody
]
Requestbase
token
)
{
// return true;
if
(
string
.
IsNullOrEmpty
(
token
.
Time
))
{
return
false
;
}
long
ltmp
=
long
.
Parse
(
token
.
Time
);
if
((
DateTime
.
UtcNow
-
DateTime
.
FromBinary
(
ltmp
)).
TotalSeconds
>
Cdy
.
Tag
.
ServiceLocator
.
Locator
.
Resolve
<
Cdy
.
Tag
.
IRuntimeSecurity
>().
TimeOut
)
{
return
false
;
}
return
Cdy
.
Tag
.
ServiceLocator
.
Locator
.
Resolve
<
Cdy
.
Tag
.
IRuntimeSecurity
>().
FreshUserId
(
token
.
Token
);
}
...
...
@@ -41,7 +51,6 @@ namespace DbInRunWebApi.Controllers
[
HttpPost
(
"Logout"
)]
public
bool
Logout
([
FromBody
]
Requestbase
token
)
{
//return true;
return
Cdy
.
Tag
.
ServiceLocator
.
Locator
.
Resolve
<
Cdy
.
Tag
.
IRuntimeSecurity
>().
Logout
(
token
.
Token
);
}
...
...
Proxy/DbInRunWebApi/Model/Requestbase.cs
浏览文件 @
99234927
...
...
@@ -53,10 +53,16 @@ namespace DbInRunWebApi.Model
#
endregion
...
Constructor
...
#
region
...
Properties
...
/// <summary>
///
/// </summary>
public
DateTime
Time
{
get
;
set
;
}
public
long
LoginTime
{
get
;
set
;
}
/// <summary>
/// 超时时间
/// </summary>
public
long
TimeOut
{
get
;
set
;
}
/// <summary>
/// 结果
...
...
@@ -101,6 +107,11 @@ namespace DbInRunWebApi.Model
/// </summary>
public
string
Token
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
Time
{
get
;
set
;
}
#
endregion
...
Properties
...
#
region
...
Methods
...
...
...
RunTime/DBRuntime.Real/Security/SecurityRunner.cs
浏览文件 @
99234927
...
...
@@ -31,9 +31,10 @@ namespace Cdy.Tag
private
Dictionary
<
long
,
DateTime
>
mLastLogin2
=
new
Dictionary
<
long
,
DateTime
>();
private
Dictionary
<
long
,
string
>
mUseIdMap2
=
new
Dictionary
<
long
,
string
>();
public
const
int
Timeout
=
10
;
public
int
m
Timeout
=
10
;
private
bool
mIsClosed
=
false
;
...
...
@@ -67,9 +68,22 @@ namespace Cdy.Tag
}
}
/// <summary>
///
/// </summary>
public
int
TimeOut
{
get
{
return
mTimeout
;
}
}
#
endregion
...
Properties
...
#
region
...
Methods
...
/// <summary>
///
/// </summary>
...
...
@@ -86,7 +100,6 @@ namespace Cdy.Tag
public
void
Stop
()
{
mIsClosed
=
true
;
}
/// <summary>
...
...
@@ -103,7 +116,7 @@ namespace Cdy.Tag
{
foreach
(
var
vv
in
mLastLogin
)
{
if
((
dt
-
vv
.
Value
).
TotalMinutes
>=
Timeout
)
if
((
dt
-
vv
.
Value
).
TotalMinutes
>=
m
Timeout
)
{
ltmp
.
Add
(
vv
.
Key
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录