Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Cong.Zhao
/
musician-api.hikoon.com
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
9c56f25c
...
9c56f25cddd35d09bdb5b7bfaf01cc8ed760cca2
authored
2022-08-22 17:34:26 +0800
by
wei.feng
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
商用授权接口
1 parent
74fb33ac
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
6 deletions
app/Http/Controllers/OpenApi/ClientCredentialsController.php
app/Http/Middleware/CheckSignature.php
routes/openApi.php
app/Http/Controllers/OpenApi/ClientCredentialsController.php
View file @
9c56f25
...
...
@@ -124,6 +124,13 @@ class ClientCredentialsController
public
function
test
()
{
return
''
;
$params
=
[
time
(),
rand
(
10000
,
999999
),
'i85ShUQ6'
];
sort
(
$params
,
SORT_STRING
);
return
[
$params
,
sha1
(
join
(
'&'
,
$params
))];
}
}
...
...
app/Http/Middleware/CheckSignature.php
View file @
9c56f25
...
...
@@ -62,12 +62,12 @@ class CheckSignature
$only
=
Arr
::
only
(
$params
,
[
'client_id'
,
'timestamp'
,
'nonce'
]);
sort
(
$only
,
SORT_STRING
);
$tmpStr
=
sha1
(
join
(
'&'
,
$only
));
if
(
$params
[
'sign'
]
!=
$tmpStr
)
{
if
(
$params
[
'sign
ature
'
]
!=
$tmpStr
)
{
return
Response
::
successWithCode
(
ErrorCode
::
INVALID_SIGNATURE
,
ErrorCode
::
$messages
[
ErrorCode
::
INVALID_SIGNATURE
]);
}
//防重放机制
//检查时间戳是否有效
if
(
time
()
<
$params
[
'timestamp'
]
+
self
::
TIMESTAMP_LIMIT
)
{
if
(
time
()
>
$params
[
'timestamp'
]
+
self
::
TIMESTAMP_LIMIT
)
{
return
Response
::
successWithCode
(
ErrorCode
::
INVALID_TIMESTAMP
,
ErrorCode
::
$messages
[
ErrorCode
::
INVALID_TIMESTAMP
]);
}
//随机数是否已被使用
...
...
routes/openApi.php
View file @
9c56f25
...
...
@@ -6,8 +6,8 @@ Route::group(['prefix' => 'client-credentials'], function () {
Route
::
get
(
'getApp'
,
"ClientCredentialsController@getApp"
);
Route
::
get
(
'token'
,
"ClientCredentialsController@getAccessToken"
);
});
Route
::
get
(
'test'
,
"ClientCredentialsController@test"
);
Route
::
get
(
'song/list'
,
"SongController@list"
);
Route
::
group
([
'middleware'
=>
'check.signature'
],
function
()
{
//Route::get('test', "ClientCredentialsController@test");
Route
::
group
([
'middleware'
=>
'check.signature'
],
function
()
{
Route
::
get
(
'song/list'
,
"SongController@list"
);
});
...
...
Please
register
or
sign in
to post a comment