2 Commits

Author SHA1 Message Date
12cbc754cd App B context belongs to app
Some checks failed
Dotnet build and test / log-the-inputs (push) Failing after 1s
Dotnet build and test / build (push) Failing after 1s
2025-07-15 19:43:41 +01:00
f43fd76baa a client store 2025-07-15 17:35:14 +01:00
362 changed files with 181 additions and 199 deletions

View File

@ -31,38 +31,34 @@ public static class Config
/// <summary>
/// Lists Available user profile classes,
/// populated at startup, using reflexion.
/// populated at startup, using reflection.
/// </summary>
public static List<Type> ProfileTypes = new List<Type>();
public static IEnumerable<IdentityResource> IdentityResources =>
new IdentityResource[]
{
[
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResources.Email()
};
];
public static IEnumerable<ApiScope> ApiScopes =>
new ApiScope[]
{
public static IEnumerable<ApiScope> TestingApiScopes =>
[
new ApiScope("scope1",new string[] {"scope1"}),
new ApiScope("scope2",new string[] {"scope2"}),
};
];
public static IEnumerable<Client> Clients =>
new Client[]
{
public static IEnumerable<Client> TestingClients =>
[
// m2m client credentials flow client
new Client
{
ClientId = "m2m.client",
ClientName = "Client Credentials Client",
AllowedGrantTypes = GrantTypes.ClientCredentials,
ClientSecrets = { new Secret("511536EF-F270-4058-80CA-1C89C192F69A".Sha256()) },
AllowedGrantTypes = GrantTypes.ClientCredentials,
AllowedScopes = { "scope1" }
},
@ -87,7 +83,7 @@ public static class Config
IdentityServerConstants.StandardScopes.OfflineAccess,
"scope2" },
},
};
];
public static PayPalSettings? PayPalSettings { get; set; }
}

View File

@ -1,11 +1,6 @@
using System.Security.Claims;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using Yavsc.Models.Blog;
namespace Yavsc.Helpers
namespace Yavsc.Server.Helpers
{
public static class UserHelpers
{
@ -24,30 +19,5 @@ namespace Yavsc.Helpers
return user.Identity.IsAuthenticated;
}
public static IEnumerable<BlogPost> UserPosts(this ApplicationDbContext dbContext, string posterId, string? readerId)
{
if (readerId == null)
{
var userPosts = dbContext.blogSpotPublications.Include(
b => b.BlogPost
).Where(x => x.BlogPost.AuthorId == posterId)
.Select(x=>x.BlogPost).ToArray();
return userPosts;
}
else
{
long[] readerCirclesMemberships =
dbContext.Circle.Include(c => c.Members)
.Where(c => c.Members.Any(m => m.MemberId == readerId))
.Select(c => c.Id).ToArray();
return dbContext.BlogSpot.Include(
b => b.Author
).Include(p => p.ACL).Where(x => x.Author.Id == posterId &&
(x.ACL.Count == 0 || x.ACL.Any(a => readerCirclesMemberships.Contains(a.CircleId))));
}
}
}
}

View File

@ -1,26 +1,5 @@
SOURCE_DIR=../..
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make
BASERESX=Resources/Yavsc.Models.Relationship.HyperLink.resx \
Resources/Yavsc.Models.Streaming.LiveFlow.resx
BASERESXGEN=$(BASERESX:.resx=.Designer.cs)
SOURCE_DIR=..
SOLUTION_DIR=../..
include $(MAKEFILE_DIR)/dnx.mk
include $(MAKEFILE_DIR)/versioning.mk
default: all
$(BINTARGETPATH): ../OAuth.AspNet.AuthServer/bin/$(CONFIGURATION)/OAuth.AspNet.AuthServer.dll \
../Yavsc.Abstract/bin/$(CONFIGURATION)/Yavsc.Abstract.dll prepare_code
../OAuth.AspNet.AuthServer/bin/$(CONFIGURATION)/OAuth.AspNet.AuthServer.dll:
make -C ../OAuth.AspNet.AuthServer
../Yavsc.Abstract/bin/$(CONFIGURATION)/Yavsc.Abstract.dll:
make -C ../Yavsc.Abstract
%.Designer.cs: %.resx
strongresbuildercli -l -p -t -r "Yavsc.Server.Resources." $^
prepare_code: $(BASERESXGEN)
all: $(BINTARGETPATH)

View File

@ -1,66 +0,0 @@
using IdentityServer8.Models;
using IdentityServer8.Stores;
using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
namespace Yavsc.Services;
public class YavscClientStore : IClientStore
{
ApplicationDbContext _context=null;
public YavscClientStore(ApplicationDbContext context)
{
_context = context;
}
async Task<Client> IClientStore.FindClientByIdAsync(string clientId)
{
var app = await _context.Applications.FirstOrDefaultAsync(c=>c.Id == clientId);
if (app == null) return null;
Client client = new()
{
ClientId = app.Id,
ClientName = app.DisplayName,
AbsoluteRefreshTokenLifetime = app.RefreshTokenLifeTime,
AccessTokenLifetime = app.AccessTokenLifetime,
AllowedGrantTypes =
[
GrantType.AuthorizationCode,
GrantType.DeviceFlow,
GrantType.ClientCredentials
],
ClientSecrets = [
new Secret(app.Secret),
]
};
switch(app.Type)
{
case Models.Auth.ApplicationTypes.NativeConfidential:
client.AccessTokenType = AccessTokenType.Reference;
client.AllowedGrantTypes =
[
GrantType.DeviceFlow
];
client.AllowedScopes = [] ;
break;
case Models.Auth.ApplicationTypes.JavaScript:
default:
client.AccessTokenType = AccessTokenType.Jwt;
client.AllowedGrantTypes =
[
GrantType.AuthorizationCode,
GrantType.ClientCredentials
];
client.AllowedScopes = ["openid", "profile"];
break;
}
return client;
}
}

View File

@ -27,6 +27,7 @@ using IdentityModel;
using System.Security.Cryptography;
using System.Text.Unicode;
using System.Text;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -16,6 +16,7 @@ using Yavsc.Services;
using Yavsc.ViewModels.Manage;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Authorization;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{
@ -709,7 +710,8 @@ namespace Yavsc.Controllers
private async Task<ApplicationUser> GetCurrentUserAsync()
{
return await _dbContext.Users.Include(u => u.PostalAddress).FirstOrDefaultAsync(u => u.Id == User.GetUserId());
return await _dbContext.Users.Include(u => u.PostalAddress)
.FirstOrDefaultAsync(u => u.Id == User.GetUserId());
}
#endregion

View File

@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Abstract.Identity;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Server.Helpers;
using Yavsc.ViewModels;
using Yavsc.ViewModels.Administration;

View File

@ -9,6 +9,7 @@ using Yavsc.Server.Settings;
using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Server.Models.Calendar;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -10,6 +10,7 @@ using Microsoft.Extensions.Options;
using Microsoft.EntityFrameworkCore;
using Yavsc.ViewModels.Blog;
using Yavsc.Server.Exceptions;
using Yavsc.Server.Helpers;
// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

View File

@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Relationship;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Relationship;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Blog;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -4,6 +4,7 @@ using Yavsc.Abstract.Models.Messaging;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Messaging;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -9,6 +9,7 @@ namespace Yavsc.Controllers
using Models;
using Models.Workflow;
using Yavsc.Helpers;
using Yavsc.Server.Helpers;
[Authorize("AdministratorOnly")]
public class ActivityController : Controller

View File

@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Auth;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Workflow;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -16,6 +16,7 @@ namespace Yavsc.Controllers
using Models.Workflow;
using Services;
using Yavsc.Interface;
using Yavsc.Server.Helpers;
using Yavsc.Settings;
public class CommandController : Controller

View File

@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Workflow;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -13,6 +13,7 @@ namespace Yavsc.Controllers
using System.Threading.Tasks;
using Yavsc.Helpers;
using Microsoft.EntityFrameworkCore;
using Yavsc.Server.Helpers;
[Authorize]
public class DoController : Controller

View File

@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Forms;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -5,6 +5,7 @@ namespace Yavsc.Controllers
using Models;
using Models.Musical;
using Yavsc.Helpers;
using Yavsc.Server.Helpers;
public class MusicalTendenciesController : Controller
{

View File

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Billing;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -7,6 +7,7 @@ namespace Yavsc.Controllers.Generic
using Microsoft.EntityFrameworkCore;
using Models;
using Yavsc.Helpers;
using Yavsc.Server.Helpers;
using Yavsc.Services;
[Authorize]

View File

@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Drawing;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -26,6 +26,7 @@ namespace Yavsc.Controllers
using Yavsc.Interface;
using Yavsc.Settings;
using Yavsc.Abstract.Models.Messaging;
using Yavsc.Server.Helpers;
public class HairCutCommandController : CommandController
{

View File

@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Haircut;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.Extensions.Options;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -5,6 +5,7 @@ using Yavsc.Models;
using Yavsc.Server.Models.IT.SourceCode;
using Yavsc.Helpers;
using Microsoft.EntityFrameworkCore;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Musical.Profiles;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{

View File

@ -7,6 +7,7 @@ namespace Yavsc.Controllers
using Models;
using Models.Musical;
using Yavsc.Helpers;
using Yavsc.Server.Helpers;
public class InstrumentsController : Controller
{

View File

@ -1,10 +1,7 @@
using System.Diagnostics;
using System.Globalization;
using System.Security.Cryptography.X509Certificates;
using Google.Apis.Util.Store;
using IdentityServer8;
using IdentityServer8.Services;
using IdentityServerHost.Quickstart.UI;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
@ -18,14 +15,9 @@ using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using Newtonsoft.Json;
using Yavsc.Abstract.Workflow;
using Yavsc.Billing;
using Yavsc.Helpers;
using Yavsc.Interface;
using Yavsc.Models;
using Yavsc.Models.Billing;
using Yavsc.Models.Haircut;
using Yavsc.Models.Workflow;
using Yavsc.Services;
using Yavsc.Settings;
using Yavsc.ViewModels.Auth;
@ -34,8 +26,6 @@ using System.Security.Cryptography;
using Microsoft.IdentityModel.Tokens;
using Microsoft.IdentityModel.Protocols.Configuration;
using IdentityModel;
using System.Security.Claims;
using IdentityServer8.Security;
using Yavsc.Interfaces;
namespace Yavsc.Extensions;
@ -238,8 +228,9 @@ public static class HostingExtensions
options.EmitStaticAudienceClaim = true;
})
.AddInMemoryIdentityResources(Config.IdentityResources)
.AddInMemoryClients(Config.Clients)
.AddInMemoryApiScopes(Config.ApiScopes)
.AddInMemoryClients(Config.TestingClients)
.AddClientStore<ClientStore>()
.AddInMemoryApiScopes(Config.TestingApiScopes)
.AddAspNetIdentity<ApplicationUser>()
;
if (builder.Environment.IsDevelopment())

View File

@ -6,6 +6,7 @@ using Yavsc.Helpers;
using Yavsc.Migrations;
using Yavsc.Models;
using Yavsc.Models.Blog;
using Yavsc.Server.Helpers;
using Yavsc.ViewModels.Auth;
namespace Yavsc.Extensions;

View File

@ -1,10 +1,32 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using Yavsc.Models.Blog;
namespace Yavsc.Helpers
{
public static class UserHelpers
{
public static IEnumerable<BlogPost> UserPosts(this ApplicationDbContext dbContext, string posterId, string? readerId)
{
if (readerId == null)
{
var userPosts = dbContext.blogSpotPublications.Include(
b => b.BlogPost
).Where(x => x.BlogPost.AuthorId == posterId)
.Select(x => x.BlogPost).ToArray();
return userPosts;
}
else
{
long[] readerCirclesMemberships =
dbContext.Circle.Include(c => c.Members)
.Where(c => c.Members.Any(m => m.MemberId == readerId))
.Select(c => c.Id).ToArray();
return dbContext.BlogSpot.Include(
b => b.Author
).Include(p => p.ACL).Where(x => x.Author.Id == posterId &&
(x.ACL.Count == 0 || x.ACL.Any(a => readerCirclesMemberships.Contains(a.CircleId))));
}
}
}
}

View File

@ -36,6 +36,7 @@ namespace Yavsc
using Models.Chat;
using Yavsc.Abstract.Chat;
using Yavsc.Helpers;
using Yavsc.Server.Helpers;
using Yavsc.Services;
public partial class ChatHub : Hub, IDisposable
{

Some files were not shown because too many files have changed in this diff Show More