Skip to content

Commit

Permalink
remove using Castle.Core.Logging;
Browse files Browse the repository at this point in the history
  • Loading branch information
hyzx86 committed Feb 23, 2023
2 parents 583ffe9 + 4af2a40 commit f2d513d
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 7 deletions.
1 change: 1 addition & 0 deletions EasyOC.build/Commons.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Description>
EasyOC is committed to making OrchardCore development easier.
This repositry is referencing a stable build of Orchard Core (1.5.0).
国内用户 欢迎加入QQ 群:877196442
</Description>
<Copyright>Tony Han</Copyright>
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

QQ 群:877196442 或者点击这里
[![Orchard Core CN 中文讨论组](https://docs.orchardcore.net/en/latest/docs/assets/images/orchard-core-cn-community-logo.png)](https://shang.qq.com/wpa/qunwpa?idkey=48721591a71ee7586316604a7a4ee99d26fd977c6120370a06585085a5936f62)


## [EasyOC.ActionReplace](src/Modules/EasyOC.ReplaceAction)
[![NuGet](https://img.shields.io/nuget/v/EasyOC.Users.svg)](https://www.nuget.org/packages/EasyOC.Users)

Expand Down
6 changes: 5 additions & 1 deletion src/Modules/EasyOC.ReplaceAction/ServiceExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc.Controllers;
using Castle.Core.Logging;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -74,6 +75,9 @@ public static IServiceProvider UseReplaceAction(this IServiceProvider servicePro
.OfType<ControllerActionDescriptor>()
.ToArray();

var logger = serviceProvider.GetService<ILogger>();


foreach (var descriptor in descriptors)
{
foreach (var item in config.Items.OrderBy(x => x.Order))
Expand Down
24 changes: 23 additions & 1 deletion src/Modules/EasyOC.SwaggerUI/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,26 @@
[![NuGet](https://img.shields.io/nuget/v/EasyOC.SwaggerUI.svg)](https://www.nuget.org/packages/EasyOC.SwaggerUI)

- Adding Swagger UI support to OrchardCore
- Integration OpenId code flow authentication
- Integration OpenId code flow authentication


## How to use?

1. Enable `EasyOC.SwaggerUI` Feature
1. Run Recipes :`EasyOC SwaggerUI Auth`
1. Config Authentication
- In Admin menus , Open : Security > OpenID Connect > Applications
- Locate SwaggerClient in the list of applications, Edit
- Update your Redirect Uris

You need keep the postfix , and use your domain and site Prefix to instead "http://localhost:2919/"
- In Admin menus , Open : Configuration > SwaggerUI , Click `Authorize` on the right

input SwaggerClient in client_id field,keep the client_secret empty

Click Authorize

![image](https://user-images.githubusercontent.com/15613121/218245730-a2ce5bfa-6400-464c-8975-4e5d1365303f.png)



51 changes: 51 additions & 0 deletions src/Modules/EasyOC.Users/Controllers/EocOpenIdAccessController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenIddict.Server.AspNetCore;
using OrchardCore.Modules;
using OrchardCore.OpenId;
using OrchardCore.OpenId.ViewModels;

namespace EasyOC.Users.Controllers
{
[Authorize, Feature(OpenIdConstants.Features.Server)]
public class EocOpenIdAccessController : Controller
{
[AllowAnonymous, HttpGet, HttpPost, IgnoreAntiforgeryToken]
public async Task<IActionResult> Logout()
{
var response = HttpContext.GetOpenIddictServerResponse();
if (response != null)
{
return View("Error", new ErrorViewModel
{
Error = response.Error,
ErrorDescription = response.ErrorDescription
});
}

var request = HttpContext.GetOpenIddictServerRequest();
if (request == null)
{
return NotFound();
}

// Warning: unlike the main Logout method, this method MUST NOT be decorated with
// [IgnoreAntiforgeryToken] as we must be able to reject end session requests
// sent by a malicious client that could abuse this interactive endpoint to silently
// log the user out without the user explicitly approving the log out operation.

await HttpContext.SignOutAsync();

// If no post_logout_redirect_uri was specified, redirect the user agent
// to the root page, that should correspond to the home page in most cases.
if (string.IsNullOrEmpty(request.PostLogoutRedirectUri))
{
return Redirect("~/");
}

return SignOut(OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
}
}
}
2 changes: 1 addition & 1 deletion src/Modules/EasyOC.Users/EasyOC.Users.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="$(OrchardCoreVersion)" />

<PackageReference Include="OrchardCore.OpenId.Core" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.OpenId" Version="$(OrchardCoreVersion)" />

<PackageReference Include="OrchardCore.Users" Version="$(OrchardCoreVersion)" />
<ProjectReference Include="..\EasyOC.ReplaceAction\EasyOC.ReplaceAction.csproj" />
Expand Down
20 changes: 17 additions & 3 deletions src/Modules/EasyOC.Users/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@
[assembly: Module(
Name = "EasyOC.Users",
Author = "Tony Han",
Website = "https://github.com/EasyOC/EasyOC.Modules",
Dependencies = new[] { "OrchardCore.Users" },
Description = "EasyOC.Users",
Website = "https://github.com/EasyOC/EasyOC.Modules"
)]

[assembly: Feature(
Id = "EasyOC.Users",
Name = "EasyOC.Users",
Dependencies = new[] { "OrchardCore.Users", "EasyOC.ReplaceAction" },
Description = "Make the UserLogin Script supports Update custom user properties and Update `UserClaims`",
Category = "Content Management"
)]


[assembly: Feature(
Id = "EasyOC.OpenId.ImplicitLogout",
Name = "Implicit logout",
Dependencies = new[] { "OrchardCore.OpenId", "EasyOC.ReplaceAction" },
Description = "Confirmation is no longer required when logging out using OpenId",
Category = "Content Management"
)]
16 changes: 15 additions & 1 deletion src/Modules/EasyOC.Users/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
using EasyOC.Users.Handlers;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;
using OrchardCore.OpenId.Controllers;
using OrchardCore.Users.Controllers;
using OrchardCore.Users.Handlers;

namespace EasyOC.Users
{
[Feature("EasyOC.Users")]
[RequireFeatures("OrchardCore.Users", "EasyOC.ReplaceAction")]
public class Startup : StartupBase
{
Expand All @@ -28,8 +30,20 @@ public override void ConfigureServices(IServiceCollection services)
nameof(EocAccountController.LinkExternalLogin),
nameof(EocAccountController.ExternalLoginCallback),
nameof(EocAccountController.RegisterExternalLogin)
);
);
}

}
[Feature("EasyOC.OpenId.ImplicitLogout")]
[RequireFeatures("OrchardCore.OpenId", "EasyOC.ReplaceAction")]
public class OpenIdStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.ReplaceActionByActionNames<EocOpenIdAccessController>(
typeof(AccessController).FullName,
nameof(EocOpenIdAccessController.Logout)
);
}
}
}

0 comments on commit f2d513d

Please sign in to comment.