Skip to content

Commit

Permalink
feat(src/plugincore.aspnetcore): use Constants
Browse files Browse the repository at this point in the history
Authentication,Authorization:
PluginCoreAuthenticationHandler,AccountManager,PluginCoreAdminAuthorizeAttribute
  • Loading branch information
yiyungent committed Dec 27, 2023
1 parent 1278d0f commit 6cd128a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
else
{
var id = new ClaimsIdentity(
new Claim[] { new Claim("PluginCore.Token", token) }, // not safe , just as an example , should custom claims on your own
// new Claim[] { new Claim("PluginCore.Token", token) }, // not safe , just as an example , should custom claims on your own
new Claim[] { new Claim(IPlugins.Constants.AspNetCoreAuthenticationClaimType, token) }, // not safe , just as an example , should custom claims on your own
Scheme.Name
);
ClaimsPrincipal principal = new ClaimsPrincipal(id);
Expand Down
3 changes: 2 additions & 1 deletion src/PluginCore.AspNetCore/Authorization/AccountManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public string CurrentToken()
{
// cookie 中找 token
//string tokenCookieName = "token";
string tokenCookieName = "PluginCore.Admin.Token";
// string tokenCookieName = "PluginCore.Admin.Token";
string tokenCookieName = IPlugins.Constants.AspNetCoreAuthorizationTokenCookieName;
if (request.Cookies.Keys.Contains(tokenCookieName))
{
if (request.Cookies[tokenCookieName] != null && string.IsNullOrEmpty(request.Cookies[tokenCookieName]) == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



using System;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Authorization;
Expand All @@ -19,7 +19,8 @@ namespace PluginCore.AspNetCore.Authorization
/// </summary>
public class PluginCoreAdminAuthorizeAttribute : AuthorizeAttribute
{
public PluginCoreAdminAuthorizeAttribute() : base("PluginCore.Admin")
// public PluginCoreAdminAuthorizeAttribute() : base("PluginCore.Admin")
public PluginCoreAdminAuthorizeAttribute() : base(IPlugins.Constants.AspNetCoreAuthorizationPolicyName)
{

}
Expand Down

0 comments on commit 6cd128a

Please sign in to comment.