Local Passwords validation

This commit is contained in:
Paul Schneider
2024-11-06 13:00:34 +00:00
parent 39f98229eb
commit 2043dbfce6
163 changed files with 1824 additions and 4784 deletions

View File

@ -0,0 +1,66 @@
using IdentityServer4.Models;
using IdentityServer4.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;
}
}