Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bwallet
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Go
bwallet
Commits
7d5ea99b
Commit
7d5ea99b
authored
Dec 15, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
md5 encrypt
parent
3e58950d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
md5.go
middleware/sign/md5/md5.go
+11
-11
No files found.
middleware/sign/md5/md5.go
View file @
7d5ea99b
...
...
@@ -2,9 +2,9 @@ package md5
import
(
config
"bwallet/conf"
"bwallet/pkg/errno"
"bwallet/pkg/handler"
"bwallet/pkg/util"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"net/url"
...
...
@@ -40,18 +40,18 @@ func Md5() gin.HandlerFunc {
// 验证签名
func
verifySign
(
c
*
gin
.
Context
)
(
map
[
string
]
string
,
error
)
{
_
=
c
.
Request
.
ParseForm
()
req
:=
c
.
Request
.
Form
req
:=
c
.
Request
.
Form
debug
:=
strings
.
Join
(
c
.
Request
.
Form
[
"debug"
],
""
)
ak
:=
strings
.
Join
(
c
.
Request
.
Form
[
"ak"
],
""
)
sn
:=
strings
.
Join
(
c
.
Request
.
Form
[
"sn"
],
""
)
ts
:=
strings
.
Join
(
c
.
Request
.
Form
[
"ts"
],
""
)
ak
:=
strings
.
Join
(
c
.
Request
.
Form
[
"ak"
],
""
)
sn
:=
strings
.
Join
(
c
.
Request
.
Form
[
"sn"
],
""
)
ts
:=
strings
.
Join
(
c
.
Request
.
Form
[
"ts"
],
""
)
// 验证来源
value
,
ok
:=
config
.
ApiAuthConfig
[
ak
]
if
ok
{
AppSecret
=
value
[
"md5"
]
}
else
{
return
nil
,
err
no
.
ErrAk
return
nil
,
err
ors
.
New
(
"ak Error"
)
}
if
debug
==
"1"
{
...
...
@@ -66,15 +66,15 @@ func verifySign(c *gin.Context) (map[string]string, error) {
// 验证过期时间
timestamp
:=
time
.
Now
()
.
Unix
()
exp
,
_
:=
strconv
.
ParseInt
(
config
.
AppSignExpiry
,
10
,
64
)
tsInt
,
_
:=
strconv
.
ParseInt
(
ts
,
10
,
64
)
if
tsInt
>
timestamp
||
timestamp
-
tsInt
>=
exp
{
return
nil
,
err
no
.
ErrTs
exp
,
_
:=
strconv
.
ParseInt
(
config
.
AppSignExpiry
,
10
,
64
)
tsInt
,
_
:=
strconv
.
ParseInt
(
ts
,
10
,
64
)
if
tsInt
>
timestamp
||
timestamp
-
tsInt
>=
exp
{
return
nil
,
err
ors
.
New
(
"ts Error"
)
}
// 验证签名
if
sn
==
""
||
sn
!=
createSign
(
req
)
{
return
nil
,
err
no
.
ErrSn
return
nil
,
err
ors
.
New
(
"sn Error"
)
}
return
nil
,
nil
...
...
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