diff --git a/Come.AspNetCore.Sample/AuthRequestFactory.cs b/Come.AspNetCore.Sample/AuthRequestFactory.cs
index 24c16a4ebcf35b4e78dbeab8f69815bd62520767..36068cb75309d44cbbf3f85eddf217533428a73e 100644
--- a/Come.AspNetCore.Sample/AuthRequestFactory.cs
+++ b/Come.AspNetCore.Sample/AuthRequestFactory.cs
@@ -20,22 +20,24 @@ namespace Come.AspNetCore.Sample
{
if (_clientConfigs == null)
{
- var _defaultPrefix = "CollectiveOAuth_";
+ var _defaultPrefix = "OAuthConfig:CollectiveOAuth_";
_clientConfigs = new Dictionary();
#region 或者默认授权列表数据
var defaultAuthList = typeof(DefaultAuthSourceEnum).ToList().Select(a => a.Name.ToUpper()).ToList();
foreach (var authSource in defaultAuthList)
{
- var clientConfig = new ClientConfig();
- clientConfig.clientId = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_ClientId");
- clientConfig.clientSecret = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_ClientSecret");
- clientConfig.redirectUri = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_RedirectUri");
- clientConfig.alipayPublicKey = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_AlipayPublicKey");
- clientConfig.unionId = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_UnionId");
- clientConfig.stackOverflowKey = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_StackOverflowKey");
- clientConfig.agentId = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_AgentId");
- clientConfig.scope = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_Scope");
+ var clientConfig = new ClientConfig
+ {
+ clientId = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_ClientId"),
+ clientSecret = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_ClientSecret"),
+ redirectUri = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_RedirectUri"),
+ alipayPublicKey = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_AlipayPublicKey"),
+ unionId = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_UnionId"),
+ stackOverflowKey = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_StackOverflowKey"),
+ agentId = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_AgentId"),
+ scope = AppSettingUtils.GetStrValue($"{_defaultPrefix}{authSource}_Scope")
+ };
_clientConfigs.Add(authSource, clientConfig);
}
#endregion
diff --git a/Come.AspNetCore.Sample/Come.AspNetCore.Sample.csproj b/Come.AspNetCore.Sample/Come.AspNetCore.Sample.csproj
index 0f78a8ed0a5e0f5178db2793b053e98a95de5146..c7ed7cfbae3df33a4be32d5f64122f84e6359d88 100644
--- a/Come.AspNetCore.Sample/Come.AspNetCore.Sample.csproj
+++ b/Come.AspNetCore.Sample/Come.AspNetCore.Sample.csproj
@@ -1,13 +1,10 @@
- netcoreapp3.1
+ net5.0
-
-
-
diff --git a/Come.AspNetCore.Sample/Startup.cs b/Come.AspNetCore.Sample/Startup.cs
index 17874ccbb5410e9bae4e5e49b55dd642d3cab523..a741c4b7d4b89a453d7bec60926038633c13ea45 100644
--- a/Come.AspNetCore.Sample/Startup.cs
+++ b/Come.AspNetCore.Sample/Startup.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Come.CollectiveOAuth.Utils;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@@ -23,6 +24,8 @@ namespace Come.AspNetCore.Sample
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
+
+ services.AddSingleton(new AppSettingUtils(Configuration));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
diff --git a/Come.AspNetCore.Sample/appsettings.json b/Come.AspNetCore.Sample/appsettings.json
index 64de1c7634be345bc1371f3a8b65c34557461d68..0dc7ffc7c418907372d819bc5f32871f1ef23ad1 100644
--- a/Come.AspNetCore.Sample/appsettings.json
+++ b/Come.AspNetCore.Sample/appsettings.json
@@ -1,6 +1,6 @@
{
- "AppSettings": {
- /*ҵɨ*/
+ "OAuthConfig": {
+ /*wechat*/
"CollectiveOAuth_WECHAT_ENTERPRISE_SCAN_ClientId": "xxxxxxxxxxxxxxxxx",
"CollectiveOAuth_WECHAT_ENTERPRISE_SCAN_AgentId": "xxxxxx",
"CollectiveOAuth_WECHAT_ENTERPRISE_SCAN_ClientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
diff --git a/Come.CollectiveOAuth/Cache/HttpRuntimeCache.cs b/Come.CollectiveOAuth/Cache/HttpRuntimeCache.cs
index a57bf0bc81d329355c60faa2a38c4775cd7f279c..6d2b31018d4bbafaabdf53a0036bf95c4cf4c47a 100644
--- a/Come.CollectiveOAuth/Cache/HttpRuntimeCache.cs
+++ b/Come.CollectiveOAuth/Cache/HttpRuntimeCache.cs
@@ -77,7 +77,12 @@ namespace Come.CollectiveOAuth.Cache
///
/// 缓存
///
- public static IMemoryCache memoryCache => new MemoryCache(new MemoryCacheOptions() { });
+ //public static IMemoryCache memoryCache => new MemoryCache(new MemoryCacheOptions() { });
+ public static MemoryCache memoryCache { get; set; }
+ static HttpRuntimeCache()
+ {
+ memoryCache = new MemoryCache(new MemoryCacheOptions { });
+ }
///
/// 获取数据缓存
diff --git a/Come.CollectiveOAuth/Come.CollectiveOAuth.csproj b/Come.CollectiveOAuth/Come.CollectiveOAuth.csproj
index f764640071a0cff7496d3e01b3b4f7147e79b6da..098f81d8cc627a601081fd5f64ba25862c7f2bd7 100644
--- a/Come.CollectiveOAuth/Come.CollectiveOAuth.csproj
+++ b/Come.CollectiveOAuth/Come.CollectiveOAuth.csproj
@@ -1,22 +1,17 @@
- netcoreapp3.1;netstandard2.0;net45
+ net5.0;netstandard2.0
false
-
-
-
-
-
Libraries\TopSdk.dll
-
+
4.2.13
@@ -30,24 +25,6 @@
4.7.0
-
-
-
-
-
-
- 4.2.13
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Come.CollectiveOAuth/Request/AuthRequests/GithubAuthRequest.cs b/Come.CollectiveOAuth/Request/AuthRequests/GithubAuthRequest.cs
index dfdf87b01133a14b70a78f5f9ab765ecfbb5fbb3..f57d4daacefc1e043f6166920992ee23fddc352b 100644
--- a/Come.CollectiveOAuth/Request/AuthRequests/GithubAuthRequest.cs
+++ b/Come.CollectiveOAuth/Request/AuthRequests/GithubAuthRequest.cs
@@ -82,7 +82,7 @@ namespace Come.CollectiveOAuth.Request
.queryParam("response_type", "code")
.queryParam("redirect_uri", config.redirectUri)
.queryParam("scope", config.scope.IsNullOrWhiteSpace() ? "user" : config.scope)
- .queryParam("state", getRealState(state) + "#wechat_redirect")
+ .queryParam("state", getRealState(state))
.build();
}
diff --git a/Come.CollectiveOAuth/Utils/AppSettingUtils.cs b/Come.CollectiveOAuth/Utils/AppSettingUtils.cs
index cf0b083b8721903feb1c4d1c0dec2f90d5a78b8d..fe7dd3ba49cfc30d961b9b0f1b04a5831a4aa2f3 100644
--- a/Come.CollectiveOAuth/Utils/AppSettingUtils.cs
+++ b/Come.CollectiveOAuth/Utils/AppSettingUtils.cs
@@ -1,8 +1,16 @@
+using Microsoft.Extensions.Configuration;
+
namespace Come.CollectiveOAuth.Utils
{
public class AppSettingUtils
{
+ static IConfiguration Configuration { get; set; }
+
+ public AppSettingUtils(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
///
/// 根据Key取Value值
///
@@ -10,16 +18,24 @@ namespace Come.CollectiveOAuth.Utils
public static string GetStrValue(string key)
{
var value = "";
-#if NET45
- value = System.Configuration.ConfigurationManager.AppSettings[key];
-#else
- value = Come.CollectiveOAuth.Utils.ConfigurationManager.AppSettings[key];
-#endif
+
+ value = GetConfig(key);
+
if (!string.IsNullOrWhiteSpace(value))
{
return value.ToString().Trim();
}
return value;
}
+
+ ///
+ /// 获取配置文件
+ ///
+ /// eg: WeChat:Token
+ ///
+ public static string GetConfig(string key)
+ {
+ return Configuration[key];
+ }
}
}
\ No newline at end of file
diff --git a/Come.Web.Sample.sln b/Come.Web.Sample.sln
index b5b4fbb376b9df8c3e3d674a11ff5290a0217911..d0ba22145ae79355acc3494a564a25bf00d778f9 100644
--- a/Come.Web.Sample.sln
+++ b/Come.Web.Sample.sln
@@ -1,13 +1,11 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29519.87
+# Visual Studio Version 17
+VisualStudioVersion = 17.2.32526.322
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Come.Web.Sample", "Come.Web.Sample\Come.Web.Sample.csproj", "{8F544C63-C74C-4C28-9120-2896C292A686}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Come.CollectiveOAuth", "Come.CollectiveOAuth\Come.CollectiveOAuth.csproj", "{6D482ED4-236A-484B-9810-DFEE702A5541}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Come.CollectiveOAuth", "Come.CollectiveOAuth\Come.CollectiveOAuth.csproj", "{6D482ED4-236A-484B-9810-DFEE702A5541}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Come.AspNetCore.Sample", "Come.AspNetCore.Sample\Come.AspNetCore.Sample.csproj", "{ED0A91E3-47C4-44D8-8F88-643B1E0C225D}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Come.AspNetCore.Sample", "Come.AspNetCore.Sample\Come.AspNetCore.Sample.csproj", "{ED0A91E3-47C4-44D8-8F88-643B1E0C225D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,10 +13,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8F544C63-C74C-4C28-9120-2896C292A686}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8F544C63-C74C-4C28-9120-2896C292A686}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8F544C63-C74C-4C28-9120-2896C292A686}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8F544C63-C74C-4C28-9120-2896C292A686}.Release|Any CPU.Build.0 = Release|Any CPU
{6D482ED4-236A-484B-9810-DFEE702A5541}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D482ED4-236A-484B-9810-DFEE702A5541}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D482ED4-236A-484B-9810-DFEE702A5541}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/Come.Web.Sample/Controllers/OAuth2Controller.cs b/Come.Web.Sample/Controllers/OAuth2Controller.cs
index a0384622ab900b8d236e2f32b12ac26792cd5611..bdf3ba66e0180cc228f174b31c498ea2032a1e43 100644
--- a/Come.Web.Sample/Controllers/OAuth2Controller.cs
+++ b/Come.Web.Sample/Controllers/OAuth2Controller.cs
@@ -53,5 +53,20 @@ namespace Come.Web.Sample.Controllers
var authResponse = request.login(authCallback);
return Content(JsonConvert.SerializeObject(authResponse));
}
+
+
+ /// Eleme验证授权
+ ///
+ ///
+ ///
+ ///
+ public ActionResult ElemeVerification()
+ {
+ var retMsg = new
+ {
+ message = "ok"
+ };
+ return Json(retMsg, JsonRequestBehavior.AllowGet);
+ }
}
}
\ No newline at end of file
diff --git a/Come.Web.Sample/Views/Home/Index.cshtml b/Come.Web.Sample/Views/Home/Index.cshtml
index 5b44deb0489c9d3209d416d652fd932d0a27413e..291040e362c6f833c1a1ac0133ff58548502a0e9 100644
--- a/Come.Web.Sample/Views/Home/Index.cshtml
+++ b/Come.Web.Sample/Views/Home/Index.cshtml
@@ -100,24 +100,3 @@
-
-
-
Getting started
-
- ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
- enables a clean separation of concerns and gives you full control over markup
- for enjoyable, agile development.
-
-
Learn more »
-
-
-
Get more libraries
-
NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.
-
Learn more »
-
-
-
Web Hosting
-
You can easily find a web hosting company that offers the right mix of features and price for your applications.
-
Learn more »
-
-
\ No newline at end of file
diff --git a/Come.Web.Sample/Views/Shared/_Layout.cshtml b/Come.Web.Sample/Views/Shared/_Layout.cshtml
index 854fe257e9b9811dd329fa2d7c40241b2d059acb..dad2bd984b36a1428dbde390e14b0664a438e192 100644
--- a/Come.Web.Sample/Views/Shared/_Layout.cshtml
+++ b/Come.Web.Sample/Views/Shared/_Layout.cshtml
@@ -21,9 +21,8 @@
- - @Html.ActionLink("主页", "Index", "Home")
- @* - @Html.ActionLink("关于", "About", "Home")
*@
- @* - @Html.ActionLink("联系方式", "Contact", "Home")
*@
+ - 使用文档
+ - 精品源码
diff --git a/README.md b/README.md
index f36ef4a0ab89592921d256f4fcf631bfeb7f6baf..373cca4b60f8a3497e8c2a423564b865b7949f80 100644
--- a/README.md
+++ b/README.md
@@ -186,6 +186,15 @@ _请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经
- [The OAuth 2.0 Authorization Framework](https://tools.ietf.org/html/rfc6749)
- [OAuth 2.0](https://oauth.net/2/)
+## 推荐一个精品源码网站
+
+- [锐风资源网(C#精品源码、教程)](https://rthinkingsoft.com)
+- [销售行业财务管理系统Asp.Net MVC+微信小程序](https://rthinkingsoft.com/2020/02/19/sales-finance/)
+- [销客多 3.5.1微信商城 三级分销系统C#源码 ASP.NET公众号网站](https://rthinkingsoft.com/2020/02/19/hishop-3-5-1/)
+- [ASP.NET- 微信企业号OA办公管理系统 源码 企业号移动OA](https://rthinkingsoft.com/2020/02/19/wx-oa-enterprise/)
+- [敏捷开发框架7.0.3 旗舰版 .NET MVC 敏捷快速开发框架+权限+工作流+EF+SqlServer+MySQL+Oracle](https://rthinkingsoft.com/2020/02/19/quick-develop-7-0-3/)
+
+
## 关注&交流
| 公众号 | QQ群 |