From 05fc36701c0f7b9682a8204099709dc96d94de17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=B8=9C=E4=BA=91?= Date: Mon, 25 Apr 2022 18:12:00 +0800 Subject: [PATCH] =?UTF-8?q?build(composer):=20=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=A0=81=E5=92=8C=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 ++ publish/languages/en/saml_error.php | 16 ++++++++++ publish/languages/zh_CN/saml_error.php | 16 ++++++++++ src/ConfigProvider.php | 14 ++++++++- src/Constants/SamlErrorCode.php | 42 ++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 publish/languages/en/saml_error.php create mode 100644 publish/languages/zh_CN/saml_error.php create mode 100644 src/Constants/SamlErrorCode.php diff --git a/composer.json b/composer.json index 046303f..3130ee8 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,11 @@ "require": { "php": "~8.0", "hyperf/config": "^2.2", + "hyperf/constants": "^2.2", "hyperf/di": "2.2.*", "hyperf/http-server": "2.2.*", + "hyperf/translation": "^2.2", + "hyperf/validation": "^2.2", "lightsaml/lightsaml": "^2.1", "teapot/status-code": "^1.1" }, diff --git a/publish/languages/en/saml_error.php b/publish/languages/en/saml_error.php new file mode 100644 index 0000000..bbea9b9 --- /dev/null +++ b/publish/languages/en/saml_error.php @@ -0,0 +1,16 @@ + + * Powered by PhpStorm + * Created on 2022/4/25 + */ + +return [ + 'default' => 'SAML format error', + 'params' => [ + 'default' => 'SAML parameters missing', + 'saml_request' => 'SAMLRequest is required', + ], +]; \ No newline at end of file diff --git a/publish/languages/zh_CN/saml_error.php b/publish/languages/zh_CN/saml_error.php new file mode 100644 index 0000000..0cd82a7 --- /dev/null +++ b/publish/languages/zh_CN/saml_error.php @@ -0,0 +1,16 @@ + + * Powered by PhpStorm + * Created on 2022/4/25 + */ + +return [ + 'default' => 'SAML 检验失败', + 'params' => [ + 'default' => 'SAML 参数校验失败', + 'saml_request' => 'SAMLRequest 参数不能为空', + ], +]; \ No newline at end of file diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index 8361055..b4a7ffa 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -41,7 +41,19 @@ class ConfigProvider // 建议默认配置放在 publish 文件夹中,文件命名和组件名称相同 'source' => __DIR__ . '/../publish/saml.php', // 对应的配置文件路径 'destination' => BASE_PATH . '/config/autoload/saml.php', // 复制为这个路径下的该文件 - ] + ], + [ + 'id' => 'languages_cn', + 'description' => 'The SAML error message for Chinese', + 'source' => __DIR__ . '/../publish/languages/zh_CN/saml_error.php', + 'destination' => BASE_PATH . '/storage/languages/zh_CN/saml_error.php' + ], + [ + 'id' => 'languages_en', + 'description' => 'The SAML error message for English', + 'source' => __DIR__ . '/../publish/languages/en/saml_error.php', + 'destination' => BASE_PATH . '/storage/languages/en/saml_error.php' + ], ], ]; } diff --git a/src/Constants/SamlErrorCode.php b/src/Constants/SamlErrorCode.php new file mode 100644 index 0000000..7f9d50d --- /dev/null +++ b/src/Constants/SamlErrorCode.php @@ -0,0 +1,42 @@ + + * Powered by PhpStorm + * Created on 2022/4/25 + */ + +namespace Singularity\HyperfSaml\Constants; + +use Hyperf\Constants\AbstractConstants; + +/** + * SAML 相关错误码 + * Singularity\HyperfSaml\Constants\SamlErrorCode@HyperfSaml + * + * @author 李东云 + * Powered by PhpStorm + * Created on 2022/4/25 + */ +class SamlErrorCode extends AbstractConstants +{ + + // 203 SAML 鉴权 + /** + * @Message("saml_error.auth.saml.default") + */ + public const AUTH_SAML_ERROR = 203000; + + // 20301 验证 + /** + * @Message("saml_error.auth.saml.params.default") + */ + public const AUTH_SAML_REQUEST_PARAMS_ERROR = 2030100; + + /** + * @Message("saml_error.auth.saml.params.saml_request") + */ + public const AUTH_SAML_REQUEST_PARAMS_SAML_REQUEST = 2030101; + +} \ No newline at end of file