commit fb4e048302759bef51dc34219c7ec22c2ef18123 Author: wyl3130 <3130921046@qq.com> Date: Sun Jun 15 11:49:34 2025 +0800 添加项目文件。 diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,363 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/CloudTrade-Multi-End.sln b/CloudTrade-Multi-End.sln new file mode 100644 index 0000000..97d7827 --- /dev/null +++ b/CloudTrade-Multi-End.sln @@ -0,0 +1,119 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.35821.62 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{63F83795-5AC1-4F2E-944E-6BAA4564A527}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.Application", "src\CloudTrade.Application\CloudTrade.Application.csproj", "{1BCCD4FB-D372-49BA-A931-7E296A5DDCC6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.Domain", "src\CloudTrade.Domain\CloudTrade.Domain.csproj", "{4C8B2F61-B2A2-422A-B617-6774BE2ADFAF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.Domain.Share", "src\CloudTrade.Domain.Share\CloudTrade.Domain.Share.csproj", "{A5552E11-6939-4CEB-8807-20F7992645BF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.SqlSugarCore", "src\CloudTrade.SqlSugarCore\CloudTrade.SqlSugarCore.csproj", "{0E89EE31-F47F-4430-AADE-7755A1A52E8E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.Application.Contracts", "src\CloudTrade.Application.Contracts\CloudTrade.Application.Contracts.csproj", "{21EAE4CE-9165-4255-BD2A-6E48227146A6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C5890CD7-2A98-4B0B-9B63-10E807507E11}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platform", "Platform", "{CF0B3CA5-8745-413A-9F98-AB5949549DA0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication1", "test\WebApplication1\WebApplication1.csproj", "{3C1E0739-4FED-4BA6-AD5F-35F461EB09DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.HttpApi.Host", "src\CloudTrade.HttpApi.Host\CloudTrade.HttpApi.Host.csproj", "{832774E4-5A31-408C-B581-86B787D5F2B8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade", "src\CloudTrade\CloudTrade\CloudTrade.csproj", "{2D9FF8A9-D9B0-46F9-B979-481881DD7A8F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.Android", "src\CloudTrade\CloudTrade.Android\CloudTrade.Android.csproj", "{CFCF43F8-D02C-4EB2-BC33-50E0668A4306}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.Desktop", "src\CloudTrade\CloudTrade.Desktop\CloudTrade.Desktop.csproj", "{2F0DC098-57DC-46E2-BEE7-5B843A7D216B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.iOS", "src\CloudTrade\CloudTrade.iOS\CloudTrade.iOS.csproj", "{F19A9E19-1A3C-44C6-A396-A0A1FFD9636F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudTrade.Browser", "src\CloudTrade\CloudTrade.Browser\CloudTrade.Browser.csproj", "{E0F0CBFC-DC53-4984-9C0D-614BF85E778B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1BCCD4FB-D372-49BA-A931-7E296A5DDCC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1BCCD4FB-D372-49BA-A931-7E296A5DDCC6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BCCD4FB-D372-49BA-A931-7E296A5DDCC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1BCCD4FB-D372-49BA-A931-7E296A5DDCC6}.Release|Any CPU.Build.0 = Release|Any CPU + {4C8B2F61-B2A2-422A-B617-6774BE2ADFAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C8B2F61-B2A2-422A-B617-6774BE2ADFAF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C8B2F61-B2A2-422A-B617-6774BE2ADFAF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C8B2F61-B2A2-422A-B617-6774BE2ADFAF}.Release|Any CPU.Build.0 = Release|Any CPU + {A5552E11-6939-4CEB-8807-20F7992645BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5552E11-6939-4CEB-8807-20F7992645BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5552E11-6939-4CEB-8807-20F7992645BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5552E11-6939-4CEB-8807-20F7992645BF}.Release|Any CPU.Build.0 = Release|Any CPU + {0E89EE31-F47F-4430-AADE-7755A1A52E8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E89EE31-F47F-4430-AADE-7755A1A52E8E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E89EE31-F47F-4430-AADE-7755A1A52E8E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E89EE31-F47F-4430-AADE-7755A1A52E8E}.Release|Any CPU.Build.0 = Release|Any CPU + {21EAE4CE-9165-4255-BD2A-6E48227146A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21EAE4CE-9165-4255-BD2A-6E48227146A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21EAE4CE-9165-4255-BD2A-6E48227146A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21EAE4CE-9165-4255-BD2A-6E48227146A6}.Release|Any CPU.Build.0 = Release|Any CPU + {3C1E0739-4FED-4BA6-AD5F-35F461EB09DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C1E0739-4FED-4BA6-AD5F-35F461EB09DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C1E0739-4FED-4BA6-AD5F-35F461EB09DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C1E0739-4FED-4BA6-AD5F-35F461EB09DC}.Release|Any CPU.Build.0 = Release|Any CPU + {832774E4-5A31-408C-B581-86B787D5F2B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {832774E4-5A31-408C-B581-86B787D5F2B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {832774E4-5A31-408C-B581-86B787D5F2B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {832774E4-5A31-408C-B581-86B787D5F2B8}.Release|Any CPU.Build.0 = Release|Any CPU + {2D9FF8A9-D9B0-46F9-B979-481881DD7A8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D9FF8A9-D9B0-46F9-B979-481881DD7A8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D9FF8A9-D9B0-46F9-B979-481881DD7A8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D9FF8A9-D9B0-46F9-B979-481881DD7A8F}.Release|Any CPU.Build.0 = Release|Any CPU + {CFCF43F8-D02C-4EB2-BC33-50E0668A4306}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CFCF43F8-D02C-4EB2-BC33-50E0668A4306}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CFCF43F8-D02C-4EB2-BC33-50E0668A4306}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {CFCF43F8-D02C-4EB2-BC33-50E0668A4306}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CFCF43F8-D02C-4EB2-BC33-50E0668A4306}.Release|Any CPU.Build.0 = Release|Any CPU + {CFCF43F8-D02C-4EB2-BC33-50E0668A4306}.Release|Any CPU.Deploy.0 = Release|Any CPU + {2F0DC098-57DC-46E2-BEE7-5B843A7D216B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F0DC098-57DC-46E2-BEE7-5B843A7D216B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F0DC098-57DC-46E2-BEE7-5B843A7D216B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F0DC098-57DC-46E2-BEE7-5B843A7D216B}.Release|Any CPU.Build.0 = Release|Any CPU + {F19A9E19-1A3C-44C6-A396-A0A1FFD9636F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F19A9E19-1A3C-44C6-A396-A0A1FFD9636F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F19A9E19-1A3C-44C6-A396-A0A1FFD9636F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {F19A9E19-1A3C-44C6-A396-A0A1FFD9636F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F19A9E19-1A3C-44C6-A396-A0A1FFD9636F}.Release|Any CPU.Build.0 = Release|Any CPU + {F19A9E19-1A3C-44C6-A396-A0A1FFD9636F}.Release|Any CPU.Deploy.0 = Release|Any CPU + {E0F0CBFC-DC53-4984-9C0D-614BF85E778B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0F0CBFC-DC53-4984-9C0D-614BF85E778B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0F0CBFC-DC53-4984-9C0D-614BF85E778B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0F0CBFC-DC53-4984-9C0D-614BF85E778B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {63F83795-5AC1-4F2E-944E-6BAA4564A527} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {1BCCD4FB-D372-49BA-A931-7E296A5DDCC6} = {63F83795-5AC1-4F2E-944E-6BAA4564A527} + {4C8B2F61-B2A2-422A-B617-6774BE2ADFAF} = {63F83795-5AC1-4F2E-944E-6BAA4564A527} + {A5552E11-6939-4CEB-8807-20F7992645BF} = {63F83795-5AC1-4F2E-944E-6BAA4564A527} + {0E89EE31-F47F-4430-AADE-7755A1A52E8E} = {63F83795-5AC1-4F2E-944E-6BAA4564A527} + {21EAE4CE-9165-4255-BD2A-6E48227146A6} = {63F83795-5AC1-4F2E-944E-6BAA4564A527} + {CF0B3CA5-8745-413A-9F98-AB5949549DA0} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {3C1E0739-4FED-4BA6-AD5F-35F461EB09DC} = {C5890CD7-2A98-4B0B-9B63-10E807507E11} + {832774E4-5A31-408C-B581-86B787D5F2B8} = {63F83795-5AC1-4F2E-944E-6BAA4564A527} + {2D9FF8A9-D9B0-46F9-B979-481881DD7A8F} = {CF0B3CA5-8745-413A-9F98-AB5949549DA0} + {CFCF43F8-D02C-4EB2-BC33-50E0668A4306} = {CF0B3CA5-8745-413A-9F98-AB5949549DA0} + {2F0DC098-57DC-46E2-BEE7-5B843A7D216B} = {CF0B3CA5-8745-413A-9F98-AB5949549DA0} + {F19A9E19-1A3C-44C6-A396-A0A1FFD9636F} = {CF0B3CA5-8745-413A-9F98-AB5949549DA0} + {E0F0CBFC-DC53-4984-9C0D-614BF85E778B} = {CF0B3CA5-8745-413A-9F98-AB5949549DA0} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D67AC370-FB17-477C-A459-EB3CED13265A} + EndGlobalSection +EndGlobal diff --git a/src/CloudTrade.Application.Contracts/CloudTrade.Application.Contracts.csproj b/src/CloudTrade.Application.Contracts/CloudTrade.Application.Contracts.csproj new file mode 100644 index 0000000..125f4c9 --- /dev/null +++ b/src/CloudTrade.Application.Contracts/CloudTrade.Application.Contracts.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + + diff --git a/src/CloudTrade.Application.Contracts/IUserService.cs b/src/CloudTrade.Application.Contracts/IUserService.cs new file mode 100644 index 0000000..6d7d7ca --- /dev/null +++ b/src/CloudTrade.Application.Contracts/IUserService.cs @@ -0,0 +1,7 @@ +namespace CloudTrade.Application.Contracts +{ + public interface IUserService + { + string LoginAsync(); + } +} diff --git a/src/CloudTrade.Application/CloudTrade.Application.csproj b/src/CloudTrade.Application/CloudTrade.Application.csproj new file mode 100644 index 0000000..81f85da --- /dev/null +++ b/src/CloudTrade.Application/CloudTrade.Application.csproj @@ -0,0 +1,13 @@ + + + + net9.0 + enable + enable + + + + + + + diff --git a/src/CloudTrade.Application/UserService.cs b/src/CloudTrade.Application/UserService.cs new file mode 100644 index 0000000..35217c7 --- /dev/null +++ b/src/CloudTrade.Application/UserService.cs @@ -0,0 +1,12 @@ +using CloudTrade.Application.Contracts; + +namespace CloudTrade.Application +{ + public class UserService : IUserService + { + public string LoginAsync() + { + return "admin"; + } + } +} diff --git a/src/CloudTrade.Domain.Share/CloudTrade.Domain.Share.csproj b/src/CloudTrade.Domain.Share/CloudTrade.Domain.Share.csproj new file mode 100644 index 0000000..50a72cf --- /dev/null +++ b/src/CloudTrade.Domain.Share/CloudTrade.Domain.Share.csproj @@ -0,0 +1,18 @@ + + + + net9.0 + enable + enable + + + + + + + + + + + + diff --git a/src/CloudTrade.Domain.Share/Response.cs b/src/CloudTrade.Domain.Share/Response.cs new file mode 100644 index 0000000..4912c90 --- /dev/null +++ b/src/CloudTrade.Domain.Share/Response.cs @@ -0,0 +1,44 @@ +namespace CloudTrade.Domain.Share +{ + public class Response + { + // 是否成功,默认为 true + public bool Success { get; set; } = true; + + // 响应消息 + public string Message { get; set; } + + // 异常码 + public string ErrorCode { get; set; } + + // 响应数据 + public T Data { get; set; } + + // =================================== 成功响应 =================================== + public static Response SuccessResponse() + { + return new Response(); + } + + public static Response SuccessResponse(T data) + { + return new Response { Data = data }; + } + + // =================================== 失败响应 =================================== + public static Response FailResponse() + { + return new Response { Success = false }; + } + + public static Response FailResponse(string errorMessage) + { + return new Response { Success = false, Message = errorMessage }; + } + + public static Response FailResponse(string errorCode, string errorMessage) + { + return new Response { Success = false, ErrorCode = errorCode, Message = errorMessage }; + } + } +} diff --git a/src/CloudTrade.Domain.Share/log4net.config b/src/CloudTrade.Domain.Share/log4net.config new file mode 100644 index 0000000..1764acf --- /dev/null +++ b/src/CloudTrade.Domain.Share/log4net.config @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CloudTrade.Domain/Class1.cs b/src/CloudTrade.Domain/Class1.cs new file mode 100644 index 0000000..a3c2252 --- /dev/null +++ b/src/CloudTrade.Domain/Class1.cs @@ -0,0 +1,7 @@ +namespace CloudTrade.Domain +{ + public class Class1 + { + + } +} diff --git a/src/CloudTrade.Domain/CloudTrade.Domain.csproj b/src/CloudTrade.Domain/CloudTrade.Domain.csproj new file mode 100644 index 0000000..125f4c9 --- /dev/null +++ b/src/CloudTrade.Domain/CloudTrade.Domain.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + + diff --git a/src/CloudTrade.HttpApi.Host/CloudTrade.HttpApi.Host.csproj b/src/CloudTrade.HttpApi.Host/CloudTrade.HttpApi.Host.csproj new file mode 100644 index 0000000..1c7713a --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/CloudTrade.HttpApi.Host.csproj @@ -0,0 +1,30 @@ + + + + net9.0 + enable + enable + True + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CloudTrade.HttpApi.Host/CloudTrade.HttpApi.Host.http b/src/CloudTrade.HttpApi.Host/CloudTrade.HttpApi.Host.http new file mode 100644 index 0000000..392850f --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/CloudTrade.HttpApi.Host.http @@ -0,0 +1,6 @@ +@CloudTrade.HttpApi.Host_HostAddress = http://localhost:5181 + +GET {{CloudTrade.HttpApi.Host_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/src/CloudTrade.HttpApi.Host/Controllers/AccountController.cs b/src/CloudTrade.HttpApi.Host/Controllers/AccountController.cs new file mode 100644 index 0000000..6b281d1 --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/Controllers/AccountController.cs @@ -0,0 +1,38 @@ +using CloudTrade.Domain.Share; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; + +namespace CloudTrade.HttpApi.Host.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class AccountController : ControllerBase + { + private readonly TokenManagement tokenManagement; + public AccountController(IOptions tokenManagement) + { + this.tokenManagement = tokenManagement.Value; + } + + [HttpPost] + public IActionResult Login(string UserName,string PassWord) + { + if (UserName == "admin" && PassWord == "admin") + { + // 模拟生成 JWT Token + var token = JwtHelper.GetToken("admin","admin",tokenManagement.Secret,tokenManagement.Issuer,tokenManagement.Audience,tokenManagement.AccessExpiration); + return Ok(new Response() { + Success=true, + Message="登录成功", + ErrorCode=null, + Data = new { token=token } + }); + } + else + { + return Unauthorized("Invalid username or password."); + } + } + } +} diff --git a/src/CloudTrade.HttpApi.Host/Controllers/WeatherForecastController.cs b/src/CloudTrade.HttpApi.Host/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..2f94c02 --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace CloudTrade.HttpApi.Host.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/src/CloudTrade.HttpApi.Host/JwtHelper.cs b/src/CloudTrade.HttpApi.Host/JwtHelper.cs new file mode 100644 index 0000000..9bc6aa2 --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/JwtHelper.cs @@ -0,0 +1,43 @@ +using Microsoft.IdentityModel.Tokens; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using System.Text; + +namespace CloudTrade.HttpApi.Host +{ + public static class JwtHelper + { + public static string GetToken(string UserName, string Role, string Secret, string Issuer, string Audience, double AccessExpiration) + { + var claims = new[] { + new Claim(ClaimTypes.Name,UserName), + new Claim(ClaimTypes.Role,Role), + }; + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Secret)); + var credential = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + var token = new JwtSecurityToken(Issuer, Audience, claims, expires: DateTime.Now.AddMinutes(AccessExpiration), signingCredentials: credential); + var jwt = new JwtSecurityTokenHandler().WriteToken(token); + return jwt; + } + + public static string GetUserNameFromJWT(string token, string Secret) + { + var tokenHandler = new JwtSecurityTokenHandler(); + var key = Encoding.UTF8.GetBytes(Secret); + tokenHandler.ValidateToken(token, new TokenValidationParameters + { + ValidateIssuerSigningKey = true, + IssuerSigningKey = new SymmetricSecurityKey(key), + ValidateIssuer = false, + ValidateAudience = false, + // Set ClockSkew to zero so tokens expire exactly at token expiration time (instead of 5 minutes later) + ClockSkew = TimeSpan.Zero + }, out SecurityToken validatedToken); + + var jwtToken = (JwtSecurityToken)validatedToken; + var userName = jwtToken.Claims.First(x => x.Type == ClaimTypes.Name).Value; + + return userName; + } + } +} diff --git a/src/CloudTrade.HttpApi.Host/Program.cs b/src/CloudTrade.HttpApi.Host/Program.cs new file mode 100644 index 0000000..c582736 --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/Program.cs @@ -0,0 +1,367 @@ +using AspNetCore.Authentication.Basic; +using Autofac; +using Autofac.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.IdentityModel.Tokens; +using Microsoft.OpenApi.Models; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security.Claims; +using System.Text; +using System.Text.Json.Serialization; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); +builder.Services.AddEndpointsApiExplorer(); +//IConfigurationʵ ȡϢ +var IConfiguration = new ConfigurationBuilder() + //Ҫȡļ 仯ʱ¼ + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .Build(); +builder.Services.Configure(IConfiguration.GetSection("token")); +var token = IConfiguration.GetSection("token").Get(); + + +ConfigureCors(builder.Services); // +ConfigureAuthentication(builder.Services); //Ȩ +ConfigureSwagger(builder.Services); //ӿĵ +ConfigureJson(builder.Services); //json +ConfigureAutofac(builder.Host); //autofac + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} +app.UseAuthentication(); +app.UseAuthorization(); +app.UseSwagger(); +app.UseSwaggerUI(); +app.MapControllers(); +//app.UseWelcomePage(); +app.UseCors("Allow"); //ʹÿ +app.Run(); + +//ȡjsonСд +void ConfigureJson(IServiceCollection Services) +{ + Services.AddControllers().AddJsonOptions(options => + { + options.JsonSerializerOptions.PropertyNamingPolicy = null; + }); +} +// +void ConfigureCors(IServiceCollection services) +{ + services.AddCors(x => + { + x.AddPolicy("Allow", x => + { + x.AllowAnyMethod(); + x.AllowAnyHeader(); + x.AllowAnyOrigin(); + // x.AllowCredentials(); + }); + }); + +} + +void ConfigureSwagger(IServiceCollection services) +{ + + services.AddSwaggerGen(x => + { + x.SwaggerDoc("v1", new OpenApiInfo { Title = builder.Environment.ApplicationName, Version = "v1" }); + var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; + var xmlFile = AppDomain.CurrentDomain.FriendlyName + ".xml"; + var xmlPath = Path.Combine(baseDirectory, xmlFile); + x.IncludeXmlComments(xmlPath, true); + x.OrderActionsBy(x => x.RelativePath); + x.CustomOperationIds(x => + { + var controllerAction = x.ActionDescriptor as ControllerActionDescriptor; + return controllerAction.ControllerName + "-" + controllerAction.ActionName; + }); + x.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFile), true); + + // JWT + x.AddSecurityDefinition("Bearer", new Microsoft.OpenApi.Models.OpenApiSecurityScheme() + { + Description = "Enter the JWT authorization token in the request header: Bearer Token", + Name = "Authorization", + In = ParameterLocation.Header, + Type = SecuritySchemeType.ApiKey, + BearerFormat = "JWT", + Scheme = "Bearer", + }); + x.AddSecurityRequirement(new Microsoft.OpenApi.Models.OpenApiSecurityRequirement() + { + { + new OpenApiSecurityScheme(){ + Reference = new OpenApiReference(){ + Type=ReferenceType.SecurityScheme, + Id="Bearer" + } + },new string[]{ } + } + }); + // OAuth ֤֧ + x.AddSecurityDefinition("OAuth2", new OpenApiSecurityScheme + { + Description = "OAuth2 Authorization: Click the authorize button below to redirect to third-party authentication.", + Name = "Authorization", + In = ParameterLocation.Header, + BearerFormat = "JWT", + Scheme = "Bearer", + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows + { + AuthorizationCode = new OpenApiOAuthFlow + { + AuthorizationUrl = new Uri("http://localhost:32769/connect/authorize"), // OAuthȨ˵ + TokenUrl = new Uri("http://localhost:32769/connect/token"), // OAuthƶ˵ + Scopes = new Dictionary + { +{ "Account", "User registration and login" }, +{ "Email", "Email verification, send verification code" } + } + } + }, + + }); + x.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "OAuth2" + } + }, + new string[] { } + } + }); + // Basic ֤ + x.AddSecurityDefinition("Basic", new OpenApiSecurityScheme + { + Name = "Authorization", + Type = SecuritySchemeType.Http, + Scheme = "basic", + In = ParameterLocation.Header, + Description = "Basic Authentication" + }); + x.AddSecurityRequirement(new OpenApiSecurityRequirement{ + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Basic" } + }, + Array.Empty() + } + }); + + // Cookie ֤ + x.AddSecurityDefinition("Cookie", new OpenApiSecurityScheme + { + Name = "Cookie", + Type = SecuritySchemeType.ApiKey, + In = ParameterLocation.Cookie, + Description = "Enter your session cookie" + }); + x.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "Cookie" + } + }, + new string[] { } + } + }); + + x.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme() + { + In = ParameterLocation.Header, + Name = "X-API-KEY", + Type = SecuritySchemeType.ApiKey, + Description = "API KEY Authentication" + }); + x.AddSecurityRequirement(new OpenApiSecurityRequirement() + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "ApiKey" + } + }, + new string[] { } + } + }); + }); + + +} +void ConfigureAuthentication(IServiceCollection services) +{ + services.AddAuthentication(x => + { + x.DefaultAuthenticateScheme = "MultiAuthSchemes"; + x.DefaultChallengeScheme = "MultiAuthSchemes"; + x.DefaultForbidScheme = "MultiAuthSchemes"; + + + }).AddPolicyScheme("MultiAuthSchemes", "MultiAuthSchemes", options => + { + // Էͷʹĸ巽 + options.ForwardDefaultSelector = context => + { + // Authorizationͷ + string authorization = context.Request.Headers["Authorization"].FirstOrDefault(); + + if (!string.IsNullOrEmpty(authorization)) + { + if (authorization.StartsWith("Bearer ")) + return JwtBearerDefaults.AuthenticationScheme; + + if (authorization.StartsWith("Basic ")) + return "Basic"; + } + + // cookie + if (context.Request.Cookies.ContainsKey("AuthCookie")) + return CookieAuthenticationDefaults.AuthenticationScheme; + + // ĬϷJWTɸҪ޸ģ + return JwtBearerDefaults.AuthenticationScheme; + }; + }) + + .AddJwtBearer(x => + { + x.RequireHttpsMetadata = false; + x.SaveToken = true; + x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() + { + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(token.Secret)), + ValidIssuer = token.Issuer, + ValidAudience = token.Audience, + ValidateIssuerSigningKey = true,//Ƿ֤SecurityKey + ValidateIssuer = true, //Ƿ֤Issuer + ValidateAudience = true, //Ƿ֤Audience + ValidateLifetime = true, //Ƿ֤ʧЧʱ + ClockSkew = TimeSpan.FromSeconds(30),//ʱݴֵ + RequireExpirationTime = true + }; + }) + .AddOAuth("OAuth", x => + { + x.ClientId = "Yu_App"; + x.ClientSecret = "123456"; + x.CallbackPath = "/signin-oauth"; + x.AuthorizationEndpoint = "1"; + x.TokenEndpoint = "1"; + x.Scope.Add(""); + x.SaveTokens = true; + x.Events = new Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents() + { + OnCreatingTicket = context => + { + // ﴦ OAuth صݣȡûϢ + + var identity = context.Principal.Identity; + var tokens = context.AccessToken; + var claimsIdentity = context.Principal.Identity as ClaimsIdentity; + claimsIdentity?.AddClaim(new Claim("access_token", context.AccessToken)); + + return Task.CompletedTask; + } + }; + }).AddCookie("Cookie", x => { + + x.ClaimsIssuer = "admin"; + + }) + + .AddBasic("Basic", x => + { + x.Realm = "CloudTrade"; + x.ClaimsIssuer = "admin"; + x.SuppressWWWAuthenticateHeader = false; + + x.Events = new BasicEvents() + { + OnValidateCredentials = context => + { + if (context.Username == "admin" && context.Password == "admin") + { + var claims = new[] { + new Claim(ClaimTypes.Name,context.Username) + }; + context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); + context.Success(); + } + return Task.CompletedTask; + } + }; + }) + + ; + + // services.AddAuthentication("ApiKey").AddScheme + + + // services.AddAuthentication("Basic").AddScheme("Basic", null); +} + +void ConfigureAutofac(IHostBuilder builder) +{ + builder.UseServiceProviderFactory(new AutofacServiceProviderFactory()); + builder.ConfigureContainer(options => + { + options.RegisterModule(new AutofacModuleRegister()); + }); +} + +public class AutofacModuleRegister : Autofac.Module +{ + protected override void Load(ContainerBuilder builder) + { + Assembly interfaceAssembly = Assembly.Load("CloudTrade.Application"); + Assembly serviceAssembly = Assembly.Load("CloudTrade.Application.Contracts"); + + builder.RegisterAssemblyTypes(interfaceAssembly, serviceAssembly).AsImplementedInterfaces(); + } +} +public class TokenManagement +{ + [JsonPropertyName("Secret")] + public string Secret { get; set; } + [JsonPropertyName("Issuer")] + public string Issuer { get; set; } + [JsonPropertyName("Audience")] + public string Audience { get; set; } + [JsonPropertyName("AccessExpiration")] + public int AccessExpiration { get; set; } + [JsonPropertyName("RefreshExpiration")] + public int RefreshExpiration { get; set; } +} + + diff --git a/src/CloudTrade.HttpApi.Host/Properties/launchSettings.json b/src/CloudTrade.HttpApi.Host/Properties/launchSettings.json new file mode 100644 index 0000000..f4639c3 --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/Properties/launchSettings.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5181", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/CloudTrade.HttpApi.Host/WeatherForecast.cs b/src/CloudTrade.HttpApi.Host/WeatherForecast.cs new file mode 100644 index 0000000..4931d94 --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace CloudTrade.HttpApi.Host +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/src/CloudTrade.HttpApi.Host/appsettings.Development.json b/src/CloudTrade.HttpApi.Host/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/CloudTrade.HttpApi.Host/appsettings.json b/src/CloudTrade.HttpApi.Host/appsettings.json new file mode 100644 index 0000000..fbf9060 --- /dev/null +++ b/src/CloudTrade.HttpApi.Host/appsettings.json @@ -0,0 +1,21 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "token": { + "Secret": "12345678123456781234567812345678", //密钥 + "Issuer": "test.cn", //签发者 + "Audience": "test", //接收者 + "AccessExpiration": 30, //过期时间 + "RefreshExpiration": 60 //刷新时间 + }, + "ConnectionStrings": { + "MasterYuCloud": "server=154.201.64.195;database=test;uid=sa;pwd=Wuhuize1.", + "SlaveYuCloud1": "", + "SlaveYuCloud2": "" + } +} \ No newline at end of file diff --git a/src/CloudTrade.SqlSugarCore/CloudTrade.SqlSugarCore.csproj b/src/CloudTrade.SqlSugarCore/CloudTrade.SqlSugarCore.csproj new file mode 100644 index 0000000..7a43efb --- /dev/null +++ b/src/CloudTrade.SqlSugarCore/CloudTrade.SqlSugarCore.csproj @@ -0,0 +1,13 @@ + + + + net9.0 + enable + enable + + + + + + + diff --git a/src/CloudTrade.SqlSugarCore/SqlSugarCoreDbContext.cs b/src/CloudTrade.SqlSugarCore/SqlSugarCoreDbContext.cs new file mode 100644 index 0000000..b5f6a00 --- /dev/null +++ b/src/CloudTrade.SqlSugarCore/SqlSugarCoreDbContext.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Http; +using SqlSugar; + +namespace CloudTrade.SqlSugarCore +{ + public class SqlSugarCoreDbContext + { + private readonly ISqlSugarClient db; + public SqlSugarCoreDbContext(IHttpContextAccessor httpContextAccessor,ISqlSugarClient db) + { + this.db = db; + + var tenantId = httpContextAccessor.HttpContext.Items["Tenant"].ToString(); // 获取租户信息 + + // 动态构建连接字符串 + var connectionString = $"Server=myserver;Database={tenantId}_Db;User Id=sa;Password=Wuhuize1.;TrustServerCertificate=True"; + + // 初始化 SqlSugar 客户端 + db = new SqlSugarClient(new ConnectionConfig + { + ConnectionString = connectionString, + DbType = DbType.SqlServer, // 数据库类型 + IsAutoCloseConnection = true, + InitKeyType = InitKeyType.Attribute + }); + } + + public ISqlSugarClient Db => db; + + } +} diff --git a/src/CloudTrade/.gitignore b/src/CloudTrade/.gitignore new file mode 100644 index 0000000..8afdcb6 --- /dev/null +++ b/src/CloudTrade/.gitignore @@ -0,0 +1,454 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# JetBrains Rider +.idea/ +*.sln.iml + +## +## Visual Studio Code +## +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json diff --git a/src/CloudTrade/CloudTrade.Android/CloudTrade.Android.csproj b/src/CloudTrade/CloudTrade.Android/CloudTrade.Android.csproj new file mode 100644 index 0000000..554f0ed --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/CloudTrade.Android.csproj @@ -0,0 +1,28 @@ + + + Exe + net9.0-android + 21 + enable + com.CompanyName.CloudTrade + 1 + 1.0 + apk + false + + + + + Resources\drawable\Icon.png + + + + + + + + + + + + diff --git a/src/CloudTrade/CloudTrade.Android/Icon.png b/src/CloudTrade/CloudTrade.Android/Icon.png new file mode 100644 index 0000000..3c39845 Binary files /dev/null and b/src/CloudTrade/CloudTrade.Android/Icon.png differ diff --git a/src/CloudTrade/CloudTrade.Android/MainActivity.cs b/src/CloudTrade/CloudTrade.Android/MainActivity.cs new file mode 100644 index 0000000..ebaaae0 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/MainActivity.cs @@ -0,0 +1,24 @@ +using Android.App; +using Android.Content.PM; +using Avalonia; +using Avalonia.Android; +using Avalonia.ReactiveUI; + +namespace CloudTrade.Android +{ + [Activity( + Label = "CloudTrade.Android", + Theme = "@style/MyTheme.NoActionBar", + Icon = "@drawable/icon", + MainLauncher = true, + ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)] + public class MainActivity : AvaloniaMainActivity + { + protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) + { + return base.CustomizeAppBuilder(builder) + .WithInterFont() + .UseReactiveUI(); + } + } +} diff --git a/src/CloudTrade/CloudTrade.Android/Properties/AndroidManifest.xml b/src/CloudTrade/CloudTrade.Android/Properties/AndroidManifest.xml new file mode 100644 index 0000000..86287b8 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/Properties/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/CloudTrade/CloudTrade.Android/Resources/AboutResources.txt b/src/CloudTrade/CloudTrade.Android/Resources/AboutResources.txt new file mode 100644 index 0000000..c2bca97 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.axml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.axml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "R" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the R class would expose: + +public class R { + public class drawable { + public const int icon = 0x123; + } + + public class layout { + public const int main = 0x456; + } + + public class strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main +to reference the layout/main.axml file, or R.strings.first_string to reference the first +string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/src/CloudTrade/CloudTrade.Android/Resources/drawable-night-v31/avalonia_anim.xml b/src/CloudTrade/CloudTrade.Android/Resources/drawable-night-v31/avalonia_anim.xml new file mode 100644 index 0000000..dde4b5a --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/Resources/drawable-night-v31/avalonia_anim.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CloudTrade/CloudTrade.Android/Resources/drawable-v31/avalonia_anim.xml b/src/CloudTrade/CloudTrade.Android/Resources/drawable-v31/avalonia_anim.xml new file mode 100644 index 0000000..94f27d9 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/Resources/drawable-v31/avalonia_anim.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CloudTrade/CloudTrade.Android/Resources/drawable/splash_screen.xml b/src/CloudTrade/CloudTrade.Android/Resources/drawable/splash_screen.xml new file mode 100644 index 0000000..2e920b4 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/Resources/drawable/splash_screen.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/src/CloudTrade/CloudTrade.Android/Resources/values-night/colors.xml b/src/CloudTrade/CloudTrade.Android/Resources/values-night/colors.xml new file mode 100644 index 0000000..3d47b6f --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/Resources/values-night/colors.xml @@ -0,0 +1,4 @@ + + + #212121 + diff --git a/src/CloudTrade/CloudTrade.Android/Resources/values-v31/styles.xml b/src/CloudTrade/CloudTrade.Android/Resources/values-v31/styles.xml new file mode 100644 index 0000000..d5ecec4 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/Resources/values-v31/styles.xml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/src/CloudTrade/CloudTrade.Android/Resources/values/colors.xml b/src/CloudTrade/CloudTrade.Android/Resources/values/colors.xml new file mode 100644 index 0000000..59279d5 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/Resources/values/colors.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + diff --git a/src/CloudTrade/CloudTrade.Android/Resources/values/styles.xml b/src/CloudTrade/CloudTrade.Android/Resources/values/styles.xml new file mode 100644 index 0000000..6e534de --- /dev/null +++ b/src/CloudTrade/CloudTrade.Android/Resources/values/styles.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/src/CloudTrade/CloudTrade.Browser/CloudTrade.Browser.csproj b/src/CloudTrade/CloudTrade.Browser/CloudTrade.Browser.csproj new file mode 100644 index 0000000..84121e9 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Browser/CloudTrade.Browser.csproj @@ -0,0 +1,16 @@ + + + net9.0-browser + Exe + true + enable + + + + + + + + + + diff --git a/src/CloudTrade/CloudTrade.Browser/Program.cs b/src/CloudTrade/CloudTrade.Browser/Program.cs new file mode 100644 index 0000000..b040f89 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Browser/Program.cs @@ -0,0 +1,17 @@ +using Avalonia; +using Avalonia.Browser; +using Avalonia.ReactiveUI; +using CloudTrade; +using System.Runtime.Versioning; +using System.Threading.Tasks; + +internal sealed partial class Program +{ + private static Task Main(string[] args) => BuildAvaloniaApp() + .WithInterFont() + .UseReactiveUI() + .StartBrowserAppAsync("out"); + + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure(); +} \ No newline at end of file diff --git a/src/CloudTrade/CloudTrade.Browser/Properties/AssemblyInfo.cs b/src/CloudTrade/CloudTrade.Browser/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c4039b7 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Browser/Properties/AssemblyInfo.cs @@ -0,0 +1 @@ +[assembly: System.Runtime.Versioning.SupportedOSPlatform("browser")] diff --git a/src/CloudTrade/CloudTrade.Browser/Properties/launchSettings.json b/src/CloudTrade/CloudTrade.Browser/Properties/launchSettings.json new file mode 100644 index 0000000..a6e8513 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Browser/Properties/launchSettings.json @@ -0,0 +1,13 @@ +{ + "profiles": { + "CloudTrade.Browser": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:7169;http://localhost:5235", + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}" + } + } +} diff --git a/src/CloudTrade/CloudTrade.Browser/runtimeconfig.template.json b/src/CloudTrade/CloudTrade.Browser/runtimeconfig.template.json new file mode 100644 index 0000000..b96a943 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Browser/runtimeconfig.template.json @@ -0,0 +1,10 @@ +{ + "wasmHostProperties": { + "perHostConfig": [ + { + "name": "browser", + "host": "browser" + } + ] + } +} \ No newline at end of file diff --git a/src/CloudTrade/CloudTrade.Browser/wwwroot/app.css b/src/CloudTrade/CloudTrade.Browser/wwwroot/app.css new file mode 100644 index 0000000..1d6f754 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Browser/wwwroot/app.css @@ -0,0 +1,58 @@ +/* HTML styles for the splash screen */ +.avalonia-splash { + position: absolute; + height: 100%; + width: 100%; + background: white; + font-family: 'Outfit', sans-serif; + justify-content: center; + align-items: center; + display: flex; + pointer-events: none; +} + +/* Light theme styles */ +@media (prefers-color-scheme: light) { + .avalonia-splash { + background: white; + } + + .avalonia-splash h2 { + color: #1b2a4e; + } + + .avalonia-splash a { + color: #0D6EFD; + } +} + +@media (prefers-color-scheme: dark) { + .avalonia-splash { + background: #1b2a4e; + } + + .avalonia-splash h2 { + color: white; + } + + .avalonia-splash a { + color: white; + } +} + +.avalonia-splash h2 { + font-weight: 400; + font-size: 1.5rem; +} + +.avalonia-splash a { + text-decoration: none; + font-size: 2.5rem; + display: block; +} + +.avalonia-splash.splash-close { + transition: opacity 200ms, display 200ms; + display: none; + opacity: 0; +} diff --git a/src/CloudTrade/CloudTrade.Browser/wwwroot/favicon.ico b/src/CloudTrade/CloudTrade.Browser/wwwroot/favicon.ico new file mode 100644 index 0000000..f7da8bb Binary files /dev/null and b/src/CloudTrade/CloudTrade.Browser/wwwroot/favicon.ico differ diff --git a/src/CloudTrade/CloudTrade.Browser/wwwroot/index.html b/src/CloudTrade/CloudTrade.Browser/wwwroot/index.html new file mode 100644 index 0000000..9c83051 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Browser/wwwroot/index.html @@ -0,0 +1,36 @@ + + + + + CloudTrade.Browser + + + + + + +
+
+

+ Powered by + + + + + + + + + + + + + + +

+
+
+ + + + diff --git a/src/CloudTrade/CloudTrade.Browser/wwwroot/main.js b/src/CloudTrade/CloudTrade.Browser/wwwroot/main.js new file mode 100644 index 0000000..bf1555e --- /dev/null +++ b/src/CloudTrade/CloudTrade.Browser/wwwroot/main.js @@ -0,0 +1,13 @@ +import { dotnet } from './_framework/dotnet.js' + +const is_browser = typeof window != "undefined"; +if (!is_browser) throw new Error(`Expected to be running in a browser`); + +const dotnetRuntime = await dotnet + .withDiagnosticTracing(false) + .withApplicationArgumentsFromQuery() + .create(); + +const config = dotnetRuntime.getConfig(); + +await dotnetRuntime.runMain(config.mainAssemblyName, [globalThis.location.href]); diff --git a/src/CloudTrade/CloudTrade.Desktop/CloudTrade.Desktop.csproj b/src/CloudTrade/CloudTrade.Desktop/CloudTrade.Desktop.csproj new file mode 100644 index 0000000..975f50b --- /dev/null +++ b/src/CloudTrade/CloudTrade.Desktop/CloudTrade.Desktop.csproj @@ -0,0 +1,27 @@ + + + WinExe + + net9.0 + enable + true + + + + app.manifest + + + + + + + None + All + + + + + + + diff --git a/src/CloudTrade/CloudTrade.Desktop/Program.cs b/src/CloudTrade/CloudTrade.Desktop/Program.cs new file mode 100644 index 0000000..64349d6 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Desktop/Program.cs @@ -0,0 +1,24 @@ +using Avalonia; +using Avalonia.ReactiveUI; +using System; + +namespace CloudTrade.Desktop +{ + internal sealed class Program + { + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .UseReactiveUI() + .LogToTrace(); + } +} diff --git a/src/CloudTrade/CloudTrade.Desktop/Properties/launchSettings.json b/src/CloudTrade/CloudTrade.Desktop/Properties/launchSettings.json new file mode 100644 index 0000000..02250b1 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Desktop/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "CloudTrade.Desktop": { + "commandName": "Project" + }, + "WSL": { + "commandName": "WSL2", + "distributionName": "" + } + } +} \ No newline at end of file diff --git a/src/CloudTrade/CloudTrade.Desktop/app.manifest b/src/CloudTrade/CloudTrade.Desktop/app.manifest new file mode 100644 index 0000000..9f0acf2 --- /dev/null +++ b/src/CloudTrade/CloudTrade.Desktop/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/src/CloudTrade/CloudTrade.iOS/AppDelegate.cs b/src/CloudTrade/CloudTrade.iOS/AppDelegate.cs new file mode 100644 index 0000000..8aec290 --- /dev/null +++ b/src/CloudTrade/CloudTrade.iOS/AppDelegate.cs @@ -0,0 +1,26 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.iOS; +using Avalonia.Media; +using Avalonia.ReactiveUI; +using Foundation; +using UIKit; + +namespace CloudTrade.iOS +{ + // The UIApplicationDelegate for the application. This class is responsible for launching the + // User Interface of the application, as well as listening (and optionally responding) to + // application events from iOS. + [Register("AppDelegate")] +#pragma warning disable CA1711 // Identifiers should not have incorrect suffix + public partial class AppDelegate : AvaloniaAppDelegate +#pragma warning restore CA1711 // Identifiers should not have incorrect suffix + { + protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) + { + return base.CustomizeAppBuilder(builder) + .WithInterFont() + .UseReactiveUI(); + } + } +} diff --git a/src/CloudTrade/CloudTrade.iOS/CloudTrade.iOS.csproj b/src/CloudTrade/CloudTrade.iOS/CloudTrade.iOS.csproj new file mode 100644 index 0000000..72b2035 --- /dev/null +++ b/src/CloudTrade/CloudTrade.iOS/CloudTrade.iOS.csproj @@ -0,0 +1,16 @@ + + + Exe + net9.0-ios + 13.0 + enable + + + + + + + + + + diff --git a/src/CloudTrade/CloudTrade.iOS/Entitlements.plist b/src/CloudTrade/CloudTrade.iOS/Entitlements.plist new file mode 100644 index 0000000..0c67376 --- /dev/null +++ b/src/CloudTrade/CloudTrade.iOS/Entitlements.plist @@ -0,0 +1,5 @@ + + + + + diff --git a/src/CloudTrade/CloudTrade.iOS/Info.plist b/src/CloudTrade/CloudTrade.iOS/Info.plist new file mode 100644 index 0000000..d073087 --- /dev/null +++ b/src/CloudTrade/CloudTrade.iOS/Info.plist @@ -0,0 +1,43 @@ + + + + + CFBundleDisplayName + CloudTrade + CFBundleIdentifier + companyName.CloudTrade + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + MinimumOSVersion + 13.0 + UIDeviceFamily + + 1 + 2 + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/src/CloudTrade/CloudTrade.iOS/Main.cs b/src/CloudTrade/CloudTrade.iOS/Main.cs new file mode 100644 index 0000000..4cac6a7 --- /dev/null +++ b/src/CloudTrade/CloudTrade.iOS/Main.cs @@ -0,0 +1,15 @@ +using UIKit; + +namespace CloudTrade.iOS +{ + public class Application + { + // This is the main entry point of the application. + static void Main(string[] args) + { + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main(args, null, typeof(AppDelegate)); + } + } +} diff --git a/src/CloudTrade/CloudTrade.iOS/Resources/LaunchScreen.xib b/src/CloudTrade/CloudTrade.iOS/Resources/LaunchScreen.xib new file mode 100644 index 0000000..9f7243e --- /dev/null +++ b/src/CloudTrade/CloudTrade.iOS/Resources/LaunchScreen.xib @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CloudTrade/CloudTrade/App.axaml b/src/CloudTrade/CloudTrade/App.axaml new file mode 100644 index 0000000..b0ca477 --- /dev/null +++ b/src/CloudTrade/CloudTrade/App.axaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CloudTrade/CloudTrade/App.axaml.cs b/src/CloudTrade/CloudTrade/App.axaml.cs new file mode 100644 index 0000000..c6483f6 --- /dev/null +++ b/src/CloudTrade/CloudTrade/App.axaml.cs @@ -0,0 +1,37 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using CloudTrade.ViewModels; +using CloudTrade.Views; + +namespace CloudTrade +{ + public partial class App : Application + { + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow + { + DataContext = new MainViewModel() + }; + } + else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform) + { + singleViewPlatform.MainView = new MainView + { + DataContext = new MainViewModel() + }; + } + + base.OnFrameworkInitializationCompleted(); + } + + } +} \ No newline at end of file diff --git a/src/CloudTrade/CloudTrade/Assets/avalonia-logo.ico b/src/CloudTrade/CloudTrade/Assets/avalonia-logo.ico new file mode 100644 index 0000000..f7da8bb Binary files /dev/null and b/src/CloudTrade/CloudTrade/Assets/avalonia-logo.ico differ diff --git a/src/CloudTrade/CloudTrade/CloudTrade.csproj b/src/CloudTrade/CloudTrade/CloudTrade.csproj new file mode 100644 index 0000000..fb7aeee --- /dev/null +++ b/src/CloudTrade/CloudTrade/CloudTrade.csproj @@ -0,0 +1,25 @@ + + + net9.0 + enable + latest + true + + + + + + + + + + + + + None + All + + + + + diff --git a/src/CloudTrade/CloudTrade/ViewLocator.cs b/src/CloudTrade/CloudTrade/ViewLocator.cs new file mode 100644 index 0000000..7598797 --- /dev/null +++ b/src/CloudTrade/CloudTrade/ViewLocator.cs @@ -0,0 +1,31 @@ +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using CloudTrade.ViewModels; +using System; + +namespace CloudTrade +{ + public class ViewLocator : IDataTemplate + { + public Control? Build(object? param) + { + if (param is null) + return null; + + var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); + var type = Type.GetType(name); + + if (type != null) + { + return (Control)Activator.CreateInstance(type)!; + } + + return new TextBlock { Text = "Not Found: " + name }; + } + + public bool Match(object? data) + { + return data is ViewModelBase; + } + } +} \ No newline at end of file diff --git a/src/CloudTrade/CloudTrade/ViewModels/MainViewModel.cs b/src/CloudTrade/CloudTrade/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..e2ab75e --- /dev/null +++ b/src/CloudTrade/CloudTrade/ViewModels/MainViewModel.cs @@ -0,0 +1,8 @@ + +namespace CloudTrade.ViewModels +{ + public class MainViewModel : ViewModelBase + { + public string Greeting { get; } = "Welcome to Avalonia!"; + } +} diff --git a/src/CloudTrade/CloudTrade/ViewModels/ViewModelBase.cs b/src/CloudTrade/CloudTrade/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..5d829a5 --- /dev/null +++ b/src/CloudTrade/CloudTrade/ViewModels/ViewModelBase.cs @@ -0,0 +1,8 @@ +using ReactiveUI; + +namespace CloudTrade.ViewModels +{ + public abstract class ViewModelBase : ReactiveObject + { + } +} diff --git a/src/CloudTrade/CloudTrade/Views/MainView.axaml b/src/CloudTrade/CloudTrade/Views/MainView.axaml new file mode 100644 index 0000000..ad5fddb --- /dev/null +++ b/src/CloudTrade/CloudTrade/Views/MainView.axaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/src/CloudTrade/CloudTrade/Views/MainView.axaml.cs b/src/CloudTrade/CloudTrade/Views/MainView.axaml.cs new file mode 100644 index 0000000..8a7abfb --- /dev/null +++ b/src/CloudTrade/CloudTrade/Views/MainView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace CloudTrade.Views +{ + public partial class MainView : UserControl + { + public MainView() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/CloudTrade/CloudTrade/Views/MainWindow.axaml b/src/CloudTrade/CloudTrade/Views/MainWindow.axaml new file mode 100644 index 0000000..27863c9 --- /dev/null +++ b/src/CloudTrade/CloudTrade/Views/MainWindow.axaml @@ -0,0 +1,12 @@ + + + diff --git a/src/CloudTrade/CloudTrade/Views/MainWindow.axaml.cs b/src/CloudTrade/CloudTrade/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..a9efb90 --- /dev/null +++ b/src/CloudTrade/CloudTrade/Views/MainWindow.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace CloudTrade.Views +{ + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/CloudTrade/Directory.Packages.props b/src/CloudTrade/Directory.Packages.props new file mode 100644 index 0000000..459b86f --- /dev/null +++ b/src/CloudTrade/Directory.Packages.props @@ -0,0 +1,25 @@ + + + + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/WebApplication1/Controllers/WeatherForecastController.cs b/test/WebApplication1/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..cccacb1 --- /dev/null +++ b/test/WebApplication1/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace WebApplication1.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/test/WebApplication1/Program.cs b/test/WebApplication1/Program.cs new file mode 100644 index 0000000..0f96964 --- /dev/null +++ b/test/WebApplication1/Program.cs @@ -0,0 +1,345 @@ +using AspNetCore.Authentication.Basic; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Tokens; +using Microsoft.OpenApi.Models; +using System.Security.Claims; +using System.Text; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); +//ConfigureSwagger(builder.Services); +//ConfigureAuthentication(builder.Services); +builder.Services.AddSwaggerGen(x => +{ + x.AddSecurityDefinition("OAuth2", new OpenApiSecurityScheme + { + Description = "OAuth2 Authorization: Click the authorize button below to redirect to third-party authentication.", + Name = "Authorization", + In = ParameterLocation.Header, + BearerFormat = "JWT", + Scheme = "Bearer", + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows + { + AuthorizationCode = new OpenApiOAuthFlow + { + AuthorizationUrl = new Uri("http://localhost:32769/connect/authorize"), // OAuthȨ˵ + TokenUrl = new Uri("http://localhost:32769/connect/token"), // OAuthƶ˵ + Scopes = new Dictionary + { +{ "Account", "User registration and login" }, +{ "Email", "Email verification, send verification code" } + } + } + }, + + }); + x.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "OAuth2" + } + }, + new string[] { } + } + }); +}); +builder.Services.AddAuthentication(options => +{ + options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; // Ĭʹ Cookie ֤ + //options.DefaultChallengeScheme = OpenIddictDefaults.AuthenticationScheme; // Ĭս +}) + .AddCookie(options => + { + options.LoginPath = "/Account/Login"; // õ¼· + options.LogoutPath = "/Account/Logout"; // õdz· + options.Cookie.HttpOnly = true; // Cookie HttpOnly + options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest; // Cookie İȫ + }).AddOAuth("OAuth2", x => +{ + x.SignInScheme = "cookie"; + x.ClientId = "test1"; + x.ClientSecret = "test1"; + x.AuthorizationEndpoint = "http://localhost:5278/oauth/authorize"; + x.TokenEndpoint = "http://localhost:5278/oauth/token"; + x.CallbackPath = "/back/path"; +}); +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseSwagger(); +app.UseSwaggerUI(); +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); +void ConfigureSwagger(IServiceCollection services) +{ + + services.AddSwaggerGen(x => + { + x.SwaggerDoc("v1", new OpenApiInfo { Title = builder.Environment.ApplicationName, Version = "v1" }); + //var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; + //var xmlFile = AppDomain.CurrentDomain.FriendlyName + ".xml"; + //var xmlPath = Path.Combine(baseDirectory, xmlFile); + //x.IncludeXmlComments(xmlPath, true); + //x.OrderActionsBy(x => x.RelativePath); + //x.CustomOperationIds(x => + //{ + // var controllerAction = x.ActionDescriptor as ControllerActionDescriptor; + // return controllerAction.ControllerName + "-" + controllerAction.ActionName; + //}); + //x.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFile), true); + + // JWT + x.AddSecurityDefinition("Bearer", new Microsoft.OpenApi.Models.OpenApiSecurityScheme() + { + Description = "Enter the JWT authorization token in the request header: Bearer Token", + Name = "Authorization", + In = ParameterLocation.Header, + Type = SecuritySchemeType.ApiKey, + BearerFormat = "JWT", + Scheme = "Bearer", + }); + x.AddSecurityRequirement(new Microsoft.OpenApi.Models.OpenApiSecurityRequirement() + { + { + new OpenApiSecurityScheme(){ + Reference = new OpenApiReference(){ + Type=ReferenceType.SecurityScheme, + Id="Bearer" + } + },new string[]{ } + } + }); + // OAuth ֤֧ + x.AddSecurityDefinition("OAuth2", new OpenApiSecurityScheme + { + Description = "OAuth2 Authorization: Click the authorize button below to redirect to third-party authentication.", + Name = "Authorization", + In = ParameterLocation.Header, + BearerFormat = "JWT", + Scheme = "Bearer", + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows + { + AuthorizationCode = new OpenApiOAuthFlow + { + AuthorizationUrl = new Uri("http://localhost:32769/connect/authorize"), // OAuthȨ˵ + TokenUrl = new Uri("http://localhost:32769/connect/token"), // OAuthƶ˵ + Scopes = new Dictionary + { +{ "Account", "User registration and login" }, +{ "Email", "Email verification, send verification code" } + } + } + }, + + }); + x.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "OAuth2" + } + }, + new string[] { } + } + }); + // Basic ֤ + x.AddSecurityDefinition("Basic", new OpenApiSecurityScheme + { + Name = "Authorization", + Type = SecuritySchemeType.Http, + Scheme = "basic", + In = ParameterLocation.Header, + Description = "Basic Authentication" + }); + x.AddSecurityRequirement(new OpenApiSecurityRequirement{ + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Basic" } + }, + Array.Empty() + } + }); + + // Cookie ֤ + x.AddSecurityDefinition("Cookie", new OpenApiSecurityScheme + { + Name = "Cookie", + Type = SecuritySchemeType.ApiKey, + In = ParameterLocation.Cookie, + Description = "Enter your session cookie" + }); + x.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "Cookie" + } + }, + new string[] { } + } + }); + + x.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme() + { + In = ParameterLocation.Header, + Name = "X-API-KEY", + Type = SecuritySchemeType.ApiKey, + Description = "API KEY Authentication" + }); + x.AddSecurityRequirement(new OpenApiSecurityRequirement() + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "ApiKey" + } + }, + new string[] { } + } + }); + }); + + +} +void ConfigureAuthentication(IServiceCollection services) +{ + services.AddAuthentication(x => + { + x.DefaultAuthenticateScheme = "MultiAuthSchemes"; + x.DefaultChallengeScheme = "MultiAuthSchemes"; + x.DefaultForbidScheme = "MultiAuthSchemes"; + + + }).AddPolicyScheme("MultiAuthSchemes", "MultiAuthSchemes", options => + { + // Էͷʹĸ巽 + options.ForwardDefaultSelector = context => + { + // Authorizationͷ + string authorization = context.Request.Headers["Authorization"].FirstOrDefault(); + + if (!string.IsNullOrEmpty(authorization)) + { + if (authorization.StartsWith("Bearer ")) + return JwtBearerDefaults.AuthenticationScheme; + + if (authorization.StartsWith("Basic ")) + return "Basic"; + } + + // cookie + if (context.Request.Cookies.ContainsKey("AuthCookie")) + return CookieAuthenticationDefaults.AuthenticationScheme; + + // ĬϷJWTɸҪ޸ģ + return JwtBearerDefaults.AuthenticationScheme; + }; + }) + + .AddJwtBearer(x => + { + x.RequireHttpsMetadata = false; + x.SaveToken = true; + x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() + { + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("12345678123456781234567812345678")), + ValidIssuer = "token.Issuer", + ValidAudience =" token.Audience", + ValidateIssuerSigningKey = true,//Ƿ֤SecurityKey + ValidateIssuer = true, //Ƿ֤Issuer + ValidateAudience = true, //Ƿ֤Audience + ValidateLifetime = true, //Ƿ֤ʧЧʱ + ClockSkew = TimeSpan.FromSeconds(30),//ʱݴֵ + RequireExpirationTime = true + }; + }) + .AddOAuth("OAuth", x => + { + x.ClientId = "Yu_App"; + x.ClientSecret = "123456"; + x.CallbackPath = "/signin-oauth"; + x.AuthorizationEndpoint = "1"; + x.TokenEndpoint = "1"; + x.Scope.Add(""); + x.SaveTokens = true; + x.Events = new Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents() + { + OnCreatingTicket = context => + { + // ﴦ OAuth صݣȡûϢ + + var identity = context.Principal.Identity; + var tokens = context.AccessToken; + var claimsIdentity = context.Principal.Identity as ClaimsIdentity; + claimsIdentity?.AddClaim(new Claim("access_token", context.AccessToken)); + + return Task.CompletedTask; + } + }; + }).AddCookie() + + .AddBasic("Basic", x => + { + x.Realm = "CloudTrade"; + x.ClaimsIssuer = "admin"; + x.SuppressWWWAuthenticateHeader = false; + + x.Events = new BasicEvents() + { + OnValidateCredentials = context => + { + if (context.Username == "admin" && context.Password == "admin") + { + var claims = new[] { + new Claim(ClaimTypes.Name,context.Username) + }; + context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); + context.Success(); + } + return Task.CompletedTask; + } + }; + }) + + ; + + // services.AddAuthentication("ApiKey").AddScheme + + + // services.AddAuthentication("Basic").AddScheme("Basic", null); +} \ No newline at end of file diff --git a/test/WebApplication1/Properties/launchSettings.json b/test/WebApplication1/Properties/launchSettings.json new file mode 100644 index 0000000..9341a63 --- /dev/null +++ b/test/WebApplication1/Properties/launchSettings.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5278", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/test/WebApplication1/WeatherForecast.cs b/test/WebApplication1/WeatherForecast.cs new file mode 100644 index 0000000..6514c01 --- /dev/null +++ b/test/WebApplication1/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace WebApplication1 +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/test/WebApplication1/WebApplication1.csproj b/test/WebApplication1/WebApplication1.csproj new file mode 100644 index 0000000..6a41c65 --- /dev/null +++ b/test/WebApplication1/WebApplication1.csproj @@ -0,0 +1,23 @@ + + + + net9.0 + enable + enable + + + + + + + + + + + + + + + + + diff --git a/test/WebApplication1/WebApplication1.http b/test/WebApplication1/WebApplication1.http new file mode 100644 index 0000000..873a0f8 --- /dev/null +++ b/test/WebApplication1/WebApplication1.http @@ -0,0 +1,6 @@ +@WebApplication1_HostAddress = http://localhost:5278 + +GET {{WebApplication1_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/test/WebApplication1/appsettings.Development.json b/test/WebApplication1/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/test/WebApplication1/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/test/WebApplication1/appsettings.json b/test/WebApplication1/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/test/WebApplication1/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}