refact and login

This commit is contained in:
Paul Schneider 2026-03-09 02:07:09 +00:00
commit e042e34bf7
78 changed files with 2492 additions and 50576 deletions

View file

@ -1,175 +0,0 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Messaging;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{
[Produces("application/json")]
[Route("api/dimiss")]
public class DimissClicksApiController : Controller
{
private readonly ApplicationDbContext _context;
public DimissClicksApiController(ApplicationDbContext context)
{
_context = context;
}
// GET: api/DimissClicksApi
[HttpGet]
public IEnumerable<DismissClicked> GetDismissClicked()
{
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
return _context.DismissClicked.Where(d=>d.UserId == uid);
}
[HttpGet("click/{noteid}"),AllowAnonymous]
public async Task<IActionResult> Click(long noteid )
{
if (User.IsSignedIn())
return await PostDismissClicked(new DismissClicked { NotificationId= noteid, UserId = User.GetUserId()});
await HttpContext.Session.LoadAsync();
var clicked = HttpContext.Session.GetString("clicked");
if (clicked == null) {
HttpContext.Session.SetString("clicked",noteid.ToString());
} else HttpContext.Session.SetString("clicked",$"{clicked}:{noteid}");
await HttpContext.Session.CommitAsync();
return Ok();
}
// GET: api/DimissClicksApi/5
[HttpGet("{id}", Name = "GetDismissClicked")]
public async Task<IActionResult> GetDismissClicked([FromRoute] string id)
{
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
if (uid != id) return new ChallengeResult();
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
DismissClicked DismissClicked = await _context.DismissClicked.SingleAsync(m => m.UserId == id);
if (DismissClicked == null)
{
return NotFound();
}
return Ok(DismissClicked);
}
// PUT: api/DimissClicksApi/5
[HttpPut("{id}")]
public async Task<IActionResult> PutDismissClicked([FromRoute] string id, [FromBody] DismissClicked DismissClicked)
{
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
if (uid != id || uid != DismissClicked.UserId) return new ChallengeResult();
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (id != DismissClicked.UserId)
{
return BadRequest();
}
_context.Entry(DismissClicked).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync(User.GetUserId());
}
catch (DbUpdateConcurrencyException)
{
if (!DismissClickedExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return new StatusCodeResult(StatusCodes.Status204NoContent);
}
// POST: api/DimissClicksApi
[HttpPost]
public async Task<IActionResult> PostDismissClicked([FromBody] DismissClicked DismissClicked)
{
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
if (uid != DismissClicked.UserId) return new ChallengeResult();
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
_context.DismissClicked.Add(DismissClicked);
try
{
await _context.SaveChangesAsync(User.GetUserId());
}
catch (DbUpdateException)
{
if (DismissClickedExists(DismissClicked.UserId))
{
return new StatusCodeResult(StatusCodes.Status409Conflict);
}
else
{
throw;
}
}
return CreatedAtRoute("GetDismissClicked", new { id = DismissClicked.UserId }, DismissClicked);
}
// DELETE: api/DimissClicksApi/5
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteDismissClicked([FromRoute] string id)
{
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
if (!User.IsInRole("Administrator"))
if (uid != id) return new ChallengeResult();
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
DismissClicked DismissClicked = await _context.DismissClicked.SingleAsync(m => m.UserId == id);
if (DismissClicked == null)
{
return NotFound();
}
_context.DismissClicked.Remove(DismissClicked);
await _context.SaveChangesAsync(User.GetUserId());
return Ok(DismissClicked);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
_context.Dispose();
}
base.Dispose(disposing);
}
private bool DismissClickedExists(string id)
{
return _context.DismissClicked.Count(e => e.UserId == id) > 0;
}
}
}

View file

@ -8,9 +8,9 @@ namespace Yavsc.Models.Relationship
public class Location : Position, ILocation { public class Location : Position, ILocation {
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[YaRequired(), [Required(),
Display(Name="Address"), Display(Name="Address"),
MaxLength(512)] MaxLength(512)]
public string Address { get; set; } public string Address { get; set; }
} }
} }

View file

@ -11,7 +11,7 @@ namespace Yavsc.Models.Relationship
/// <summary> /// <summary>
/// The longitude. /// The longitude.
/// </summary> /// </summary>
[YaRequired(),Display(Name="Longitude")] [Required(),Display(Name="Longitude")]
[Range(-180, 360.0)] [Range(-180, 360.0)]
public double Longitude { get; set; } public double Longitude { get; set; }
@ -20,9 +20,9 @@ namespace Yavsc.Models.Relationship
/// ///
/// The latitude. /// The latitude.
/// </summary> /// </summary>
[YaRequired(),Display(Name="Latitude")] [Required(),Display(Name="Latitude")]
[Range(-90, 90 )] [Range(-90, 90 )]
public double Latitude { get; set; } public double Latitude { get; set; }
} }
} }

View file

@ -18,88 +18,94 @@ using Yavsc.Helpers;
using Yavsc.Interface; using Yavsc.Interface;
using Yavsc.Models; using Yavsc.Models;
using Yavsc.Services; using Yavsc.Services;
using Yavsc.Server.Helpers;
internal class Program internal class Program
{ {
private static async Task Main(string[] args) private static async Task Main(string[] args)
{ {
Console.Title = "API"; Console.Title = "Yavsc.Blogs";
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
var services = builder.Services; var services = builder.Services;
// builder.Services.AddDistributedMemoryCache();
// accepts any access token issued by identity server var authority = builder.GetAuthority();
// adds an authorization policy for scope 'scope1' var audience = builder.GetAudience();
services // builder.Services.AddDistributedMemoryCache();
.AddAuthorization(options =>
{
options.AddPolicy("ApiScope", policy =>
{
policy
.RequireAuthenticatedUser()
.RequireClaim(JwtClaimTypes.Scope, new string[] { "scope2" });
});
})
.AddCors(options =>
{
// this defines a CORS policy called "default"
options.AddPolicy("default", policy =>
{
policy.WithOrigins("https://localhost:5003")
.AllowAnyHeader()
.AllowAnyMethod();
});
})
.AddControllers();
// accepts any access token issued by identity server // accepts any access token issued by identity server
var authenticationBuilder = services.AddAuthentication("Bearer") // adds an authorization policy for scope 'scope1'
.AddJwtBearer("Bearer", options =>
{
options.IncludeErrorDetails = true;
options.Authority = "https://localhost:5001";
options.TokenValidationParameters =
new() { ValidateAudience = false, RoleClaimType = Constants.RoleClaimType };
options.MapInboundClaims = true;
});
services.AddDbContext<ApplicationDbContext>(options => services
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"))); .AddAuthorization(options =>
services.AddTransient<ITrueEmailSender, MailSender>()
.AddTransient<IBillingService, BillingService>()
.AddTransient<ICalendarManager, CalendarManager>();
services.AddTransient<IFileSystemAuthManager, FileSystemAuthManager>();
WorkflowHelpers.ConfigureBillingService();
using (var app = builder.Build())
{ {
if (app.Environment.IsDevelopment()) options.AddPolicy("ApiScope", policy =>
app.UseDeveloperExceptionPage(); {
policy
.RequireAuthenticatedUser()
.RequireClaim(JwtClaimTypes.Scope, new string[] { "blogs" });
});
})
.AddCors(options =>
{
// this defines a CORS policy called "default"
options.AddPolicy("default", policy =>
{
policy.WithOrigins(audience)
.AllowAnyHeader()
.AllowAnyMethod();
});
})
.AddControllers();
app // accepts any access token issued by identity server
.UseRouting() var authenticationBuilder = services.AddAuthentication("Bearer")
.UseAuthentication() .AddJwtBearer("Bearer", options =>
.UseAuthorization() {
.UseCors("default") options.IncludeErrorDetails = true;
/* .UseEndpoints(endpoints => options.Authority = authority;
{ options.TokenValidationParameters =
endpoints.MapDefaultControllerRoute() new() { ValidateAudience = false, RoleClaimType = Constants.RoleClaimType };
.RequireAuthorization(); options.MapInboundClaims = true;
})*/ });
; services.AddDbContext<ApplicationDbContext>(options =>
// app.MapIdentityApi<ApplicationUser>().RequireAuthorization("ApiScope"); options.UseNpgsql(builder.Configuration.GetConnectionString(Constants.YavscConnectionStringName)));
app.MapDefaultControllerRoute();
app.MapGet("/identity", (HttpContext context) =>
new JsonResult(context?.User?.Claims.Select(c => new { c.Type, c.Value }))
);
// app.UseSession(); services.AddTransient<ITrueEmailSender, MailSender>()
await app.RunAsync(); .AddTransient<IBillingService, BillingService>()
} .AddTransient<ICalendarManager, CalendarManager>();
services.AddTransient<IFileSystemAuthManager, FileSystemAuthManager>();
WorkflowHelpers.ConfigureBillingService();
using (var app = builder.Build())
{
if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
app
.UseRouting()
.UseAuthentication()
.UseAuthorization()
.UseCors("default")
/* .UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute()
.RequireAuthorization();
})*/
;
// app.MapIdentityApi<ApplicationUser>().RequireAuthorization("ApiScope");
app.MapDefaultControllerRoute();
app.MapGet("/identity", (HttpContext context) =>
new JsonResult(context?.User?.Claims.Select(c => new { c.Type, c.Value }))
);
// app.UseSession();
await app.RunAsync();
} }
}
} }

View file

@ -0,0 +1,17 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://localhost:6001"
}
}
}
}

View file

@ -1,46 +1,54 @@
using IdentityServer8.EntityFramework.DbContexts; using IdentityServer8.EntityFramework.DbContexts;
using IdentityServer8.EntityFramework.Entities; using IdentityServer8.EntityFramework.Entities;
using IdentityServer8.EntityFramework.Stores;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Yavsc.Helpers;
using Yavsc.Models; using Yavsc.Models;
using Yavsc.Models.Auth; using Yavsc.Models.Auth;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
[Authorize("AdministratorOnly")] [Authorize("AdministratorOnly")]
public class ClientController : Controller public class ClientController : Controller
{ {
private readonly ConfigurationDbContext _context; private readonly ApplicationDbContext context;
private readonly ClientStore clientStore;
public ClientController(ConfigurationDbContext context) public ClientController(ApplicationDbContext context,
ClientStore clientStore,
IdentityServer8.Stores.ValidatingClientStore<ClientStore> validatingClientStore
)
{ {
_context = context; this.context = context;
this.clientStore = clientStore;
} }
// GET: Client // GET: Client
public async Task<IActionResult> Index() public async Task<IActionResult> Index()
{ {
return View(await _context.Clients.Include(c=>c.AllowedGrantTypes) return View(await context.Clients.Include(c => c.AllowedGrantTypes)
.Include(c=>c.RedirectUris).ToListAsync()); .Include(c => c.RedirectUris).ToListAsync());
} }
// GET: Client/Details/5 // GET: Client/Details/5
public async Task<IActionResult> Details(string id) public async Task<IActionResult> Details(int id)
{ {
if (id == null)
{
return NotFound();
}
Client client = await _context.Clients.Include( Client client = await context.Clients.Include(
c => c.ClientSecrets c => c.ClientSecrets
).Include(c=>c.AllowedGrantTypes) ).Include(c => c.AllowedGrantTypes)
.Include(c=>c.RedirectUris) .Include(c => c.RedirectUris)
.SingleAsync(m => m.ClientId == id); .Include(c=>c.ClientSecrets)
.Include(c=>c.AllowedCorsOrigins)
.Include(c=>c.AllowedScopes)
.Include(c=>c.IdentityProviderRestrictions)
.Include(c=>c.PostLogoutRedirectUris)
.SingleAsync(m => m.Id == id);
if (client == null) if (client == null)
{ {
return NotFound(); return NotFound();
@ -51,6 +59,8 @@ namespace Yavsc.Controllers
// GET: Client/Create // GET: Client/Create
public IActionResult Create() public IActionResult Create()
{ {
Secret s;
SetAppTypesInputValues(); SetAppTypesInputValues();
return View(); return View();
} }
@ -62,15 +72,30 @@ namespace Yavsc.Controllers
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
if (string.IsNullOrWhiteSpace(client.ClientId)) var model = await clientStore.FindClientByIdAsync(client.ClientId);
client.ClientId = Guid.NewGuid().ToString(); if (model != null)
_context.Clients.Add(client); {
await _context.SaveChangesAsync(); ModelState.AddModelError("ClientId", "existent");
return BadRequest(ModelState);
}
context.Clients.Add(client);
if (client.ClientSecrets != null)
{
foreach (var secret in client.ClientSecrets)
{
context.ClientSecrets.Add(secret);
}
}
await context.SaveChangesAsync();
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
SetAppTypesInputValues(); SetAppTypesInputValues();
return View(client); return View(client);
} }
private void SetAppTypesInputValues() private void SetAppTypesInputValues()
{ {
IEnumerable<SelectListItem> types = new SelectListItem[] { IEnumerable<SelectListItem> types = new SelectListItem[] {
@ -85,14 +110,9 @@ namespace Yavsc.Controllers
ViewData["AccessTokenType"] = types; ViewData["AccessTokenType"] = types;
} }
// GET: Client/Edit/5 // GET: Client/Edit/5
public async Task<IActionResult> Edit(string id) public async Task<IActionResult> Edit(int id)
{ {
if (id == null) Client client = await context.Clients.SingleOrDefaultAsync(m => m.Id == id);
{
return NotFound();
}
Client client = await _context.Clients.SingleAsync(m => m.ClientId == id);
if (client == null) if (client == null)
{ {
return NotFound(); return NotFound();
@ -108,8 +128,16 @@ namespace Yavsc.Controllers
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(client);
await _context.SaveChangesAsync(); if (client.ClientSecrets != null)
{
foreach (var secret in client.ClientSecrets)
{
context.Update(secret);
}
}
context.Update(client);
await context.SaveChangesAsync();
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(client); return View(client);
@ -117,14 +145,10 @@ namespace Yavsc.Controllers
// GET: Client/Delete/5 // GET: Client/Delete/5
[ActionName("Delete")] [ActionName("Delete")]
public async Task<IActionResult> Delete(string id) public async Task<IActionResult> Delete(int id)
{ {
if (id == null)
{
return NotFound();
}
Client client = await _context.Clients.SingleAsync(m => m.ClientId == id); Client client = await context.Clients.SingleOrDefaultAsync(m => m.Id == id);
if (client == null) if (client == null)
{ {
return NotFound(); return NotFound();
@ -136,11 +160,13 @@ namespace Yavsc.Controllers
// POST: Client/Delete/5 // POST: Client/Delete/5
[HttpPost, ActionName("Delete")] [HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string id) public async Task<IActionResult> DeleteConfirmed(int id)
{ {
Client client = await _context.Clients.SingleAsync(m => m.ClientId == id); Client client = await context.Clients
_context.Clients.Remove(client); .Include(client => client.ClientSecrets)
await _context.SaveChangesAsync(); .SingleAsync(m => m.Id == id);
context.Clients.Remove(client);
await context.SaveChangesAsync();
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

View file

@ -42,6 +42,7 @@ using IdentityServer8.EntityFramework.Stores;
using IdentityServer8.EntityFramework.Services; using IdentityServer8.EntityFramework.Services;
using IdentityServer8.EntityFramework.Interfaces; using IdentityServer8.EntityFramework.Interfaces;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using IdentityServer8.Validation;
namespace Yavsc.Extensions; namespace Yavsc.Extensions;
@ -103,7 +104,8 @@ public static class HostingExtensions
.AddTransient<IBillingService, BillingService>() .AddTransient<IBillingService, BillingService>()
.AddTransient<IDataStore, FileDataStore>((sp) => new FileDataStore("googledatastore", false)) .AddTransient<IDataStore, FileDataStore>((sp) => new FileDataStore("googledatastore", false))
.AddTransient<ICalendarManager, CalendarManager>() .AddTransient<ICalendarManager, CalendarManager>()
.AddTransient<BlogSpotService>(); .AddTransient<BlogSpotService>()
.AddTransient<ValidatingClientStore<ClientStore>>();
// TODO for SMS: services.AddTransient<ISmsSender, AuthMessageSender>(); // TODO for SMS: services.AddTransient<ISmsSender, AuthMessageSender>();
@ -280,6 +282,7 @@ public static class HostingExtensions
}) })
.AddAspNetIdentity<ApplicationUser>() .AddAspNetIdentity<ApplicationUser>()
.AddClientStore<ClientStore>() .AddClientStore<ClientStore>()
.AddClientConfigurationValidator<DefaultClientConfigurationValidator>()
.AddCorsPolicyService<CorsPolicyService>() .AddCorsPolicyService<CorsPolicyService>()
.AddResourceStore<ResourceStore>() .AddResourceStore<ResourceStore>()
.AddConfigurationStore(options => .AddConfigurationStore(options =>
@ -395,6 +398,7 @@ public static class HostingExtensions
app.UseSession(); app.UseSession();
return app; return app;
} }
private static void MigrateDatabase(this IApplicationBuilder app) private static void MigrateDatabase(this IApplicationBuilder app)
{ {
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope()) using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
@ -404,8 +408,6 @@ public static class HostingExtensions
{ {
foreach (Type contextType in new Type[] foreach (Type contextType in new Type[]
{ {
typeof(PersistedGrantDbContext),
typeof(ConfigurationDbContext),
typeof(ApplicationDbContext) typeof(ApplicationDbContext)
}) })
{ {

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,78 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class idResClams : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IdentityResourceClaim_IdentityResources_IdentityResourceId",
table: "IdentityResourceClaim");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityResourceClaim",
table: "IdentityResourceClaim");
migrationBuilder.RenameTable(
name: "IdentityResourceClaim",
newName: "IdentityResourceClaims");
migrationBuilder.RenameIndex(
name: "IX_IdentityResourceClaim_IdentityResourceId",
table: "IdentityResourceClaims",
newName: "IX_IdentityResourceClaims_IdentityResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityResourceClaims",
table: "IdentityResourceClaims",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_IdentityResourceClaims_IdentityResources_IdentityResourceId",
table: "IdentityResourceClaims",
column: "IdentityResourceId",
principalTable: "IdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IdentityResourceClaims_IdentityResources_IdentityResourceId",
table: "IdentityResourceClaims");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityResourceClaims",
table: "IdentityResourceClaims");
migrationBuilder.RenameTable(
name: "IdentityResourceClaims",
newName: "IdentityResourceClaim");
migrationBuilder.RenameIndex(
name: "IX_IdentityResourceClaims_IdentityResourceId",
table: "IdentityResourceClaim",
newName: "IX_IdentityResourceClaim_IdentityResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityResourceClaim",
table: "IdentityResourceClaim",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_IdentityResourceClaim_IdentityResources_IdentityResourceId",
table: "IdentityResourceClaim",
column: "IdentityResourceId",
principalTable: "IdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,78 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class IdentityResourceProperties : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IdentityResourceProperty_IdentityResources_IdentityResource~",
table: "IdentityResourceProperty");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityResourceProperty",
table: "IdentityResourceProperty");
migrationBuilder.RenameTable(
name: "IdentityResourceProperty",
newName: "IdentityResourceProperties");
migrationBuilder.RenameIndex(
name: "IX_IdentityResourceProperty_IdentityResourceId",
table: "IdentityResourceProperties",
newName: "IX_IdentityResourceProperties_IdentityResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityResourceProperties",
table: "IdentityResourceProperties",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_IdentityResourceProperties_IdentityResources_IdentityResour~",
table: "IdentityResourceProperties",
column: "IdentityResourceId",
principalTable: "IdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IdentityResourceProperties_IdentityResources_IdentityResour~",
table: "IdentityResourceProperties");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityResourceProperties",
table: "IdentityResourceProperties");
migrationBuilder.RenameTable(
name: "IdentityResourceProperties",
newName: "IdentityResourceProperty");
migrationBuilder.RenameIndex(
name: "IX_IdentityResourceProperties_IdentityResourceId",
table: "IdentityResourceProperty",
newName: "IX_IdentityResourceProperty_IdentityResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityResourceProperty",
table: "IdentityResourceProperty",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_IdentityResourceProperty_IdentityResources_IdentityResource~",
table: "IdentityResourceProperty",
column: "IdentityResourceId",
principalTable: "IdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,78 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class ApiResourceSecrets : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiResourceSecret_ApiResources_ApiResourceId",
table: "ApiResourceSecret");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiResourceSecret",
table: "ApiResourceSecret");
migrationBuilder.RenameTable(
name: "ApiResourceSecret",
newName: "ApiResourceSecrets");
migrationBuilder.RenameIndex(
name: "IX_ApiResourceSecret_ApiResourceId",
table: "ApiResourceSecrets",
newName: "IX_ApiResourceSecrets_ApiResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiResourceSecrets",
table: "ApiResourceSecrets",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiResourceSecrets_ApiResources_ApiResourceId",
table: "ApiResourceSecrets",
column: "ApiResourceId",
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiResourceSecrets_ApiResources_ApiResourceId",
table: "ApiResourceSecrets");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiResourceSecrets",
table: "ApiResourceSecrets");
migrationBuilder.RenameTable(
name: "ApiResourceSecrets",
newName: "ApiResourceSecret");
migrationBuilder.RenameIndex(
name: "IX_ApiResourceSecrets_ApiResourceId",
table: "ApiResourceSecret",
newName: "IX_ApiResourceSecret_ApiResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiResourceSecret",
table: "ApiResourceSecret",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiResourceSecret_ApiResources_ApiResourceId",
table: "ApiResourceSecret",
column: "ApiResourceId",
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,78 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class ApiResourceScopes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiResourceScope_ApiResources_ApiResourceId",
table: "ApiResourceScope");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiResourceScope",
table: "ApiResourceScope");
migrationBuilder.RenameTable(
name: "ApiResourceScope",
newName: "ApiResourceScopes");
migrationBuilder.RenameIndex(
name: "IX_ApiResourceScope_ApiResourceId",
table: "ApiResourceScopes",
newName: "IX_ApiResourceScopes_ApiResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiResourceScopes",
table: "ApiResourceScopes",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiResourceScopes_ApiResources_ApiResourceId",
table: "ApiResourceScopes",
column: "ApiResourceId",
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiResourceScopes_ApiResources_ApiResourceId",
table: "ApiResourceScopes");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiResourceScopes",
table: "ApiResourceScopes");
migrationBuilder.RenameTable(
name: "ApiResourceScopes",
newName: "ApiResourceScope");
migrationBuilder.RenameIndex(
name: "IX_ApiResourceScopes_ApiResourceId",
table: "ApiResourceScope",
newName: "IX_ApiResourceScope_ApiResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiResourceScope",
table: "ApiResourceScope",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiResourceScope_ApiResources_ApiResourceId",
table: "ApiResourceScope",
column: "ApiResourceId",
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,78 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class ApiResourceClaims : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiResourceClaim_ApiResources_ApiResourceId",
table: "ApiResourceClaim");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiResourceClaim",
table: "ApiResourceClaim");
migrationBuilder.RenameTable(
name: "ApiResourceClaim",
newName: "ApiResourceClaims");
migrationBuilder.RenameIndex(
name: "IX_ApiResourceClaim_ApiResourceId",
table: "ApiResourceClaims",
newName: "IX_ApiResourceClaims_ApiResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiResourceClaims",
table: "ApiResourceClaims",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiResourceClaims_ApiResources_ApiResourceId",
table: "ApiResourceClaims",
column: "ApiResourceId",
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiResourceClaims_ApiResources_ApiResourceId",
table: "ApiResourceClaims");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiResourceClaims",
table: "ApiResourceClaims");
migrationBuilder.RenameTable(
name: "ApiResourceClaims",
newName: "ApiResourceClaim");
migrationBuilder.RenameIndex(
name: "IX_ApiResourceClaims_ApiResourceId",
table: "ApiResourceClaim",
newName: "IX_ApiResourceClaim_ApiResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiResourceClaim",
table: "ApiResourceClaim",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiResourceClaim_ApiResources_ApiResourceId",
table: "ApiResourceClaim",
column: "ApiResourceId",
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,78 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class ApiResourceProperties : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiResourceProperty_ApiResources_ApiResourceId",
table: "ApiResourceProperty");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiResourceProperty",
table: "ApiResourceProperty");
migrationBuilder.RenameTable(
name: "ApiResourceProperty",
newName: "ApiResourceProperties");
migrationBuilder.RenameIndex(
name: "IX_ApiResourceProperty_ApiResourceId",
table: "ApiResourceProperties",
newName: "IX_ApiResourceProperties_ApiResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiResourceProperties",
table: "ApiResourceProperties",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiResourceProperties_ApiResources_ApiResourceId",
table: "ApiResourceProperties",
column: "ApiResourceId",
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiResourceProperties_ApiResources_ApiResourceId",
table: "ApiResourceProperties");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiResourceProperties",
table: "ApiResourceProperties");
migrationBuilder.RenameTable(
name: "ApiResourceProperties",
newName: "ApiResourceProperty");
migrationBuilder.RenameIndex(
name: "IX_ApiResourceProperties_ApiResourceId",
table: "ApiResourceProperty",
newName: "IX_ApiResourceProperty_ApiResourceId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiResourceProperty",
table: "ApiResourceProperty",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiResourceProperty_ApiResources_ApiResourceId",
table: "ApiResourceProperty",
column: "ApiResourceId",
principalTable: "ApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,78 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class ApiScopeClaims : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiScopeClaim_ApiScopes_ScopeId",
table: "ApiScopeClaim");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiScopeClaim",
table: "ApiScopeClaim");
migrationBuilder.RenameTable(
name: "ApiScopeClaim",
newName: "ApiScopeClaims");
migrationBuilder.RenameIndex(
name: "IX_ApiScopeClaim_ScopeId",
table: "ApiScopeClaims",
newName: "IX_ApiScopeClaims_ScopeId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiScopeClaims",
table: "ApiScopeClaims",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiScopeClaims_ApiScopes_ScopeId",
table: "ApiScopeClaims",
column: "ScopeId",
principalTable: "ApiScopes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiScopeClaims_ApiScopes_ScopeId",
table: "ApiScopeClaims");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiScopeClaims",
table: "ApiScopeClaims");
migrationBuilder.RenameTable(
name: "ApiScopeClaims",
newName: "ApiScopeClaim");
migrationBuilder.RenameIndex(
name: "IX_ApiScopeClaims_ScopeId",
table: "ApiScopeClaim",
newName: "IX_ApiScopeClaim_ScopeId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiScopeClaim",
table: "ApiScopeClaim",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiScopeClaim_ApiScopes_ScopeId",
table: "ApiScopeClaim",
column: "ScopeId",
principalTable: "ApiScopes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,78 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class ApiScopeProperties : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiScopeProperty_ApiScopes_ScopeId",
table: "ApiScopeProperty");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiScopeProperty",
table: "ApiScopeProperty");
migrationBuilder.RenameTable(
name: "ApiScopeProperty",
newName: "ApiScopeProperties");
migrationBuilder.RenameIndex(
name: "IX_ApiScopeProperty_ScopeId",
table: "ApiScopeProperties",
newName: "IX_ApiScopeProperties_ScopeId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiScopeProperties",
table: "ApiScopeProperties",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiScopeProperties_ApiScopes_ScopeId",
table: "ApiScopeProperties",
column: "ScopeId",
principalTable: "ApiScopes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApiScopeProperties_ApiScopes_ScopeId",
table: "ApiScopeProperties");
migrationBuilder.DropPrimaryKey(
name: "PK_ApiScopeProperties",
table: "ApiScopeProperties");
migrationBuilder.RenameTable(
name: "ApiScopeProperties",
newName: "ApiScopeProperty");
migrationBuilder.RenameIndex(
name: "IX_ApiScopeProperties_ScopeId",
table: "ApiScopeProperty",
newName: "IX_ApiScopeProperty_ScopeId");
migrationBuilder.AddPrimaryKey(
name: "PK_ApiScopeProperty",
table: "ApiScopeProperty",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ApiScopeProperty_ApiScopes_ScopeId",
table: "ApiScopeProperty",
column: "ScopeId",
principalTable: "ApiScopes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View file

@ -1,59 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class article : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Content",
table: "Comment",
newName: "Article");
migrationBuilder.RenameColumn(
name: "Content",
table: "BlogSpot",
newName: "Article");
migrationBuilder.CreateIndex(
name: "IX_MusicalPreference_TendencyId",
table: "MusicalPreference",
column: "TendencyId");
migrationBuilder.AddForeignKey(
name: "FK_MusicalPreference_MusicalTendency_TendencyId",
table: "MusicalPreference",
column: "TendencyId",
principalTable: "MusicalTendency",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_MusicalPreference_MusicalTendency_TendencyId",
table: "MusicalPreference");
migrationBuilder.DropIndex(
name: "IX_MusicalPreference_TendencyId",
table: "MusicalPreference");
migrationBuilder.RenameColumn(
name: "Article",
table: "Comment",
newName: "Content");
migrationBuilder.RenameColumn(
name: "Article",
table: "BlogSpot",
newName: "Content");
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,336 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class identityClientsCleanup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ClientClaim");
migrationBuilder.DropTable(
name: "ClientCorsOrigins");
migrationBuilder.DropTable(
name: "ClientGrantType");
migrationBuilder.DropTable(
name: "ClientIdPRestriction");
migrationBuilder.DropTable(
name: "ClientPostLogoutRedirectUri");
migrationBuilder.DropTable(
name: "ClientProperty");
migrationBuilder.DropTable(
name: "ClientRedirectUri");
migrationBuilder.DropTable(
name: "ClientScope");
migrationBuilder.DropTable(
name: "ClientSecret");
migrationBuilder.DropTable(
name: "Clients");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
AbsoluteRefreshTokenLifetime = table.Column<int>(type: "integer", nullable: false),
AccessTokenLifetime = table.Column<int>(type: "integer", nullable: false),
AccessTokenType = table.Column<int>(type: "integer", nullable: false),
AllowAccessTokensViaBrowser = table.Column<bool>(type: "boolean", nullable: false),
AllowOfflineAccess = table.Column<bool>(type: "boolean", nullable: false),
AllowPlainTextPkce = table.Column<bool>(type: "boolean", nullable: false),
AllowRememberConsent = table.Column<bool>(type: "boolean", nullable: false),
AllowedIdentityTokenSigningAlgorithms = table.Column<string>(type: "text", nullable: true),
AlwaysIncludeUserClaimsInIdToken = table.Column<bool>(type: "boolean", nullable: false),
AlwaysSendClientClaims = table.Column<bool>(type: "boolean", nullable: false),
AuthorizationCodeLifetime = table.Column<int>(type: "integer", nullable: false),
BackChannelLogoutSessionRequired = table.Column<bool>(type: "boolean", nullable: false),
BackChannelLogoutUri = table.Column<string>(type: "text", nullable: true),
ClientClaimsPrefix = table.Column<string>(type: "text", nullable: true),
ClientId = table.Column<string>(type: "text", nullable: true),
ClientName = table.Column<string>(type: "text", nullable: true),
ClientUri = table.Column<string>(type: "text", nullable: true),
ConsentLifetime = table.Column<int>(type: "integer", nullable: true),
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Description = table.Column<string>(type: "text", nullable: true),
DeviceCodeLifetime = table.Column<int>(type: "integer", nullable: false),
EnableLocalLogin = table.Column<bool>(type: "boolean", nullable: false),
Enabled = table.Column<bool>(type: "boolean", nullable: false),
FrontChannelLogoutSessionRequired = table.Column<bool>(type: "boolean", nullable: false),
FrontChannelLogoutUri = table.Column<string>(type: "text", nullable: true),
IdentityTokenLifetime = table.Column<int>(type: "integer", nullable: false),
IncludeJwtId = table.Column<bool>(type: "boolean", nullable: false),
LastAccessed = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
LogoUri = table.Column<string>(type: "text", nullable: true),
NonEditable = table.Column<bool>(type: "boolean", nullable: false),
PairWiseSubjectSalt = table.Column<string>(type: "text", nullable: true),
ProtocolType = table.Column<string>(type: "text", nullable: true),
RefreshTokenExpiration = table.Column<int>(type: "integer", nullable: false),
RefreshTokenUsage = table.Column<int>(type: "integer", nullable: false),
RequireClientSecret = table.Column<bool>(type: "boolean", nullable: false),
RequireConsent = table.Column<bool>(type: "boolean", nullable: false),
RequirePkce = table.Column<bool>(type: "boolean", nullable: false),
RequireRequestObject = table.Column<bool>(type: "boolean", nullable: false),
SlidingRefreshTokenLifetime = table.Column<int>(type: "integer", nullable: false),
UpdateAccessTokenClaimsOnRefresh = table.Column<bool>(type: "boolean", nullable: false),
Updated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
UserCodeType = table.Column<string>(type: "text", nullable: true),
UserSsoLifetime = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ClientClaim",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
Type = table.Column<string>(type: "text", nullable: true),
Value = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientClaim", x => x.Id);
table.ForeignKey(
name: "FK_ClientClaim_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientCorsOrigins",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
Origin = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientCorsOrigins", x => x.Id);
table.ForeignKey(
name: "FK_ClientCorsOrigins_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientGrantType",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
GrantType = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientGrantType", x => x.Id);
table.ForeignKey(
name: "FK_ClientGrantType_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientIdPRestriction",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
Provider = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientIdPRestriction", x => x.Id);
table.ForeignKey(
name: "FK_ClientIdPRestriction_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientPostLogoutRedirectUri",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
PostLogoutRedirectUri = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientPostLogoutRedirectUri", x => x.Id);
table.ForeignKey(
name: "FK_ClientPostLogoutRedirectUri_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientProperty",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
Key = table.Column<string>(type: "text", nullable: true),
Value = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientProperty", x => x.Id);
table.ForeignKey(
name: "FK_ClientProperty_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientRedirectUri",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
RedirectUri = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientRedirectUri", x => x.Id);
table.ForeignKey(
name: "FK_ClientRedirectUri_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientScope",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
Scope = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientScope", x => x.Id);
table.ForeignKey(
name: "FK_ClientScope_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientSecret",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Description = table.Column<string>(type: "text", nullable: true),
Expiration = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Type = table.Column<string>(type: "text", nullable: true),
Value = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientSecret", x => x.Id);
table.ForeignKey(
name: "FK_ClientSecret_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ClientClaim_ClientId",
table: "ClientClaim",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientCorsOrigins_ClientId",
table: "ClientCorsOrigins",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientGrantType_ClientId",
table: "ClientGrantType",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientIdPRestriction_ClientId",
table: "ClientIdPRestriction",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientPostLogoutRedirectUri_ClientId",
table: "ClientPostLogoutRedirectUri",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientProperty_ClientId",
table: "ClientProperty",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientRedirectUri_ClientId",
table: "ClientRedirectUri",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientScope_ClientId",
table: "ClientScope",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ClientSecret_ClientId",
table: "ClientSecret",
column: "ClientId");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -8,12 +8,12 @@ namespace Yavsc.ViewModels
[Display(Name="EnroledLabel", ResourceType=typeof(EnrolerViewModel))] [Display(Name="EnroledLabel", ResourceType=typeof(EnrolerViewModel))]
public string EnroledUserName { get; set; } public string EnroledUserName { get; set; }
[YaRequired] [Required]
public string EnroledUserId { get; set; } public string EnroledUserId { get; set; }
[Display(Name="RoleNameLabel", ResourceType=typeof(EnrolerViewModel))] [Display(Name="RoleNameLabel", ResourceType=typeof(EnrolerViewModel))]
[YaRequired] [Required]
public string RoleName { get; set; } public string RoleName { get; set; }
} }
} }

View file

@ -8,11 +8,11 @@ namespace Yavsc.ViewModels.Gen
public class PdfGenerationViewModel public class PdfGenerationViewModel
{ {
[YaRequired] [Required]
public string TeXSource { get; set; } public string TeXSource { get; set; }
[YaRequired] [Required]
public string BaseFileName { get; set; } public string BaseFileName { get; set; }
[YaRequired] [Required]
public string DestDir { get; set; } public string DestDir { get; set; }
public bool Generated { get; set; } public bool Generated { get; set; }
public HtmlString GenerationErrorMessage { get; set; } public HtmlString GenerationErrorMessage { get; set; }

View file

@ -6,7 +6,7 @@ namespace Yavsc.ViewModels.Manage
{ {
public class SetFullNameViewModel public class SetFullNameViewModel
{ {
[YaRequired] [Required]
[Display(Name = "Your full name"), YaStringLength(512)] [Display(Name = "Your full name"), YaStringLength(512)]
public string FullName { get; set; } public string FullName { get; set; }
} }

View file

@ -1,22 +1,21 @@
@model Client @model Client
@{
ViewData["Title"] = @Localizer["Create"];
}
<h2>@Localizer["Create"]</h2> <h2>@Localizer["Create"]</h2>
<form asp-action="Create"> <form asp-action="Create">
<div class="form-horizontal"> <div class="form-horizontal">
<h4>Client</h4> <h4>Client</h4>
<hr /> <hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly"
class="text-danger"></div>
<div class="form-group"> <div class="form-group">
<label asp-for="ClientId" class="col-md-2 control-label"></label> <label asp-for="ClientId"
class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="ClientId" class="form-control" /> <input asp-for="ClientId" class="form-control" />
<span asp-validation-for="ClientId" class="text-danger" ></span> <span asp-validation-for="ClientId"
class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -28,50 +27,48 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="ClientName" class="col-md-2 control-label"></label> <label asp-for="ClientName"
class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="ClientName" class="form-control" /> <input asp-for="ClientName" class="form-control" />
<span asp-validation-for="ClientName" class="text-danger" ></span> <span asp-validation-for="ClientName" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="FrontChannelLogoutUri" class="col-md-2 control-label"></label> <label asp-for="FrontChannelLogoutUri" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="FrontChannelLogoutUri" class="form-control"></span> <input asp-for="FrontChannelLogoutUri"
<span asp-validation-for="FrontChannelLogoutUri" class="text-danger" ></span> class="form-control"></span>
<span asp-validation-for="FrontChannelLogoutUri"
class="text-danger"></span>
</div>
</div> </div>
</div> <div class="form-group">
<div class="form-group"> <label asp-for="RedirectUris" class="col-md-2 control-label"></label>
<label asp-for="RedirectUris" class="col-md-2 control-label"></label> <div class="col-md-10">
<div class="col-md-10"> <input asp-for="RedirectUris" class="form-control" />
<input asp-for="RedirectUris" class="form-control" /> <span asp-validation-for="RedirectUris" class="text-danger"></span>
<span asp-validation-for="RedirectUris" class="text-danger" ></span> </div>
</div> </div>
</div> <div class="form-group">
<div class="form-group"> <label asp-for="AbsoluteRefreshTokenLifetime" class="col-md-2 control-label"></label>
<label asp-for="AbsoluteRefreshTokenLifetime" class="col-md-2 control-label"></label> <div class="col-md-10">
<div class="col-md-10"> <input asp-for="AbsoluteRefreshTokenLifetime" class="form-control"></span>
<input asp-for="AbsoluteRefreshTokenLifetime" class="form-control" ></span> <span asp-validation-for="AbsoluteRefreshTokenLifetime" class="text-danger"></span>
<span asp-validation-for="AbsoluteRefreshTokenLifetime" class="text-danger"></span> </div>
</div> </div>
</div> <div class="form-group">
<div class="form-group"> <label asp-for="AccessTokenType" class="col-md-2 control-label"></label>
<label asp-for="ClientSecrets" class="col-md-2 control-label"></label> <div class="col-md-10">
<div class="col-md-10"> @Html.DropDownList("AccessTokenType")
<input asp-for="ClientSecrets" class="form-control" /> <span asp-validation-for="AccessTokenType" class="text-danger"></span>
<span asp-validation-for="ClientSecrets" class="text-danger" ></span> </div>
</div> </div>
</div> <div class="form-group">
<div class="form-group"> <div class="col-md-offset-2 col-md-10">
<label asp-for="AccessTokenType" class="col-md-2 control-label"></label> <input type="submit" value="Create" class="btn btn-default" />
<div class="col-md-10"> </div>
@Html.DropDownList("AccessTokenType") </div>
<span asp-validation-for="AccessTokenType" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div> </div>
</div> </div>
</div> </div>

View file

@ -1,9 +1,5 @@
@model Client @model Client
@{
ViewData["Title"] = @Localizer["Delete"];
}
<h2>@Localizer["Delete"]</h2> <h2>@Localizer["Delete"]</h2>
<h3>@Localizer["AreYourSureYouWantToDeleteThis"]</h3> <h3>@Localizer["AreYourSureYouWantToDeleteThis"]</h3>
@ -61,7 +57,7 @@
</dd> </dd>
</dl> </dl>
<form asp-action="Delete"> <form asp-action="Delete" asp-route-id="@Model.Id">
<div class="form-actions no-color"> <div class="form-actions no-color">
<input type="submit" value="Delete" class="btn btn-default" /> | <input type="submit" value="Delete" class="btn btn-default" /> |
<a asp-action="Index">@Localizer["Back to List"]</a> <a asp-action="Index">@Localizer["Back to List"]</a>

View file

@ -1,9 +1,5 @@
@model Client @model Client
@{
ViewData["Title"] = @Localizer["Details"];
}
<h2>@Localizer["Details"]</h2> <h2>@Localizer["Details"]</h2>
<div> <div>
@ -31,7 +27,6 @@
<dt> <dt>
@Html.DisplayNameFor(model => model.FrontChannelLogoutUri) @Html.DisplayNameFor(model => model.FrontChannelLogoutUri)
</dt> </dt>
<dd>
@Html.DisplayFor(model => model.FrontChannelLogoutUri) @Html.DisplayFor(model => model.FrontChannelLogoutUri)
</dd> </dd>
<dt> <dt>
@ -52,7 +47,14 @@
<dt> <dt>
@Html.DisplayNameFor(model => model.ClientSecrets) @Html.DisplayNameFor(model => model.ClientSecrets)
</dt> </dt>
<dd>Count : @Model.ClientSecrets.Count</dd> <dd>
<ul>
@foreach(var secret in Model.ClientSecrets)
{
<li>@Html.DisplayForModel(secret)</li>
}
</ul>
</dd>
<dt> <dt>
@Html.DisplayNameFor(model => model.AccessTokenType) @Html.DisplayNameFor(model => model.AccessTokenType)

View file

@ -1,9 +1,5 @@
@model Client @model Client
@{
ViewData["Title"] = "Edit";
}
<h2>@Localizer["Edit"]</h2> <h2>@Localizer["Edit"]</h2>
<form asp-action="Edit"> <form asp-action="Edit">
@ -65,7 +61,7 @@
<div class="form-group"> <div class="form-group">
<label asp-for="AccessTokenType" class="col-md-2 control-label"></label> <label asp-for="AccessTokenType" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.DropDownList("Type") @Html.DropDownList("AccessTokenType")
<span asp-validation-for="AccessTokenType" class="text-danger" ></span> <span asp-validation-for="AccessTokenType" class="text-danger" ></span>
</div> </div>
</div> </div>

View file

@ -1,10 +1,6 @@
@using IdentityServer8.Models @using IdentityServer8.Models
@model IEnumerable<IdentityServer8.EntityFramework.Entities.Client> @model IEnumerable<IdentityServer8.EntityFramework.Entities.Client>
@{
ViewData["Title"] = @Localizer["Index"];
}
<h2>@Localizer["Index"]</h2> <h2>@Localizer["Index"]</h2>
<p> <p>
@ -40,43 +36,48 @@
<th></th> <th></th>
</tr> </tr>
@foreach (var item in Model) { @foreach (var item in Model)
<tr> {
<td> <tr>
@Html.DisplayFor(modelItem => item.ClientId) <td>
</td> @Html.DisplayFor(modelItem => item.ClientId)
<td> </td>
@Html.DisplayFor(modelItem => item.Enabled) <td>
</td> @Html.DisplayFor(modelItem => item.Enabled)
<td> </td>
@Html.DisplayFor(modelItem => item.ClientName) <td>
</td> @Html.DisplayFor(modelItem => item.ClientName)
<td> </td>
@Html.DisplayFor(modelItem => item.FrontChannelLogoutUri) <td>
</td> @Html.DisplayFor(modelItem => item.FrontChannelLogoutUri)
<td> </td>
<ul> <td>
@foreach (var uri in item.RedirectUris) <ul>
{ <li>@uri.RedirectUri</li> } @foreach (var uri in item.RedirectUris)
</ul> {
</td> <li>@uri.RedirectUri</li>
<td> }
@Html.DisplayFor(modelItem => item.AbsoluteRefreshTokenLifetime) </ul>
</td> </td>
<td> <td>
<ul> @Html.DisplayFor(modelItem => item.AbsoluteRefreshTokenLifetime)
@foreach (var t in item.AllowedGrantTypes) </td>
{ <li>@t.GrantType</li> } <td>
</ul> <ul>
</td> @foreach (var t in item.AllowedGrantTypes)
<td> {
@Enum.GetName(typeof(AccessTokenType), item.AccessTokenType) <li>@t.GrantType</li>
</td> }
<td> </ul>
<a asp-action="Edit" asp-route-id="@item.ClientId">Edit</a> | </td>
<a asp-action="Details" asp-route-id="@item.ClientId">Details</a> | <td>
<a asp-action="Delete" asp-route-id="@item.ClientId">Delete</a> @Enum.GetName(typeof(AccessTokenType), item.AccessTokenType)
</td> </td>
</tr> <td>
} <a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</table> </table>

View file

@ -0,0 +1,41 @@
@model ClientSecret
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.ClientId)
</dt>
<dd>
@Html.DisplayFor(model => model.ClientId)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Created)
</dt>
<dd>
@Html.DisplayFor(model => model.Created)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Expiration)
</dt>
<dd>
@Html.DisplayFor(model => model.Expiration)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Description)
</dt>
<dd>
@Html.DisplayFor(model => model.Description)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Type)
</dt>
<dd>
@Html.DisplayFor(model => model.Type)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Value)
</dt>
<dd>
@Html.DisplayFor(model => model.Value)
</dd>
</dl>

View file

@ -0,0 +1,16 @@
@model ClientSecret
<div class="form-group">
<label asp-for="Description" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.EditorFor(m => m.Description)
<span asp-validation-for="Description" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Value" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.EditorFor(m => m.Value)
<span asp-validation-for="Value" class="text-danger"></span>
</div>
</div>

View file

@ -3,12 +3,8 @@ namespace Yavsc.Server
public static class ServerConstants public static class ServerConstants
{ {
public const string CompanyInfoUrlFormat = " https://societeinfo.com/app/rest/api/v1/company/json?registration_number={0}&key={1}";
public const string ApplicationName = "Yavsc";
public const string CompanyInfoUrl = " https://societeinfo.com/app/rest/api/v1/company/json?registration_number={0}&key={1}";
private static readonly string[] GoogleScopes = { "openid", "profile", "email" };
public static readonly string[] GoogleCalendarScopes = public static readonly string[] GoogleCalendarScopes =
{ "openid", "profile", "email", "https://www.googleapis.com/auth/calendar" }; { "openid", "profile", "email", "https://www.googleapis.com/auth/calendar" };

View file

@ -12,7 +12,7 @@ namespace Yavsc.Helpers
string siren, CompanyInfoSettings api) string siren, CompanyInfoSettings api)
{ {
using (var request = new HttpRequestMessage(HttpMethod.Get, using (var request = new HttpRequestMessage(HttpMethod.Get,
string.Format(ServerConstants.CompanyInfoUrl,siren,api.ApiKey))) { string.Format(ServerConstants.CompanyInfoUrlFormat,siren,api.ApiKey))) {
using (var response = await web.SendAsync(request)) { using (var response = await web.SendAsync(request)) {
var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); var payload = JObject.Parse(await response.Content.ReadAsStringAsync());
return payload.ToObject<CompanyInfoMessage>(); return payload.ToObject<CompanyInfoMessage>();

View file

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
namespace Yavsc.Server.Helpers;
public static class ConfigurationHelpers
{
public static string GetAuthority(this WebApplicationBuilder builder)
{
return builder.Configuration.GetSection("Site")
.GetValue<string>("Authority");
}
public static string GetAudience(this WebApplicationBuilder builder)
{
return builder.Configuration.GetSection("Site")
.GetValue<string>("Audience");
}
}

View file

@ -1,43 +1,46 @@
using Microsoft.EntityFrameworkCore; using IdentityServer8.EntityFramework.Entities;
using IdentityServer8.EntityFramework.Interfaces;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.ChangeTracking;
using Yavsc.Abstract.Models.Messaging;
using Yavsc.Server.Models.EMailing;
using Yavsc.Server.Models.IT.SourceCode;
using Yavsc.Server.Models.IT;
using Yavsc.Abstract.Identity;
using Yavsc.Server.Models.Calendar;
namespace Yavsc.Models namespace Yavsc.Models
{ {
using Abstract.Identity;
using Abstract.Models.Messaging;
using Access;
using Attributes;
using Auth;
using Bank;
using Billing;
using Blog;
using Chat;
using Drawing;
using Forms;
using Haircut; using Haircut;
using Identity;
using IT.Evolution; using IT.Evolution;
using IT.Fixing; using IT.Fixing;
using Streaming;
using Relationship;
using Forms;
using Auth;
using Billing;
using Musical;
using Workflow;
using Identity;
using Market; using Market;
using Chat;
using Messaging; using Messaging;
using Access; using Microsoft.AspNetCore.Http;
using Musical;
using Musical.Profiles; using Musical.Profiles;
using Workflow.Profiles;
using Drawing;
using Attributes;
using Bank;
using Payment; using Payment;
using Blog; using Relationship;
using Server.Models.Calendar;
using Server.Models.EMailing;
using Server.Models.IT;
using Server.Models.IT.SourceCode;
using Streaming;
using Workflow;
using Workflow.Profiles;
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> public class ApplicationDbContext : IdentityDbContext<ApplicationUser>,
IConfigurationDbContext, IPersistedGrantDbContext
{ {
public ApplicationDbContext() public ApplicationDbContext()
{ {
} }
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{ {
@ -46,6 +49,8 @@ namespace Yavsc.Models
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)
{ {
base.OnModelCreating(builder); base.OnModelCreating(builder);
builder.UseIdentityByDefaultColumns();
// Customize the ASP.NET Identity model and override the defaults if needed. // Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more. // For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder); // Add your customizations after calling base.OnModelCreating(builder);
@ -72,16 +77,48 @@ namespace Yavsc.Models
builder.Entity<Cratie.Option>().HasKey(o => new { o.Code, o.CodeScrutin }); builder.Entity<Cratie.Option>().HasKey(o => new { o.Code, o.CodeScrutin });
builder.Entity<Notification>().Property(n => n.icon).HasDefaultValue("exclam"); builder.Entity<Notification>().Property(n => n.icon).HasDefaultValue("exclam");
builder.Entity<ChatRoomAccess>().HasKey(p => new { room = p.ChannelName, user = p.UserId }); builder.Entity<ChatRoomAccess>().HasKey(p => new { room = p.ChannelName, user = p.UserId });
builder.Entity<InstrumentRating>().HasAlternateKey(i => new { Instrument = i.InstrumentId, owner = i.OwnerId }); builder.Entity<InstrumentRating>().HasAlternateKey(i => new { Instrument = i.InstrumentId, owner = i.OwnerId })
;
builder.Entity<Activity>().Property(a => a.ParentCode).IsRequired(false);
builder.Entity<Client>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ClientSecret>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ClientScope>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ClientIdPRestriction>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ClientProperty>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ClientPostLogoutRedirectUri>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ClientRedirectUri>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ClientCorsOrigin>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ClientGrantType>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ClientClaim>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ApiResource>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<ApiScope>().Property("Id").UseIdentityAlwaysColumn();
builder.Entity<DeviceFlowCodes>().HasKey(e => new { e.UserCode, e.DeviceCode });
builder.Entity<PersistedGrant>().HasKey(e => e.Key);
// builder.Entity<IdentityUserLogin<String>>().HasKey(i=> new { i.LoginProvider, i.UserId, i.ProviderKey });
builder.Entity<ClientSecret>().HasOne<Client>().WithMany(e => e.ClientSecrets).HasForeignKey(e => e.ClientId);
builder.Entity<ClientScope>().HasOne<Client>().WithMany(e => e.AllowedScopes).HasForeignKey(e => e.ClientId);
builder.Entity<ClientIdPRestriction>().HasOne<Client>().WithMany(e => e.IdentityProviderRestrictions).HasForeignKey(e => e.ClientId);
builder.Entity<ClientProperty>().HasOne<Client>().WithMany(e => e.Properties).HasForeignKey(e => e.ClientId);
builder.Entity<ClientPostLogoutRedirectUri>().HasOne<Client>().WithMany(e => e.PostLogoutRedirectUris).HasForeignKey(e => e.ClientId);
builder.Entity<ClientRedirectUri>().HasOne<Client>().WithMany(e => e.RedirectUris).HasForeignKey(e => e.ClientId);
builder.Entity<ClientCorsOrigin>().HasOne<Client>().WithMany(e => e.AllowedCorsOrigins).HasForeignKey(e => e.ClientId);
builder.Entity<ClientGrantType>().HasOne<Client>().WithMany(e => e.AllowedGrantTypes).HasForeignKey(e => e.ClientId);
builder.Entity<ApiResourceSecret>().HasOne<ApiResource>().WithMany(e => e.Secrets).HasForeignKey(e => e.ApiResourceId);
builder.Entity<ApiResourceScope>().HasOne<ApiResource>().WithMany(e => e.Scopes).HasForeignKey(e => e.ApiResourceId);
builder.Entity<ApiResourceClaim>().HasOne<ApiResource>().WithMany(e => e.UserClaims).HasForeignKey(e => e.ApiResourceId);
builder.Entity<ApiResourceProperty>().HasOne<ApiResource>().WithMany(e => e.Properties).HasForeignKey(e => e.ApiResourceId);
builder.Entity<ApiScopeClaim>().HasOne<ApiScope>().WithMany(e => e.UserClaims).HasForeignKey(e => e.ScopeId);
builder.Entity<ApiScopeProperty>().HasOne<ApiScope>().WithMany(e => e.Properties).HasForeignKey(e => e.ScopeId);
foreach (var et in builder.Model.GetEntityTypes()) foreach (var et in builder.Model.GetEntityTypes())
{ {
if (et.ClrType.GetInterface("IBaseTrackedEntity") != null) if (et.ClrType.GetInterface("IBaseTrackedEntity") != null)
et.FindProperty("DateCreated").SetAfterSaveBehavior(Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Ignore); et.FindProperty("DateCreated").SetAfterSaveBehavior(Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Ignore);
} }
builder.Entity<Activity>().Property(a => a.ParentCode).IsRequired(false);
// builder.Entity<IdentityUserLogin<String>>().HasKey(i=> new { i.LoginProvider, i.UserId, i.ProviderKey });
} }
/// <summary> /// <summary>
@ -91,7 +128,7 @@ namespace Yavsc.Models
public DbSet<Activity> Activities { get; set; } public DbSet<Activity> Activities { get; set; }
public DbSet<UserActivity> UserActivities { get; set; } public DbSet<UserActivity> UserActivities { get; set; }
/// <summary> /// <summary>
/// Users posts /// Users posts
/// </summary> /// </summary>
@ -203,7 +240,12 @@ namespace Yavsc.Models
return await base.SaveChangesAsync(ctoken); return await base.SaveChangesAsync(ctoken);
} }
public DbSet<Circle> Circle { get; set; } public Task<int> SaveChangesAsync()
{
return base.SaveChangesAsync();
}
public DbSet<Circle> Circle { get; set; }
public DbSet<CircleAuthorizationToBlogPost> CircleAuthorizationToBlogPost { get; set; } public DbSet<CircleAuthorizationToBlogPost> CircleAuthorizationToBlogPost { get; set; }
@ -265,24 +307,39 @@ namespace Yavsc.Models
public DbSet<InstrumentRating> InstrumentRating { get; set; } public DbSet<InstrumentRating> InstrumentRating { get; set; }
public DbSet<Scope> Scopes { get; set; }
public DbSet<BlogSpotPublication> blogSpotPublications { get; set; } public DbSet<BlogSpotPublication> blogSpotPublications { get; set; }
/* public DbSet<Client> Clients { get; set; }
public DbSet<ClientIdPRestriction> ClientIdPRestrictions { get; set; }
public DbSet<ClientProperty> ClientProperties { get; set; }
public DbSet<ClientCorsOrigin> ClientCorsOrigins { get; set; } public DbSet<ClientCorsOrigin> ClientCorsOrigins { get; set; }
public DbSet<IdentityServer8.EntityFramework.Entities.Client> Clients { get; set; } public DbSet<ClientSecret> ClientSecrets { get; set; }
public DbSet<IdentityServer8.EntityFramework.Entities.IdentityResource> IdentityResources { get; set; } public DbSet<ClientScope> ClientScopes { get; set; }
public DbSet<IdentityServer8.EntityFramework.Entities.ApiResource> ApiResources { get; set; } public DbSet<ClientGrantType> ClientGrantTypes { get; set; }
public DbSet<IdentityServer8.EntityFramework.Entities.ApiScope> ApiScopes { get; set; } public DbSet<ClientClaim> ClientClaims { get; set; }
public DbSet<ClientRedirectUri> ClientRedirectUris { get; set; }
public DbSet<ClientPostLogoutRedirectUri> ClientPostLogoutRedirectUris { get; set; }
public DbSet<IdentityResource> IdentityResources { get; set; }
public DbSet<IdentityResourceClaim> IdentityResourceClaims { get; set; } public DbSet<IdentityResourceClaim> IdentityResourceClaims { get; set; }
public DbSet<IdentityResourceProperty> IdentityResourceProperties { get; set; } public DbSet<IdentityResourceProperty> IdentityResourceProperties { get; set; }
public DbSet<ApiResource> ApiResources { get; set; }
public DbSet<ApiResourceSecret> ApiResourceSecrets { get; set; } public DbSet<ApiResourceSecret> ApiResourceSecrets { get; set; }
public DbSet<ApiResourceScope> ApiResourceScopes { get; set; } public DbSet<ApiResourceScope> ApiResourceScopes { get; set; }
public DbSet<ApiResourceClaim> ApiResourceClaims { get; set; } public DbSet<ApiResourceClaim> ApiResourceClaims { get; set; }
public DbSet<ApiResourceProperty> ApiResourceProperties { get; set; } public DbSet<ApiResourceProperty> ApiResourceProperties { get; set; }
public DbSet<ApiScope> ApiScopes { get; set; }
public DbSet<ApiScopeClaim> ApiScopeClaims { get; set; } public DbSet<ApiScopeClaim> ApiScopeClaims { get; set; }
public DbSet<ApiScopeProperty> ApiScopeProperties { get; set; } */ public DbSet<ApiScopeProperty> ApiScopeProperties { get; set; }
public DbSet<PersistedGrant> PersistedGrants { get; set; }
public DbSet<DeviceFlowCodes> DeviceFlowCodes { get; set; }
} }
} }

View file

@ -24,7 +24,7 @@ namespace Yavsc.Server.Models.IT
/// As a side effect, there's no project without valid git reference in db. /// As a side effect, there's no project without valid git reference in db.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[YaRequired] [Required]
public string Name { get; set; } public string Name { get; set; }
public string Version { get; set; } public string Version { get; set; }
@ -33,7 +33,7 @@ namespace Yavsc.Server.Models.IT
public virtual List<ProjectBuildConfiguration> Configurations { get; set; } public virtual List<ProjectBuildConfiguration> Configurations { get; set; }
[YaRequired] [Required]
public long GitId { get; set; } public long GitId { get; set; }
[ForeignKey("GitId")] [ForeignKey("GitId")]

View file

@ -13,7 +13,7 @@ namespace Yavsc.Server.Models.IT
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[YaRequired] [Required]
public string Name { get; set; } public string Name { get; set; }
public long ProjectId { get; set; } public long ProjectId { get; set; }

View file

@ -10,7 +10,7 @@ namespace Yavsc.Server.Models.IT.SourceCode
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[YaRequired] [Required]
public string Path { get; set; } public string Path { get; set; }
[YaStringLength(2048)] [YaStringLength(2048)]
@ -30,4 +30,4 @@ namespace Yavsc.Server.Models.IT.SourceCode
return $"[Git ref {Path} {Branch} {Url}]"; return $"[Git ref {Path} {Branch} {Url}]";
} }
} }
} }

View file

@ -36,7 +36,7 @@ namespace Yavsc.Models.Messaging
/// Gets or sets the circles. /// Gets or sets the circles.
/// </summary> /// </summary>
/// <value>The circles.</value> /// <value>The circles.</value>
[YaRequired, Display(Name="Circles")] [Required, Display(Name="Circles")]
public virtual List<Circle> Circles{ get; set; } public virtual List<Circle> Circles{ get; set; }
public override string CreateBody() public override string CreateBody()

View file

@ -7,13 +7,13 @@ namespace Yavsc.Models.Messaging
{ {
public class DismissClicked public class DismissClicked
{ {
[YaRequired] [Required]
public string UserId { get; set; } public string UserId { get; set; }
[ForeignKey("UserId")] [ForeignKey("UserId")]
public virtual ApplicationUser User { get; set; } public virtual ApplicationUser User { get; set; }
[YaRequired] [Required]
public long NotificationId { get; set; } public long NotificationId { get; set; }
[ForeignKey("NotificationId")] [ForeignKey("NotificationId")]

View file

@ -41,7 +41,7 @@ namespace Yavsc.Models.Streaming
[Display(Name="SequenceNumberLabel", ResourceType=typeof(LiveFlow))] [Display(Name="SequenceNumberLabel", ResourceType=typeof(LiveFlow))]
public int SequenceNumber { get; set; } public int SequenceNumber { get; set; }
[YaRequired] [Required]
[Display(Name="OwnerIdLabel", ResourceType=typeof(LiveFlow))] [Display(Name="OwnerIdLabel", ResourceType=typeof(LiveFlow))]
public string OwnerId {get; set; } public string OwnerId {get; set; }

View file

@ -10,7 +10,7 @@ namespace Yavsc.Models.Musical
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id {get; set; } public long Id {get; set; }
[MaxLength(255), YaRequired] [MaxLength(255), Required]
public string Name { get ; set; } public string Name { get ; set; }
} }
} }

View file

@ -10,7 +10,7 @@ namespace Yavsc.Models.Musical
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id {get; set; } public long Id {get; set; }
[YaRequired] [Required]
public long InstrumentId { get; set; } public long InstrumentId { get; set; }
[ForeignKey("InstrumentId")] [ForeignKey("InstrumentId")]
@ -25,4 +25,4 @@ namespace Yavsc.Models.Musical
public virtual PerformerProfile Profile { get; set; } public virtual PerformerProfile Profile { get; set; }
} }
} }

View file

@ -17,7 +17,7 @@ namespace Yavsc.Models.Musical
public int Rate { get; set; } public int Rate { get; set; }
[YaRequired] [Required]
public long TendencyId { get; set; } public long TendencyId { get; set; }
[ForeignKey("TendencyId")] [ForeignKey("TendencyId")]

View file

@ -9,7 +9,7 @@ namespace Yavsc.Models.Musical {
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id {get; set; } public long Id {get; set; }
[MaxLength(255),YaRequired] [MaxLength(255),Required]
public string Name { get ; set; } public string Name { get ; set; }
} }

View file

@ -10,10 +10,10 @@ namespace Yavsc.Models.Payment {
public class PayPalPayment : ITrackedEntity public class PayPalPayment : ITrackedEntity
{ {
[YaRequired,Key] [Required,Key]
public string CreationToken { get; set; } public string CreationToken { get; set; }
[YaRequired] [Required]
public string ExecutorId { get; set; } public string ExecutorId { get; set; }
[ForeignKey("ExecutorId")] [ForeignKey("ExecutorId")]

View file

@ -14,10 +14,10 @@ namespace Yavsc.Models.Relationship
public bool Public { get; set; } public bool Public { get; set; }
[YaRequired] [Required]
public string Name { get; set; } public string Name { get; set; }
[YaRequired] [Required]
public string OwnerId { get; set; } public string OwnerId { get; set; }
[ForeignKey("OwnerId"),JsonIgnore,NotMapped] [ForeignKey("OwnerId"),JsonIgnore,NotMapped]

View file

@ -9,13 +9,13 @@ namespace Yavsc.Models.Relationship
public partial class CircleMember public partial class CircleMember
{ {
[YaRequired] [Required]
public long CircleId { get; set; } public long CircleId { get; set; }
[ForeignKey("CircleId")] [ForeignKey("CircleId")]
public virtual Circle Circle { get; set; } public virtual Circle Circle { get; set; }
[YaRequired] [Required]
public string MemberId { get; set; } public string MemberId { get; set; }
[ForeignKey("MemberId")] [ForeignKey("MemberId")]

View file

@ -9,7 +9,7 @@ namespace Yavsc.Models.Relationship
{ {
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[YaRequired()] [Required()]
public string Name { get; set; } public string Name { get; set; }
} }
} }

View file

@ -14,14 +14,14 @@ namespace Yavsc.Models.Workflow
public class Activity : ITrackedEntity, IActivity public class Activity : ITrackedEntity, IActivity
{ {
[YaStringLength(512), YaRequired, Key] [YaStringLength(512), Required, Key]
[Display(Name = "Code")] [Display(Name = "Code")]
public string Code { get; set; } public string Code { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[YaStringLength(512), YaRequired()] [YaStringLength(512), Required()]
[Display(Name = "Nom")] [Display(Name = "Nom")]
public string Name { get; set; } public string Name { get; set; }

View file

@ -16,7 +16,7 @@ namespace Yavsc.Models.Workflow
public string Title { get; set; } public string Title { get; set; }
[YaRequired] [Required]
public string ActivityCode { get; set; } public string ActivityCode { get; set; }
[ForeignKey("ActivityCode"),JsonIgnore] [ForeignKey("ActivityCode"),JsonIgnore]

View file

@ -21,13 +21,13 @@ namespace Yavsc.Models.Workflow
[Display(Name="Activity"), JsonIgnore] [Display(Name="Activity"), JsonIgnore]
public virtual List<UserActivity> Activity { get; set; } public virtual List<UserActivity> Activity { get; set; }
[YaRequired,YaStringLength(14),Display(Name="SIREN"), [Required,YaStringLength(14),Display(Name="SIREN"),
RegularExpression(@"^[0-9]{9,14}$", ErrorMessage = "Only numbers are allowed here")] RegularExpression(@"^[0-9]{9,14}$", ErrorMessage = "Only numbers are allowed here")]
public string SIREN { get; set; } public string SIREN { get; set; }
public long OrganizationAddressId { get; set; } public long OrganizationAddressId { get; set; }
[YaRequired,Display(Name="Organization address"),ForeignKey("OrganizationAddressId")] [Required,Display(Name="Organization address"),ForeignKey("OrganizationAddressId")]
public virtual Location OrganizationAddress { get; set; } public virtual Location OrganizationAddress { get; set; }
[Display(Name="Accept notifications on client query")] [Display(Name="Accept notifications on client query")]

View file

@ -18,21 +18,21 @@ namespace Yavsc.Models.Workflow
/// Event date /// Event date
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[YaRequired(),Display(Name="EventDate")] [Required(),Display(Name="EventDate")]
public DateTime EventDate { get; set; } public DateTime EventDate { get; set; }
/// <summary> /// <summary>
/// Location identifier /// Location identifier
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[YaRequired] [Required]
public long LocationId { get; set; } public long LocationId { get; set; }
/// <summary> /// <summary>
/// A Location for this event /// A Location for this event
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[YaRequired(ErrorMessage="SpecifyPlace"),Display(Name="Location"),ForeignKey("LocationId")] [Required(ErrorMessage="SpecifyPlace"),Display(Name="Location"),ForeignKey("LocationId")]
public Location Location { get; set; } public Location Location { get; set; }
} }

View file

@ -7,13 +7,13 @@ namespace Yavsc.Models.Workflow
{ {
public class UserActivity public class UserActivity
{ {
[YaRequired] [Required]
public string UserId { get; set; } public string UserId { get; set; }
[ForeignKey("UserId")] [ForeignKey("UserId")]
public virtual PerformerProfile User { get; set; } public virtual PerformerProfile User { get; set; }
[YaRequired] [Required]
public string DoesCode { get; set; } public string DoesCode { get; set; }
[ForeignKey("DoesCode")] [ForeignKey("DoesCode")]
@ -25,4 +25,4 @@ namespace Yavsc.Models.Workflow
[NotMapped,JsonIgnore] [NotMapped,JsonIgnore]
public object Settings { get; internal set; } public object Settings { get; internal set; }
} }
} }

View file

@ -4,18 +4,18 @@ using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Account {  namespace Yavsc.Models.Account { 
public class ChangePasswordBindingModel { public class ChangePasswordBindingModel {
[YaRequired] [Required]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string OldPassword { get; set; } public string OldPassword { get; set; }
[YaRequired] [Required]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string NewPassword { get; set; } public string NewPassword { get; set; }
} }
public class SetPasswordBindingModel { public class SetPasswordBindingModel {
[YaRequired] [Required]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string NewPassword { get; set; } public string NewPassword { get; set; }
} }
} }

View file

@ -7,12 +7,12 @@ namespace Yavsc.ViewModels.Account
{ {
public class ExternalLoginConfirmationViewModel public class ExternalLoginConfirmationViewModel
{ {
[YaRequired] [Required]
[YaStringLength(2,Constants.MaxUserNameLength)] [YaStringLength(2,Constants.MaxUserNameLength)]
[YaRegularExpression(Constants.UserNameRegExp)] [YaRegularExpression(Constants.UserNameRegExp)]
public string Name { get; set; } public string Name { get; set; }
[YaRequired] [Required]
[EmailAddress] [EmailAddress]
public string Email { get; set; } public string Email { get; set; }

View file

@ -5,10 +5,10 @@ namespace Yavsc.ViewModels.Account
{ {
public class VerifyCodeViewModel public class VerifyCodeViewModel
{ {
[YaRequired] [Required]
public string Provider { get; set; } public string Provider { get; set; }
[YaRequired] [Required]
public string Code { get; set; } public string Code { get; set; }
public string ReturnUrl { get; set; } public string ReturnUrl { get; set; }

View file

@ -5,7 +5,7 @@ namespace Yavsc.ViewModels.Manage
{ {
public class AddPhoneNumberViewModel public class AddPhoneNumberViewModel
{ {
[YaRequired] [Required]
[Phone] [Phone]
[Display(Name = "Phone number")] [Display(Name = "Phone number")]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }

View file

@ -5,12 +5,12 @@ namespace Yavsc.ViewModels.Manage
{ {
public class ChangePasswordViewModel public class ChangePasswordViewModel
{ {
[YaRequired] [Required]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[Display(Name = "Current password")] [Display(Name = "Current password")]
public string OldPassword { get; set; } public string OldPassword { get; set; }
[YaRequired] [Required]
[YaStringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] [YaStringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[Display(Name = "New password")] [Display(Name = "New password")]

View file

@ -5,32 +5,32 @@ namespace Yavsc.ViewModels.Manage
{ {
public class DoDirectCreditViewModel { public class DoDirectCreditViewModel {
[YaRequired] [Required]
public string PaymentType  { get; set;} public string PaymentType  { get; set;}
[YaRequired] [Required]
public string PayerName  { get; set;} public string PayerName  { get; set;}
[YaRequired] [Required]
public string FirstName  { get; set;} public string FirstName  { get; set;}
[YaRequired] [Required]
public string LastName  { get; set;} public string LastName  { get; set;}
[YaRequired] [Required]
public string CreditCardNumber  { get; set;} public string CreditCardNumber  { get; set;}
public string CreditCardType  { get; set;} public string CreditCardType  { get; set;}
public string Cvv2Number  { get; set;} public string Cvv2Number  { get; set;}
public string CardExpiryDate  { get; set;} public string CardExpiryDate  { get; set;}
public string IpnNotificationUrl { get; set; } public string IpnNotificationUrl { get; set; }
[YaRequired] [Required]
public string Street1 { get; set; } public string Street1 { get; set; }
public string Street2 { get; set; } public string Street2 { get; set; }
public string City { get; set; } public string City { get; set; }
public string State { get; set; } public string State { get; set; }
public string Country { get; set; } public string Country { get; set; }
[YaRequired] [Required]
public string PostalCode { get; set; } public string PostalCode { get; set; }
public string Phone { get; set; } public string Phone { get; set; }
[YaRequired] [Required]
public string CurrencyCode { get; set; } public string CurrencyCode { get; set; }
[YaRequired] [Required]
public string Amount { get; set; } public string Amount { get; set; }
} }
} }

View file

@ -5,13 +5,13 @@ namespace Yavsc.ViewModels.Manage
{ {
public class SetAddressViewModel public class SetAddressViewModel
{ {
[YaRequired] [Required]
public string Street1 { get; set; } public string Street1 { get; set; }
public string Street2 { get; set; } public string Street2 { get; set; }
public string City { get; set; } public string City { get; set; }
public string State { get; set; } public string State { get; set; }
public string Country { get; set; } public string Country { get; set; }
[YaRequired] [Required]
public string PostalCode { get; set; } public string PostalCode { get; set; }
} }
} }

View file

@ -5,7 +5,7 @@ namespace Yavsc.ViewModels.Manage
{ {
public class SetPasswordViewModel public class SetPasswordViewModel
{ {
[YaRequired] [Required]
[YaStringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] [YaStringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[Display(Name = "New password")] [Display(Name = "New password")]

View file

@ -5,10 +5,10 @@ namespace Yavsc.ViewModels.Manage
{ {
public class VerifyPhoneNumberViewModel public class VerifyPhoneNumberViewModel
{ {
[YaRequired] [Required]
public string Code { get; set; } public string Code { get; set; }
[YaRequired] [Required]
[Phone] [Phone]
[Display(Name = "Phone number")] [Display(Name = "Phone number")]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }

View file

@ -5,6 +5,7 @@ using Xunit.Abstractions;
using Yavsc.Server.Models.IT.SourceCode; using Yavsc.Server.Models.IT.SourceCode;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using isnd.tests; using isnd.tests;
using Yavsc.Server.Models.IT;
namespace yavscTests namespace yavscTests
{ {
@ -21,13 +22,21 @@ namespace yavscTests
this._output = output; this._output = output;
} }
[Fact] // FIXME write a scenario from an empty database [Fact]
public void GitClone() public void GitClone()
{ {
using var scope = _serverFixture.Services.CreateScope(); using var scope = _serverFixture.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>(); var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
Assert.NotNull (dbContext.Project); Assert.NotNull(dbContext.Project);
var firstProject = dbContext.Project.Include(p=>p.Repository).FirstOrDefault(); Project yavsc = new Project
{
Name = "Yavsc"
};
dbContext.Project.Add(yavsc);
dbContext.SaveChanges();
var firstProject = dbContext.Project.Include(p => p.Repository).FirstOrDefault(
p => p.Name == "Yavsc"
);
Assert.NotNull (firstProject); Assert.NotNull (firstProject);
var di = new DirectoryInfo(_serverFixture.SiteSettings.GitRepository); var di = new DirectoryInfo(_serverFixture.SiteSettings.GitRepository);
if (!di.Exists) di.Create(); if (!di.Exists) di.Create();

View file

@ -1,6 +1,9 @@
using isnd.tests; using isnd.tests;
using Xunit.Abstractions; using Xunit.Abstractions;
using IdentityModel.Client; using IdentityModel.Client;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
namespace yavscTests namespace yavscTests
{ {
@ -14,43 +17,39 @@ namespace yavscTests
} }
[Theory]
[MemberData(nameof(GetLoginIntentData))]
public async Task TestUserMayLogin
(
string userName,
string password
)
{
}
[Fact] [Fact]
public async Task ObtainServiceToken() public async Task ObtainServiceToken()
{ {
var serverUrl = _serverFixture.Addresses.FirstOrDefault( var serverUrl = _serverFixture.Addresses.FirstOrDefault(
u => u.StartsWith("https:") u => u.StartsWith("https:")
); );
String authority = _serverFixture.SiteSettings.Authority; String authority = _serverFixture.SiteSettings.Authority;
var client = new HttpClient(); HttpClient client = NewHttpClient();
var disco = await client.GetDiscoveryDocumentAsync(authority); var disco = await client.GetDiscoveryDocumentAsync(authority);
if (disco.IsError) throw new Exception(disco.Error); if (disco.IsError) throw new Exception(disco.Error);
var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
{ {
Address = disco.TokenEndpoint, Address = disco.TokenEndpoint,
ClientId = _serverFixture.TestClientId,
ClientSecret = _serverFixture.TestClientSecret,
Scope = "test",
GrantType = "client_credentials"
});
/*"mvc";
options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0";*/
if (response.IsError) throw new Exception(response.Error);
ClientId = "m2m.client", // _serverFixture.TestClientId, }
ClientSecret = "511536EF-F270-4058-80CA-1C89C192F69A" //_serverFixture.TestClientSecret,
});
/*"mvc";
options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0";*/
if (response.IsError) throw new Exception(response.Error);
} private static HttpClient NewHttpClient()
{
return new HttpClient(new BypassSslValidationHandler());
}
[Fact] [Fact]
public async Task ObtainResourceOwnerPasswordToken() public async Task ObtainResourceOwnerPasswordToken()
{ {
var serverUrl = _serverFixture.Addresses.FirstOrDefault( var serverUrl = _serverFixture.Addresses.FirstOrDefault(
@ -58,7 +57,7 @@ namespace yavscTests
); );
String authority = _serverFixture.SiteSettings.Authority; String authority = _serverFixture.SiteSettings.Authority;
var client = new HttpClient(); var client = NewHttpClient();
var disco = await client.GetDiscoveryDocumentAsync(authority); var disco = await client.GetDiscoveryDocumentAsync(authority);
if (disco.IsError) throw new Exception(disco.Error); if (disco.IsError) throw new Exception(disco.Error);
@ -66,13 +65,13 @@ namespace yavscTests
{ {
Address = disco.TokenEndpoint, Address = disco.TokenEndpoint,
ClientId = "m2m.client", ClientId = _serverFixture.TestClientId,
ClientSecret = "511536EF-F270-4058-80CA-1C89C192F69A", ClientSecret = _serverFixture.TestClientSecret,
UserName = _serverFixture.TestingUserName, UserName = _serverFixture.TestingUserName,
Password = _serverFixture.TestingUserPassword, Password = _serverFixture.TestingUserPassword,
Scope = "scope1", Scope = "test",
Parameters = Parameters =
{ {
@ -90,4 +89,23 @@ namespace yavscTests
} }
} }
internal class BypassSslValidationHandler : HttpClientHandler
{
public BypassSslValidationHandler()
{
// Override validation for this handler only
ServerCertificateCustomValidationCallback = ValidateCertificate;
}
private bool ValidateCertificate(
HttpRequestMessage request,
X509Certificate2 certificate,
X509Chain chain,
SslPolicyErrors errors)
{
// Accept all certificates (bypass validation)
return true;
}
}
} }

View file

@ -16,7 +16,7 @@ namespace yavscTests
this.output = output; this.output = output;
} }
[Fact] [Fact]
public void UniquePathesAfterFileNameCleaning() public void UniquePathsAfterFileNameCleaning()
{ {
var name1 = "content:///scanned_files/2020-06-02/00.11.02.JPG"; var name1 = "content:///scanned_files/2020-06-02/00.11.02.JPG";
var name2 = "content:///scanned_files/2020-06-02/00.11.03.JPG"; var name2 = "content:///scanned_files/2020-06-02/00.11.03.JPG";

View file

@ -13,6 +13,9 @@ using Microsoft.EntityFrameworkCore;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes; using Serilog.Sinks.SystemConsole.Themes;
using IdentityServer8.EntityFramework.Entities;
using IdentityServer8.Models;
using Client = IdentityServer8.EntityFramework.Entities.Client;
namespace isnd.tests namespace isnd.tests
{ {
@ -33,12 +36,12 @@ namespace isnd.tests
public IServiceProvider Services { get; private set; } public IServiceProvider Services { get; private set; }
public string TestingUserName { get; private set; } public string TestingUserName { get; private set; }
public string TestingUserPassword { get; private set; } public string TestingUserPassword { get; private set; }
public string ProtectedTestingApiKey { get; internal set; } public string ProtectedTestingApiKey { get; internal set; }
public ApplicationUser TestingUser { get; private set; } public ApplicationUser TestingUser { get; private set; }
public bool DbCreated { get; internal set; } public bool DbCreated { get; internal set; }
public SiteSettings SiteSettings { get => siteSettings; set => siteSettings = value; } public SiteSettings SiteSettings { get => siteSettings; set => siteSettings = value; }
public string TestClientSecret { get; private set; } = "TestClientSecret"; public string TestClientSecret { get; set; }
public WebServerFixture() public WebServerFixture()
{ {
@ -47,7 +50,7 @@ namespace isnd.tests
public void Dispose() public void Dispose()
{ {
if (app!=null) if (app != null)
app.StopAsync().Wait(); app.StopAsync().Wait();
} }
void ConfigureLogger() => Log.Logger = new LoggerConfiguration() void ConfigureLogger() => Log.Logger = new LoggerConfiguration()
@ -79,17 +82,20 @@ namespace isnd.tests
this.app = builder.ConfigureWebAppServices(); this.app = builder.ConfigureWebAppServices();
Services = app.Services; Services = app.Services;
SiteSettings = app.Services.GetRequiredService<IOptions<SiteSettings>>().Value;
using (var migrationScope = app.Services.CreateScope()) using (var migrationScope = app.Services.CreateScope())
{ {
var db = migrationScope.ServiceProvider.GetRequiredService<ApplicationDbContext>(); var db = migrationScope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
db.Database.EnsureDeleted(); db.Database.EnsureDeleted();
db.Database.EnsureCreated(); db.Database.EnsureCreated();
db.Database.Migrate();
TestingUserName = "Tester"; TestingUserName = "Tester";
TestingUserPassword = "test"; TestingUserPassword = "tesT456+*";
TestClientId = "testClientId"; TestClientId = "testClientId";
TestingUser = await db.Users.FirstOrDefaultAsync(u => u.UserName == TestingUserName); TestClientSecret = Guid.CreateVersion7().ToString();
EnsureUser(TestingUserName, TestingUserPassword); EnsureUser(TestingUserName, TestingUserPassword);
AddAuthorizedClient(TestClientId, TestClientSecret);
TestingUser = await db.Users.FirstOrDefaultAsync(u => u.UserName == TestingUserName);
} }
await app.ConfigurePipeline(); await app.ConfigurePipeline();
app.UseSession(); app.UseSession();
@ -108,8 +114,73 @@ namespace isnd.tests
{ {
Addresses.Add(address); Addresses.Add(address);
} }
SiteSettings = app.Services.GetRequiredService<IOptions<SiteSettings>>().Value;
}
private void AddAuthorizedClient(string testClientId, string testClientSecret)
{
using (IServiceScope scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
Client testingClient = new Client
{
ClientId = testClientId,
AccessTokenLifetime = 3600000,
AccessTokenType = 1,
BackChannelLogoutUri = SiteSettings.Audience,
ClientName = "Testing client",
Enabled = true
};
db.Clients.Add(testingClient);
db.SaveChanges();
ClientSecret secret = new ClientSecret
{
Value = testClientSecret.Sha256(),
ClientId = testingClient.Id
};
db.ClientSecrets.Add(secret);
var testOrigin = new ClientCorsOrigin
{
ClientId = testingClient.Id,
Origin = SiteSettings.Audience
};
db.ClientCorsOrigins.Add(testOrigin);
db.ClientGrantTypes.Add(new ClientGrantType
{
ClientId = testingClient.Id,
GrantType = "client_credentials"
});
db.ClientGrantTypes.Add(new ClientGrantType
{
ClientId = testingClient.Id,
GrantType = "password"
});
db.ClientGrantTypes.Add(new ClientGrantType
{
ClientId = testingClient.Id,
GrantType = "code"
});
db.ClientScopes.Add(new ClientScope
{
ClientId = testingClient.Id,
Scope = "test"
});
db.ApiScopes.Add(new IdentityServer8.EntityFramework.Entities.ApiScope
{
Name = "test",
Enabled = true
});
db.ClientRedirectUris.Add(new ClientRedirectUri
{
ClientId = testingClient.Id,
RedirectUri = SiteSettings.Audience
});
db.SaveChanges();
}
} }
public void EnsureUser(string testingUserName, string password) public void EnsureUser(string testingUserName, string password)
@ -118,7 +189,7 @@ namespace isnd.tests
{ {
using IServiceScope scope = app.Services.CreateScope(); using IServiceScope scope = app.Services.CreateScope();
var userManager = var userManager =
scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>(); scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
TestingUser = new ApplicationUser TestingUser = new ApplicationUser
@ -128,7 +199,7 @@ namespace isnd.tests
EmailConfirmed = true EmailConfirmed = true
}; };
var result = userManager.CreateAsync(TestingUser,password).Result; var result = userManager.CreateAsync(TestingUser, password).Result;
Assert.True(result.Succeeded); Assert.True(result.Succeeded);