Compare commits

...

3 Commits

Author SHA1 Message Date
ch4o5
0705d1bef3 chore(release): 0.2.4 2023-01-13 20:20:00 +00:00
李东云
922c780c49 fix(oss): 修复了oss的配置缺失和错误 2023-01-14 04:19:46 +08:00
李东云
cdb193778f revert(constant): 移除冗余的http头authentication的枚举类型 2023-01-14 04:18:48 +08:00
7 changed files with 25 additions and 81 deletions

View File

@@ -1,4 +1,16 @@
# 版本更新日志
### [0.2.4](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v0.2.3...v0.2.4) (2023-01-13)
### ⏪ Revert | 回退
* **constant:** 移除冗余的http头authentication的枚举类型 ([cdb1937](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/cdb193778fb888851682bb1671bc55dd8f0e3423))
### 🐛 Bug Fixes | Bug 修复
* **oss:** 修复了oss的配置缺失和错误 ([922c780](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/922c780c49edc2cddbce3e66e6b9dfde7be364f8))
### [0.2.3](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v0.2.2...v0.2.3) (2023-01-13)

View File

@@ -1 +1 @@
0.2.3
0.2.4

View File

@@ -107,5 +107,5 @@
"url": "https://repo.huaweicloud.com/repository/php/"
}
},
"version": "0.2.3"
"version": "0.2.4"
}

View File

@@ -76,6 +76,8 @@ return [
'oss' => [
'access_key_id' => env('ACCESS_KEY_ID', ''),
'access_key_secret' => env('ACCESS_KEY_SECRET', ''),
'oss_host' => env('OSS_HOST', ''),
'oss_callback' => env('OSS_CALLBACK'), // 可选
],
],
],

View File

@@ -1,72 +0,0 @@
<?php
declare (strict_types=1);
namespace Singularity\HDK\Core\Constants;
use Hyperf\Constants\AbstractConstants;
use Hyperf\Constants\Annotation\Constants;
use Lmc\HttpConstants\Header;
#[Constants]
class HttpAuthenticationType extends AbstractConstants
{
/**
* base64-encoded credentials. More information below.
*
* @link https://datatracker.ietf.org/doc/html/rfc7617 RFC 7617
*/
public const BASIC = 'Basic';
/**
* bearer tokens to access OAuth 2.0-protected resources
*
* @link https://datatracker.ietf.org/doc/html/rfc6750 RFC 6750
*/
public const Bearer = 'Bearer';
/**
* HTTP Digest Access Authentication
*
* @note Firefox 93 and later support SHA-256 encryption.
* Previous versions only support MD5 hashing (not recommended).
*
* @link https://datatracker.ietf.org/doc/html/rfc7616 RFC 7616
*/
public const DIGEST = Header::DIGEST;
/**
* HTTP Origin-Bound Authentication, digital-signature-based
*
* @link https://datatracker.ietf.org/doc/html/rfc7486 RFC 7486,Section 3
*/
public const HOBA = 'HOBA';
/**
* @link https://datatracker.ietf.org/doc/html/rfc8120 RFC 8120
*/
public const MUTUAL = 'Mutual';
/**
* @link https://www.ietf.org/rfc/rfc4559.txt RFC 4559
*/
public const NEGOTIATE_NTLM = 'Negotiate';
/**
* Voluntary Application Server Identification (VAPID) for Web Push
*
* @link https://datatracker.ietf.org/doc/html/rfc8292 RFC 8292
*/
public const VAPID = 'vapid';
/**
* Salted Challenge Response HTTP Authentication Mechanism
*
* @link https://datatracker.ietf.org/doc/html/rfc7804 RFC 7804
*/
public const SCRAM_SHA_256 = 'SCRAM-SHA-256';
/**
* This scheme is used for AWS3 server authentication.
*
* @link https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html AWS docs
*/
public const AWS4_HMAC_SHA256 = 'AWS4-HMAC-SHA256';
/**
* 国密 SM3
*
* @see https://sm3.doylee.cn
*/
public const SCRAM_SM3 = 'SCRAM-SM3';
}

View File

@@ -29,7 +29,7 @@ class OssService
$this->accessKeyId ??= config('common.third_party.storage.oss.access_key_id');
$this->accessKeySecret ??= config('common.third_party.storage.oss.access_key_secret');
$this->host ??= config('common.third_party.storage.oss.oss_host');
$this->callbackUrl ??= config('oss_callback');
$this->callbackUrl ??= config('common.third_party.storage.oss.oss_callback') ?? null;
}
/**
@@ -84,7 +84,7 @@ class OssService
$string_to_sign = $base64_policy;
$signature = base64_encode(hash_hmac('sha1', $string_to_sign, $this->accessKeySecret, true));
$callback = Json::encode([
$callback = isset($this->callbackUrl) ? Json::encode([
'callbackUrl' => $this->callbackUrl,
'callbackBody' => $isImage ? <<<'callbackBody'
{
@@ -102,7 +102,7 @@ class OssService
"name": ${x:name},
"hash": ${x:hash}
}
callbackBody : <<<'callbackBody'
callbackBody: <<<'callbackBody'
{
"bucket": ${bucket},
"object": ${object},
@@ -115,17 +115,20 @@ callbackBody : <<<'callbackBody'
}
callbackBody,
'callbackBodyType' => 'application/json',
]);
]) : null;
return [
$result = [
'accessid' => $this->accessKeyId,
'host' => $this->host,
'policy' => $base64_policy,
'signature' => $signature,
'expire' => $expire_time,
'dir' => $dir,
'callback' => base64_encode($callback),
];
if (isset($callback)) {
$result += ['callback' => base64_encode($callback),];
}
return $result;
}
/**

View File

@@ -25,7 +25,6 @@ class UtilsService
* @return string
* @throws Exception
*/
#[Pure]
public function generateSecureCode(int $length = 4): string
{
$code = '';