a client store

This commit is contained in:
Paul Schneider
2025-07-15 17:35:14 +01:00
parent 1e766f4718
commit f43fd76baa
6 changed files with 80 additions and 57 deletions

View File

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using IdentityServer8.Stores;
using IdentityServer8.Models;
namespace Yavsc.Services;
public class ClientStore : IClientStore
{
public ClientStore(ApplicationDbContext applicationDbContext)
{
ApplicationDbContext = applicationDbContext;
}
public ApplicationDbContext ApplicationDbContext { get; }
public async Task<Client> FindClientByIdAsync(string clientId)
{
var clientFromDb = await ApplicationDbContext.Client.FirstAsync(c => c.Id == clientId);
return new Client
{
ClientId = clientFromDb.Id,
ClientName = clientFromDb.DisplayName,
ClientSecrets = { new Secret(clientFromDb.Secret.Sha256()) },
AllowedGrantTypes =[ GrantType.ClientCredentials, GrantType.DeviceFlow],
AllowedScopes = ["openid", "profile", "scope1"]
};
}
}