From 3b8e52c7eee45007962dbfcc3787a2a2d8fad1e4 Mon Sep 17 00:00:00 2001 From: zhontai <361243234@qq.com> Date: Thu, 16 Nov 2023 14:54:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=85=BC=E5=AE=B9.net7?= =?UTF-8?q?=E5=92=8C.net8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZhonTai.sln | 2 +- build/pkg.props | 19 - src/Directory.Build.props | 3 - src/hosts/ZhonTai.Host/ZhonTai.Host.csproj | 2 +- src/platform/Directory.Build.props | 23 + .../Core/Auth/ClaimAttributes.cs | 2 +- .../Auth/ResponseAuthenticationHandler.cs | 11 +- .../Services/Auth/AuthService.cs | 1 + .../ZhonTai.Admin/ZhonTai.Admin.csproj | 11 +- src/platform/ZhonTai.ApiUI/ZhonTai.ApiUI.xml | 434 ++++++++++++++++++ .../ZhonTai.Common/ZhonTai.Common.csproj | 24 +- .../ZhonTai.Common/ZhonTai.Common.xml | 33 +- .../ZhonTai.DynamicApi.csproj | 4 - .../ZhonTai.DynamicApi/ZhonTai.DynamicApi.xml | 235 ++++++++++ src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj | 38 +- 15 files changed, 757 insertions(+), 85 deletions(-) delete mode 100644 build/pkg.props delete mode 100644 src/Directory.Build.props create mode 100644 src/platform/Directory.Build.props create mode 100644 src/platform/ZhonTai.ApiUI/ZhonTai.ApiUI.xml create mode 100644 src/platform/ZhonTai.DynamicApi/ZhonTai.DynamicApi.xml diff --git a/ZhonTai.sln b/ZhonTai.sln index 1318d1e7..50f8f9ca 100644 --- a/ZhonTai.sln +++ b/ZhonTai.sln @@ -21,7 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4A1F23C8 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{A6C50476-5236-4FD3-8C29-6449494846C0}" ProjectSection(SolutionItems) = preProject - build\pkg.props = build\pkg.props + src\platform\Directory.Build.props = src\platform\Directory.Build.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZhonTai.ApiUI", "src\platform\ZhonTai.ApiUI\ZhonTai.ApiUI.csproj", "{A6911102-A4F8-4000-A997-045F84F73060}" diff --git a/build/pkg.props b/build/pkg.props deleted file mode 100644 index 9e6bafff..00000000 --- a/build/pkg.props +++ /dev/null @@ -1,19 +0,0 @@ - - - 5.0.2 - net8.0 - false - true - xiaoxue - xiaoxue - true - snupkg - MIT - https://admin.zhontai.net - https://github.com/zhontai/Admin.Core - git - ZhonTai AdminApi;WebApi;HttpApi; - logo.png - 1701;1702;1591 - - \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props deleted file mode 100644 index f3896c05..00000000 --- a/src/Directory.Build.props +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/hosts/ZhonTai.Host/ZhonTai.Host.csproj b/src/hosts/ZhonTai.Host/ZhonTai.Host.csproj index 5bea7c14..7f600ef5 100644 --- a/src/hosts/ZhonTai.Host/ZhonTai.Host.csproj +++ b/src/hosts/ZhonTai.Host/ZhonTai.Host.csproj @@ -1,6 +1,6 @@  - net8.0 + net7.0 中台接口宿主 Linux diff --git a/src/platform/Directory.Build.props b/src/platform/Directory.Build.props new file mode 100644 index 00000000..9349228c --- /dev/null +++ b/src/platform/Directory.Build.props @@ -0,0 +1,23 @@ + + + 5.0.2 + Latest + net7.0;net8.0 + true + true + true + false + xiaoxue + xiaoxue + true + snupkg + MIT + https://admin.zhontai.net + https://github.com/zhontai/Admin.Core + git + ZhonTai AdminApi;WebApi;HttpApi; + logo.png + 1701;1702;1591 + $(MSBuildProjectName).xml + + \ No newline at end of file diff --git a/src/platform/ZhonTai.Admin/Core/Auth/ClaimAttributes.cs b/src/platform/ZhonTai.Admin/Core/Auth/ClaimAttributes.cs index 87fda21a..9afa368c 100644 --- a/src/platform/ZhonTai.Admin/Core/Auth/ClaimAttributes.cs +++ b/src/platform/ZhonTai.Admin/Core/Auth/ClaimAttributes.cs @@ -10,7 +10,7 @@ public static class ClaimAttributes /// /// 用户Id /// - public const string UserId = "id"; + public const string UserId = "uid"; /// /// 用户名 diff --git a/src/platform/ZhonTai.Admin/Core/Auth/ResponseAuthenticationHandler.cs b/src/platform/ZhonTai.Admin/Core/Auth/ResponseAuthenticationHandler.cs index e48eb1ea..d155db09 100644 --- a/src/platform/ZhonTai.Admin/Core/Auth/ResponseAuthenticationHandler.cs +++ b/src/platform/ZhonTai.Admin/Core/Auth/ResponseAuthenticationHandler.cs @@ -17,11 +17,20 @@ namespace ZhonTai.Admin.Core.Auth; /// public class ResponseAuthenticationHandler : AuthenticationHandler { +#if NET8_0 public ResponseAuthenticationHandler( IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder - ) : base(options, logger, encoder) + ) : base(options, logger, encoder) +#else + public ResponseAuthenticationHandler( + IOptionsMonitor options, + ILoggerFactory logger, + UrlEncoder encoder, + ISystemClock systemClock + ) : base(options, logger, encoder, systemClock) +#endif { } diff --git a/src/platform/ZhonTai.Admin/Services/Auth/AuthService.cs b/src/platform/ZhonTai.Admin/Services/Auth/AuthService.cs index 29c9c690..72fd35f2 100644 --- a/src/platform/ZhonTai.Admin/Services/Auth/AuthService.cs +++ b/src/platform/ZhonTai.Admin/Services/Auth/AuthService.cs @@ -88,6 +88,7 @@ public class AuthService : BaseService, IAuthService, IDynamicApi new Claim(ClaimAttributes.UserName, user.UserName), new Claim(ClaimAttributes.Name, user.Name), new Claim(ClaimAttributes.UserType, user.Type.ToInt().ToString(), ClaimValueTypes.Integer32), + new Claim(JwtRegisteredClaimNames.Iat, DateTime.Now.ToTimestamp().ToString(), ClaimValueTypes.Integer64), }; if (_appConfig.Tenant) diff --git a/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj b/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj index 64388204..ebe87710 100644 --- a/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj +++ b/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj @@ -1,17 +1,17 @@  中台Admin权限管理接口库 + false - ZhonTai.Admin.xml 1701;1702;1591;8632 - + @@ -40,14 +40,13 @@ - + - - + + - diff --git a/src/platform/ZhonTai.ApiUI/ZhonTai.ApiUI.xml b/src/platform/ZhonTai.ApiUI/ZhonTai.ApiUI.xml new file mode 100644 index 00000000..bb7a8431 --- /dev/null +++ b/src/platform/ZhonTai.ApiUI/ZhonTai.ApiUI.xml @@ -0,0 +1,434 @@ + + + + ZhonTai.ApiUI + + + + + Register the SwaggerUI middleware with provided options + + + + + Register the SwaggerUI middleware with optional setup action for DI-injected options + + + + + Gets or sets a route prefix for accessing the swagger-ui + + + + + Gets or sets a Stream function for retrieving the swagger-ui page + + + + + Gets or sets a title for the swagger-ui page + + + + + Gets or sets additional content to place in the head of the swagger-ui page + + + + + Gets the JavaScript config object, represented as JSON, that will be passed to the SwaggerUI + + + + + Gets the JavaScript config object, represented as JSON, that will be passed to the initOAuth method + + + + + Gets the interceptor functions that define client-side request/response interceptors + + + + + One or more Swagger JSON endpoints (url and name) to power the UI + + + + + If set to true, enables deep linking for tags and operations + + + + + If set to true, it persists authorization data and it would not be lost on browser close/refresh + + + + + Controls the display of operationId in operations list + + + + + The default expansion depth for models (set to -1 completely hide the models) + + + + + The default expansion depth for the model on the model-example section + + + + + Controls how the model is shown when the API is first rendered. + (The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links) + + + + + Controls the display of the request duration (in milliseconds) for Try-It-Out requests + + + + + Controls the default expansion setting for the operations and tags. + It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing) + + + + + If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations + that are shown. Can be an empty string or specific value, in which case filtering will be enabled using that + value as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag + + + + + If set, limits the number of tagged operations displayed to at most this many. The default is to show all operations + + + + + Controls the display of vendor extension (x-) fields and values for Operations, Parameters, and Schema + + + + + Controls the display of extensions (pattern, maxLength, minLength, maximum, minimum) fields and values for Parameters + + + + + OAuth redirect URL + + + + + List of HTTP methods that have the Try it out feature enabled. + An empty array disables Try it out for all operations. This does not filter the operations from the display + + + + + Controls whether the "Try it out" section should be enabled by default. + + + + + By default, Swagger-UI attempts to validate specs against swagger.io's online validator. + You can use this parameter to set a different validator URL, for example for locally deployed validators (Validator Badge). + Setting it to null will disable validation + + + + + Default username for OAuth2 password flow. + + + + + Default clientId + + + + + Default clientSecret + + Setting this exposes the client secrets in inline javascript in the swagger-ui generated html. + + + + Realm query parameter (for oauth1) added to authorizationUrl and tokenUrl + + + + + Application name, displayed in authorization popup + + + + + Scope separator for passing scopes, encoded before calling, default value is a space (encoded value %20) + + + + + String array of initially selected oauth scopes, default is empty array + + + + + Additional query parameters added to authorizationUrl and tokenUrl + + + + + Only activated for the accessCode flow. During the authorization_code request to the tokenUrl, + pass the Client Password using the HTTP Basic Authentication scheme + (Authorization header with Basic base64encode(client_id + client_secret)) + + + + + Only applies to authorizatonCode flows. Proof Key for Code Exchange brings enhanced security for OAuth public clients. + The default is false + + + + + MUST be a valid Javascript function. + Function to intercept remote definition, "Try it out", and OAuth 2.0 requests. + Accepts one argument requestInterceptor(request) and must return the modified request, or a Promise that resolves to the modified request. + Ex: "function (req) { req.headers['MyCustomHeader'] = 'CustomValue'; return req; }" + + + + + MUST be a valid Javascript function. + Function to intercept remote definition, "Try it out", and OAuth 2.0 responses. + Accepts one argument responseInterceptor(response) and must return the modified response, or a Promise that resolves to the modified response. + Ex: "function (res) { console.log(res); return res; }" + + + + + Injects additional CSS stylesheets into the index.html page + + + A path to the stylesheet - i.e. the link "href" attribute + The target media - i.e. the link "media" attribute + + + + Injects additional Javascript files into the index.html page + + + A path to the javascript - i.e. the script "src" attribute + The script type - i.e. the script "type" attribute + + + + Adds Swagger JSON endpoints. Can be fully-qualified or relative to the UI page + + + Can be fully qualified or relative to the current host + The description that appears in the document selector drop-down + + + + Enables deep linking for tags and operations + + + + + + Enables persist authorization data + + + + + + Controls the display of operationId in operations list + + + + + + The default expansion depth for models (set to -1 completely hide the models) + + + + + + + The default expansion depth for the model on the model-example section + + + + + + + Controls how the model is shown when the API is first rendered. + (The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links.) + + + + + + + Controls the display of the request duration (in milliseconds) for Try-It-Out requests + + + + + + Controls the default expansion setting for the operations and tags. + It can be 'List' (expands only the tags), 'Full' (expands the tags and operations) or 'None' (expands nothing) + + + + + + + Enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. + If an expression is provided it will be used and applied initially. + Filtering is case sensitive matching the filter expression anywhere inside the tag + + + + + + + Enables the "Try it out" section by default. + + + + + + Limits the number of tagged operations displayed to at most this many. The default is to show all operations + + + + + + + Controls the display of vendor extension (x-) fields and values for Operations, Parameters, and Schema + + + + + + Controls the display of extensions (pattern, maxLength, minLength, maximum, minimum) fields and values for Parameters + + + + + + List of HTTP methods that have the Try it out feature enabled. An empty array disables Try it out for all operations. + This does not filter the operations from the display + + + + + + + OAuth redirect URL + + + + + + + You can use this parameter to enable the swagger-ui's built-in validator (badge) functionality + Setting it to null will disable validation + + + + + + + Default clientId + + + + + + + Default userName + + + + + + + Default clientSecret + + + + Setting this exposes the client secrets in inline javascript in the swagger-ui generated html. + + + + realm query parameter (for oauth1) added to authorizationUrl and tokenUrl + + + + + + + Application name, displayed in authorization popup + + + + + + + Scope separator for passing scopes, encoded before calling, default value is a space (encoded value %20) + + + + + + + String array of initially selected oauth scopes, default is empty array + + + + + Additional query parameters added to authorizationUrl and tokenUrl + + + + + + + Only activated for the accessCode flow. During the authorization_code request to the tokenUrl, + pass the Client Password using the HTTP Basic Authentication scheme (Authorization header with + Basic base64encoded[client_id:client_secret]). The default is false + + + + + + Only applies to authorizatonCode flows. Proof Key for Code Exchange brings enhanced security for OAuth public clients. + The default is false + + + + + + Function to intercept remote definition, "Try it out", and OAuth 2.0 requests. + + + MUST be a valid Javascript function: (request: SwaggerRequest) => SwaggerRequest + + + + Function to intercept remote definition, "Try it out", and OAuth 2.0 responses. + + + MUST be a valid Javascript function: (response: SwaggerResponse ) => SwaggerResponse + + + diff --git a/src/platform/ZhonTai.Common/ZhonTai.Common.csproj b/src/platform/ZhonTai.Common/ZhonTai.Common.csproj index bd5b1829..785137e3 100644 --- a/src/platform/ZhonTai.Common/ZhonTai.Common.csproj +++ b/src/platform/ZhonTai.Common/ZhonTai.Common.csproj @@ -5,20 +5,26 @@ - ZhonTai.Common.xml 1701;1702;1591;8632 - - - - - - - - + + + + + + + + + + + + + + + diff --git a/src/platform/ZhonTai.Common/ZhonTai.Common.xml b/src/platform/ZhonTai.Common/ZhonTai.Common.xml index 0bef9d27..502ef6b6 100644 --- a/src/platform/ZhonTai.Common/ZhonTai.Common.xml +++ b/src/platform/ZhonTai.Common/ZhonTai.Common.xml @@ -322,9 +322,7 @@ - Pattern:
- (\\d{3})\\d{4}(\\d{4})
- Explanation:
+ Pattern explanation:
○ 1st capture group.
○ Match a Unicode digit exactly 3 times.
@@ -336,9 +334,7 @@
- Pattern:
- (?<=.{2})[^@]+(?=.{2}@)
- Explanation:
+ Pattern explanation:
○ Zero-width positive lookbehind.
○ Match a character other than '\n' exactly 2 times right-to-left.
@@ -351,21 +347,19 @@
- Pattern:
- ([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})
- Explanation:
+ Pattern explanation:
○ 1st capture group.
- ○ Match a character in the set [0-9] atomically at least 1 and at most 3 times.
+ ○ Match '0' through '9' atomically at least 1 and at most 3 times.
○ Match '.'.
○ 2nd capture group.
- ○ Match a character in the set [0-9] atomically at least 1 and at most 3 times.
+ ○ Match '0' through '9' atomically at least 1 and at most 3 times.
○ Match '.'.
○ 3rd capture group.
- ○ Match a character in the set [0-9] atomically at least 1 and at most 3 times.
+ ○ Match '0' through '9' atomically at least 1 and at most 3 times.
○ Match '.'.
○ 4th capture group.
- ○ Match a character in the set [0-9] atomically at least 1 and at most 3 times.
+ ○ Match '0' through '9' atomically at least 1 and at most 3 times.
@@ -572,9 +566,7 @@ - Pattern:
- ^(?=.*[a-zA-Z])(?=.*\\d)[a-zA-Z\\d!@#$%^&.*]{6,16}$
- Explanation:
+ Pattern explanation:
○ Match if at the beginning of the string.
○ Zero-width positive lookahead.
@@ -816,14 +808,5 @@ Whether is non-infinite. - - Finds the next index of any character that matches a Unicode digit. - - - Supports searching for characters in or not in "\0\u0001\u0002\u0003\u0004\u0005\u0006\a\b\t\n\v\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007f". - - - Supports searching for characters in or not in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz". - diff --git a/src/platform/ZhonTai.DynamicApi/ZhonTai.DynamicApi.csproj b/src/platform/ZhonTai.DynamicApi/ZhonTai.DynamicApi.csproj index e10d0bc7..52ccebff 100644 --- a/src/platform/ZhonTai.DynamicApi/ZhonTai.DynamicApi.csproj +++ b/src/platform/ZhonTai.DynamicApi/ZhonTai.DynamicApi.csproj @@ -4,10 +4,6 @@ DynamicApi;WebApi; - - - - diff --git a/src/platform/ZhonTai.DynamicApi/ZhonTai.DynamicApi.xml b/src/platform/ZhonTai.DynamicApi/ZhonTai.DynamicApi.xml new file mode 100644 index 00000000..78c8f909 --- /dev/null +++ b/src/platform/ZhonTai.DynamicApi/ZhonTai.DynamicApi.xml @@ -0,0 +1,235 @@ + + + + ZhonTai.DynamicApi + + + + + Specifies the dynamic webapi options for the assembly. + + + + + Routing prefix for all APIs + + Default value is null. + + + + + API HTTP Verb. + + Default value is null. + + + + + + + Routing prefix for all APIs + API HTTP Verb. + + + + Equivalent to AreaName + + + + + 分组名称列表 + + + + + 不格式化结果数据 + + + + + 排序值 + + + + + 排序设置 + + 排序值 + + + + //不映射指定的方法 + + + + + + + 不格式化结果数据 + + + + + + + Processing action name + + + + + + + API HTTP Verb. + + Default value is "POST". + + + + + Routing prefix for all APIs + + Default value is "api". + + + + + Remove the dynamic API class(Controller) name postfix. + + Default value is {"AppService", "ApplicationService"}. + + + + + Remove the dynamic API class's method(Action) postfix. + + Default value is {"Async"}. + + + + + Ignore MVC Form Binding types. + + + + + Naming convention + + + + + The method that processing the name of the action. + + + + + The method that processing the name of the controller. + + + + + Specifies the dynamic webapi options for the assembly. + + + + + Verify that all configurations are valid + + + + + Add the dynamic webapi options for the assembly. + + + + + + + + Add the dynamic webapi options for the assemblies. + + + + + + + + Add Dynamic WebApi + + + + + Use Dynamic WebApi to Configure + + + + + + + + Add Dynamic WebApi to Container + + + configuration + + + + + camelCase + + + + + PascalCase + + + + + snake_case + + + + + kebab-case + + + + + extension.case + + + + + Customize with GetRestFulControllerName and GetRestFulActionName method + + + + + Gets a single attribute for a member. + + Type of the attribute + The member that will be checked for the attribute + Include inherited attributes + Returns the attribute object if found. Returns null if not found. + + + + 是否成功标记 + + + + + 编码 + + + + + 消息 + + + + + 数据 + + + + diff --git a/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj b/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj index 6bf09ed8..c3a68811 100644 --- a/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj +++ b/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj @@ -1,23 +1,31 @@  - 中台测试库 net8.0 + 中台测试库 false - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - - + + + - + \ No newline at end of file