Merge branch 'master' of https://gitea.f2b211.com/jsasg/orico-official-website
This commit is contained in:
5
.env
5
.env
@@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
[JWT]
|
|
||||||
TTL=3600
|
|
||||||
REFRESH_TTL=20160
|
|
||||||
SECRET=b43e6276644ed60e65c50d1b324ba10b
|
|
||||||
@@ -36,12 +36,14 @@ WHITE_LIST[] = receive_sync/product
|
|||||||
# 不需记录日志的接口
|
# 不需记录日志的接口
|
||||||
[ADMIN_API]
|
[ADMIN_API]
|
||||||
IGNORE_LOGGING_LIST[] = v1/OperateLog/index
|
IGNORE_LOGGING_LIST[] = v1/OperateLog/index
|
||||||
MAX_IMAGE_SIZE = 5mb # 图片上传最大限制
|
MAX_IMAGE_SIZE = 5mb; # 图片上传最大限制
|
||||||
MAX_VIDEO_SIZE = 150mb # 视频上传最大限制
|
MAX_VIDEO_SIZE = 150mb; # 视频上传最大限制
|
||||||
MAX_ATTACHMENT_SIZE = 100mb # 附件上传最大限制
|
MAX_ATTACHMENT_SIZE = 100mb; # 附件上传最大限制
|
||||||
|
|
||||||
# 开放API
|
# 开放API
|
||||||
[OPENAPI]
|
[OPENAPI]
|
||||||
|
ACCESS_TOKEN_LIFETIME = 3600; # 访问令牌有效期
|
||||||
|
REFRESH_TOKEN_LIFETIME = 1209600; # 刷新令牌有效期
|
||||||
RESOURCE_IMAGES_DOMAIN = http://local.orico.com; # 图片资源服务器地址
|
RESOURCE_IMAGES_DOMAIN = http://local.orico.com; # 图片资源服务器地址
|
||||||
RESOURCE_VIDEOS_DOMAIN = http://local.orico.com; # 视频资源服务器地址
|
RESOURCE_VIDEOS_DOMAIN = http://local.orico.com; # 视频资源服务器地址
|
||||||
|
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,8 +3,10 @@ composer.phar
|
|||||||
composer.lock
|
composer.lock
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
.env
|
||||||
.env.dev
|
.env.dev
|
||||||
.env.local
|
.env.local
|
||||||
|
.env.prod
|
||||||
|
|
||||||
/.idea
|
/.idea
|
||||||
/.vscode
|
/.vscode
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ class SysRoleAuthorityBaseModel extends Model
|
|||||||
protected $schema = [
|
protected $schema = [
|
||||||
'role_id' => 'int',
|
'role_id' => 'int',
|
||||||
'menu_id' => 'int',
|
'menu_id' => 'int',
|
||||||
'permission' => 'int',
|
'permission' => 'string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<div class="m_Container">
|
<div class="m_Container">
|
||||||
{notempty name="categorys_data"}
|
{notempty name="categorys_data"}
|
||||||
<div class="product_list">
|
<div class="product_list">
|
||||||
|
{if condition="in_array('products', array_keys($categorys_data[0]))"}
|
||||||
<ul>
|
<ul>
|
||||||
{assign name="products" value=":\think\helper\Arr::flatMap(fn($pro) => $pro['products'], $categorys_data)" /}
|
{assign name="products" value=":\think\helper\Arr::flatMap(fn($pro) => $pro['products'], $categorys_data)" /}
|
||||||
{volist name="products" id="pr"}
|
{volist name="products" id="pr"}
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{/volist}
|
{/volist}
|
||||||
</ul>
|
</ul>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/notempty}
|
{/notempty}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,7 +25,10 @@ class Authorize
|
|||||||
$server = request()->server();
|
$server = request()->server();
|
||||||
$request = new Request([], $post, [], [], [], $server);
|
$request = new Request([], $post, [], [], [], $server);
|
||||||
$storage = new OAuthStorage;
|
$storage = new OAuthStorage;
|
||||||
$oauth = new OAuth2($storage);
|
$oauth = new OAuth2($storage, [
|
||||||
|
'access_token_lifetime' => intval(env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600)),
|
||||||
|
'refresh_token_lifetime' => intval(env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600)),
|
||||||
|
]);
|
||||||
$token = $oauth->grantAccessToken($request);
|
$token = $oauth->grantAccessToken($request);
|
||||||
return success('success', json_decode($token->getContent(), true));
|
return success('success', json_decode($token->getContent(), true));
|
||||||
} catch (OAuth2ServerException $e) {
|
} catch (OAuth2ServerException $e) {
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ class Auth
|
|||||||
public function handle($request, \Closure $next)
|
public function handle($request, \Closure $next)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oauth = new OAuth2(new OAuthStorage);
|
$oauth = new OAuth2(new OAuthStorage, [
|
||||||
|
'access_token_lifetime' => intval(env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600)),
|
||||||
|
'refresh_token_lifetime' => intval(env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600)),
|
||||||
|
]);
|
||||||
$token = $oauth->getBearerToken();
|
$token = $oauth->getBearerToken();
|
||||||
$oauth->verifyAccessToken($token);
|
$oauth->verifyAccessToken($token);
|
||||||
} catch (OAuth2ServerException $e) {
|
} catch (OAuth2ServerException $e) {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class OAuthClientModel extends Model
|
|||||||
'client_secret' => 'string',
|
'client_secret' => 'string',
|
||||||
'redirect_uri' => 'string',
|
'redirect_uri' => 'string',
|
||||||
'enabled' => 'int',
|
'enabled' => 'int',
|
||||||
|
'expired_at' => 'datetime',
|
||||||
|
'remark' => 'string',
|
||||||
'created_at' => 'datetime',
|
'created_at' => 'datetime',
|
||||||
'updated_at' => 'datetime',
|
'updated_at' => 'datetime',
|
||||||
'deleted_at' => 'datetime'
|
'deleted_at' => 'datetime'
|
||||||
|
|||||||
@@ -78,15 +78,18 @@ class OAuthStorage implements IOAuth2GrantCode, IOAuth2RefreshTokens, IOAuth2Gra
|
|||||||
public function getClient($client_id): IOAuth2Client
|
public function getClient($client_id): IOAuth2Client
|
||||||
{
|
{
|
||||||
// 实现获取客户端的逻辑
|
// 实现获取客户端的逻辑
|
||||||
$ret = OAuthClientModel::clientId($client_id)->find();
|
$client = OAuthClientModel::clientId($client_id)->find();
|
||||||
if (is_null($ret)) {
|
if (is_null($client)) {
|
||||||
throw new \Exception('客户端不存在');
|
throw new \Exception('客户端不存在');
|
||||||
}
|
}
|
||||||
if ($ret->enabled != 1) {
|
if ($client->enabled != 1) {
|
||||||
throw new \Exception('客户端已禁用');
|
throw new \Exception('客户端已禁用');
|
||||||
}
|
}
|
||||||
|
if (strtotime($client->expired_at) < time()) {
|
||||||
|
throw new \Exception('client_id 授权已过期');
|
||||||
|
}
|
||||||
|
|
||||||
return new OAuth2Client($ret->client_id, $ret->client_secret, [$ret->redirect_uri]);
|
return new OAuth2Client($client->client_id, $client->client_secret, [$client->redirect_uri]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkClientCredentials(IOAuth2Client $client, $client_secret = null): bool
|
public function checkClientCredentials(IOAuth2Client $client, $client_secret = null): bool
|
||||||
@@ -96,6 +99,9 @@ class OAuthStorage implements IOAuth2GrantCode, IOAuth2RefreshTokens, IOAuth2Gra
|
|||||||
if (is_null($client)) {
|
if (is_null($client)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (strtotime($client->expired_at) < time()) {
|
||||||
|
throw new \Exception('client_id 授权已过期');
|
||||||
|
}
|
||||||
|
|
||||||
return $client->client_secret == hash('sha1', $client->client_id . $client_secret . $this->salt);
|
return $client->client_secret == hash('sha1', $client->client_id . $client_secret . $this->salt);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user