Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
im-microservice
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Li Feifei
im-microservice
Commits
faf23f43
Commit
faf23f43
authored
Jul 07, 2020
by
Li Feifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
9b3c1fbf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
20 deletions
+8
-20
Registration_services.go
initialization/Registration_services.go
+3
-4
auth.go
middleware/auth.go
+5
-16
No files found.
initialization/Registration_services.go
View file @
faf23f43
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
"im-microservice/sevice/health"
"im-microservice/sevice/health"
"im-microservice/sevice/im_chat_room"
"im-microservice/sevice/im_chat_room"
"im-microservice/sevice/im_friend_request"
"im-microservice/sevice/im_friend_request"
"im-microservice/sevice/im_chat_room_user"
//
"im-microservice/sevice/im_chat_room_user"
ic
"im-microservice/sevice/im_configure"
ic
"im-microservice/sevice/im_configure"
"im-microservice/sevice/im_user"
"im-microservice/sevice/im_user"
iur
"im-microservice/sevice/im_user_relationship"
iur
"im-microservice/sevice/im_user_relationship"
...
@@ -45,8 +45,7 @@ func init() {
...
@@ -45,8 +45,7 @@ func init() {
grpc
.
UnaryInterceptor
(
grpc_middleware
.
ChainUnaryServer
(
grpc
.
UnaryInterceptor
(
grpc_middleware
.
ChainUnaryServer
(
middleware
.
Interceptor
,
middleware
.
Interceptor
,
grpc_validator
.
UnaryServerInterceptor
(),
grpc_validator
.
UnaryServerInterceptor
(),
middleware
.
Interceptor
,
middleware
.
Auth
,
//middleware.Auth,
grpc_recovery
.
UnaryServerInterceptor
(
middleware
.
RecoveryInterceptor
()),
grpc_recovery
.
UnaryServerInterceptor
(
middleware
.
RecoveryInterceptor
()),
grpc_zap
.
UnaryServerInterceptor
(
middleware
.
ZapInterceptor
()),
grpc_zap
.
UnaryServerInterceptor
(
middleware
.
ZapInterceptor
()),
)))
)))
...
@@ -57,7 +56,7 @@ func init() {
...
@@ -57,7 +56,7 @@ func init() {
pb
.
RegisterImUserServer
(
rpc_server
,
&
im_user
.
ImUserServer
{})
pb
.
RegisterImUserServer
(
rpc_server
,
&
im_user
.
ImUserServer
{})
pb
.
RegisterUserRelationshipServiceServer
(
rpc_server
,
&
iur
.
UserRelationshipService
{})
pb
.
RegisterUserRelationshipServiceServer
(
rpc_server
,
&
iur
.
UserRelationshipService
{})
pb
.
RegisterImFriendServiceServer
(
rpc_server
,
&
im_friend_request
.
ImFriendService
{})
pb
.
RegisterImFriendServiceServer
(
rpc_server
,
&
im_friend_request
.
ImFriendService
{})
pb
.
RegisterChatRoomUserServer
(
rpc_server
,
&
im_chat_room_user
.
ChatRoomUserServer
{})
//
pb.RegisterChatRoomUserServer(rpc_server, &im_chat_room_user.ChatRoomUserServer{})
reflection
.
Register
(
rpc_server
)
reflection
.
Register
(
rpc_server
)
RpcServer
=
rpc_server
RpcServer
=
rpc_server
...
...
middleware/auth.go
View file @
faf23f43
...
@@ -56,23 +56,12 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
...
@@ -56,23 +56,12 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
if
info
.
FullMethod
!=
health_path
{
if
info
.
FullMethod
!=
health_path
{
request_map
:=
make
(
map
[
string
]
string
)
request_map
:=
make
(
map
[
string
]
string
)
s
:=
fmt
.
Sprintf
(
"%v"
,
req
)
key_r
,
_
:=
regexp
.
Compile
(
`[^}|^Common:]\s?(.*?):"(.*?)"`
)
key_r
,
_
:=
regexp
.
Compile
(
`Appkey:"(.*?)"`
)
result
:=
key_r
.
FindAllStringSubmatch
(
fmt
.
Sprintf
(
"%v"
,
req
),
-
1
)
nonce_r
,
_
:=
regexp
.
Compile
(
`Nonce:"(.*?)"`
)
for
_
,
v
:=
range
result
{
c_r
,
_
:=
regexp
.
Compile
(
`Curtime:"(.*?)"`
)
request_map
[
v
[
1
]]
=
v
[
2
]
cs_r
,
_
:=
regexp
.
Compile
(
`Checksum:"(.*?)"`
)
}
appkey
:=
key_r
.
FindAllStringSubmatch
(
s
,
-
1
)
nonce
:=
nonce_r
.
FindAllStringSubmatch
(
s
,
-
1
)
curtime
:=
c_r
.
FindAllStringSubmatch
(
s
,
-
1
)
check_sum
:=
cs_r
.
FindAllStringSubmatch
(
s
,
-
1
)
request_map
[
"Appkey"
]
=
appkey
[
0
][
1
]
request_map
[
"Nonce"
]
=
nonce
[
0
][
1
]
request_map
[
"Curtime"
]
=
curtime
[
0
][
1
]
request_map
[
"Checksum"
]
=
check_sum
[
0
][
1
]
if
err
:=
checksum
(
request_map
);
err
!=
nil
{
if
err
:=
checksum
(
request_map
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment