mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-25 15:08:47 -07:00
f0e4679887
Players sign in to the website, and admins to the admin panel, with an OpenID Connect provider (DorkNet:SignIn:*). The first sign-in links the provider identity (issuer + subject) to a DorkNet account with that account's password; after that the provider sign-in is enough. - Cookie sessions per host, keys persisted in the database so redeploys keep people signed in; unlink, deletion or a ban ends the session. - Link attempts limited to 5 failures per 15 minutes per identity and per username. - Admin panel: "Sign in with ..." exchanges the session for the usual admin tokens via GET /api/admin/v1/sso (IsAdmin still required). - Downloads: optional DorkNet:Downloads:RequireSignIn serves the manifest and files only to signed-in players; the Downloads and Quest pages offer sign-in instead. - Website: sign-in in the header, /link and /account pages. The game client's login is unchanged.
69 lines
2.5 KiB
C#
69 lines
2.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace DorkNet.Server.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class ExternalSignIn : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "DataProtectionKeys",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
FriendlyName = table.Column<string>(type: "TEXT", nullable: true),
|
|
Xml = table.Column<string>(type: "TEXT", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DataProtectionKeys", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ExternalLogins",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
PlayerId = table.Column<long>(type: "INTEGER", nullable: false),
|
|
Issuer = table.Column<string>(type: "TEXT", nullable: false),
|
|
Subject = table.Column<string>(type: "TEXT", nullable: false),
|
|
Email = table.Column<string>(type: "TEXT", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
LastUsedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ExternalLogins", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ExternalLogins_Issuer_Subject",
|
|
table: "ExternalLogins",
|
|
columns: new[] { "Issuer", "Subject" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ExternalLogins_PlayerId",
|
|
table: "ExternalLogins",
|
|
column: "PlayerId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "DataProtectionKeys");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ExternalLogins");
|
|
}
|
|
}
|
|
}
|