Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
98740fdd
Commit
98740fdd
authored
Sep 04, 2016
by
astaxie
Committed by
GitHub
Sep 04, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2138 from kbynd/patch-1
RequestURI captures the signature field as well.
parents
3f67c62d
6d3042f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
apiauth.go
plugins/apiauth/apiauth.go
+3
-3
No files found.
plugins/apiauth/apiauth.go
View file @
98740fdd
...
...
@@ -119,7 +119,7 @@ func APISecretAuth(f AppIDToAppSecret, timeout int) beego.FilterFunc {
return
}
if
ctx
.
Input
.
Query
(
"signature"
)
!=
Signature
(
appsecret
,
ctx
.
Input
.
Method
(),
ctx
.
Request
.
Form
,
ctx
.
Input
.
UR
I
())
{
Signature
(
appsecret
,
ctx
.
Input
.
Method
(),
ctx
.
Request
.
Form
,
ctx
.
Input
.
UR
L
())
{
ctx
.
ResponseWriter
.
WriteHeader
(
403
)
ctx
.
WriteString
(
"auth failed"
)
}
...
...
@@ -127,7 +127,7 @@ func APISecretAuth(f AppIDToAppSecret, timeout int) beego.FilterFunc {
}
// Signature used to generate signature with the appsecret/method/params/RequestURI
func
Signature
(
appsecret
,
method
string
,
params
url
.
Values
,
RequestUR
I
string
)
(
result
string
)
{
func
Signature
(
appsecret
,
method
string
,
params
url
.
Values
,
RequestUR
L
string
)
(
result
string
)
{
var
query
string
pa
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
params
{
...
...
@@ -143,7 +143,7 @@ func Signature(appsecret, method string, params url.Values, RequestURI string) (
query
=
fmt
.
Sprintf
(
"%v%v%v"
,
query
,
vs
.
Keys
[
i
],
vs
.
Vals
[
i
])
}
}
stringToSign
:=
fmt
.
Sprintf
(
"%v
\n
%v
\n
%v
\n
"
,
method
,
query
,
RequestUR
I
)
stringToSign
:=
fmt
.
Sprintf
(
"%v
\n
%v
\n
%v
\n
"
,
method
,
query
,
RequestUR
L
)
sha256
:=
sha256
.
New
hash
:=
hmac
.
New
(
sha256
,
[]
byte
(
appsecret
))
...
...
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