diff --git a/.env.example b/.env.example
index 8c22ddf..977de14 100644
--- a/.env.example
+++ b/.env.example
@@ -56,6 +56,13 @@ SSO_AUTO_PROVISION=false
# true: hide the password form; only administrators can still sign in with a password, at /Login?local=1.
SSO_DISABLE_LOCAL_LOGIN=false
+# ---- Two-factor sign-in ----
+# Anyone with a password can turn on authenticator-app codes under My profile -> Security.
+# true: administrators who sign in with a password must set it up before using Taskist.
+TWO_FACTOR_REQUIRE_FOR_ADMINS=false
+# "Don't ask again on this device" lasts this many days; 0 turns the option off.
+TWO_FACTOR_REMEMBER_DEVICE_DAYS=30
+
# ---- Seeding ----
# Reference data (roles, permissions, menus, translations, admin account). Leave true for a usable install.
SEED_DATA=true
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1073bfe..abb6bef 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ Each release lists **Upgrade notes** when an install needs action beyond the ste
- **Appearance**: light, dark or system theme and an accent colour per user.
- **Per-user export column layouts** on top of the administrator's default.
- **Tags** for the backlog, with inline create and merge.
+- **Two-factor sign-in** with any authenticator app (TOTP), turned on per user under My profile → Security: QR-code setup, ten one-time recovery codes, an optional "don't ask again on this device" (`Authentication:TwoFactor:RememberDeviceDays`, default 30), and administrator reset on the user's page. `Authentication:TwoFactor:RequireForAdministrators` (off by default) makes it mandatory for administrators who sign in with a password. Single sign-on users are not asked, since their identity provider handles it. See [docs/two-factor.md](docs/two-factor.md). ([#12](https://github.com/Taskist/taskist/issues/12))
- **Single sign-on with OpenID Connect** (`Authentication:Oidc`, off by default): Keycloak, Authentik, Entra ID, Google, Okta and other providers. Existing users are linked by verified e-mail; optional account creation on first sign-in (*Registered* role only), optional group → role mapping (adds roles only), and an SSO-only mode that keeps password sign-in for administrators at `/Login?local=1`. Linked sign-ins are listed under My profile → Security and on the user's admin page. See [docs/sso.md](docs/sso.md). ([#11](https://github.com/Taskist/taskist/issues/11))
- **Optional Sentry error tracking** (`Sentry:Enabled` + `Sentry:Dsn`, off by default): unhandled exceptions and logged errors, with request bodies, cookies, query strings, auth headers and personal data filtered out.
- `Security:RequireHttpsCookies` and `Security:ForwardedHeaders:*` settings for plain-HTTP and reverse-proxy deployments.
diff --git a/README.md b/README.md
index d0a3ee1..044a551 100644
--- a/README.md
+++ b/README.md
@@ -80,7 +80,7 @@ Taskist is a self-hosted **task, change request and bug tracker** built with ASP
**⚙️ Administration**
-- Users, roles and fine-grained permissions; optional single sign-on with any OpenID Connect provider
+- Users, roles and fine-grained permissions; two-factor sign-in with an authenticator app; optional single sign-on with any OpenID Connect provider
- Masters for clients, projects, modules, statuses, task types, severities, tags and reporters — shared or per project
- Database-driven translations, e-mail templates and settings
- Light, dark and system themes with an accent colour per user; activity log; background-jobs dashboard
@@ -177,10 +177,12 @@ Taskist reads `appsettings.json`, `appsettings.{Environment}.json`, user-secrets
| `Authentication:Oidc:AutoProvision` | `false` | Create a Taskist account (*Registered* role only) on first sign-in. Off = only existing users can sign in |
| `Authentication:Oidc:RoleClaim` / `RoleMappings` | — | Optional: add Taskist roles from provider groups, e.g. `{"taskist-leads": "TeamLead"}`. Only adds roles, never removes them |
| `Authentication:Oidc:DisableLocalLogin` | `false` | Hide the password form. Administrators can still sign in with a password at `/Login?local=1` |
+| `Authentication:TwoFactor:RequireForAdministrators` | `false` | Administrators who sign in with a password must turn on two-factor sign-in before using Taskist; see [docs/two-factor.md](docs/two-factor.md) |
+| `Authentication:TwoFactor:RememberDeviceDays` | `30` | How long "Don't ask again on this device" lasts after a two-factor sign-in; `0` turns the option off |
Everything else — password policy, lockout, session length, e-mail, Git, notifications, report layouts — lives in the app under **Configuration → Settings**.
-**Behind a reverse proxy** (nginx, Traefik, IIS, a cloud load balancer): keep `RequireHttpsCookies=true`, set `ForwardedHeaders:Enabled=true` and list the proxy in `KnownProxies` or `KnownNetworks`, and set `App:BaseUrl` to the public `https://` address. In Docker these are `TASKIST_REQUIRE_HTTPS_COOKIES`, `TASKIST_FORWARDED_HEADERS`, `TASKIST_PROXY_NETWORK` and `APP_BASE_URL` in `.env`; Sentry uses `SENTRY_ENABLED`, `SENTRY_DSN`, `SENTRY_ENVIRONMENT` and `SENTRY_TRACES_SAMPLE_RATE`; single sign-on uses the `SSO_*` variables.
+**Behind a reverse proxy** (nginx, Traefik, IIS, a cloud load balancer): keep `RequireHttpsCookies=true`, set `ForwardedHeaders:Enabled=true` and list the proxy in `KnownProxies` or `KnownNetworks`, and set `App:BaseUrl` to the public `https://` address. In Docker these are `TASKIST_REQUIRE_HTTPS_COOKIES`, `TASKIST_FORWARDED_HEADERS`, `TASKIST_PROXY_NETWORK` and `APP_BASE_URL` in `.env`; Sentry uses `SENTRY_ENABLED`, `SENTRY_DSN`, `SENTRY_ENVIRONMENT` and `SENTRY_TRACES_SAMPLE_RATE`; single sign-on uses the `SSO_*` variables and two-factor sign-in the `TWO_FACTOR_*` ones.
diff --git a/SECURITY.md b/SECURITY.md
index edb7d73..a5b56b0 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -82,6 +82,19 @@ Secrets are write-only in the UI and are never written to the activity log.
- The forgot-password endpoint is rate limited per IP address.
- Change the seeded `admin@taskist.org` password immediately after installation.
+### Two-factor sign-in
+
+Users with a password can turn on authenticator-app codes (TOTP, RFC 6238: 6 digits, 30-second steps) under **My profile → Security**. Setup in [docs/two-factor.md](docs/two-factor.md).
+
+- **Secrets** are 160-bit random keys, stored encrypted with Data Protection (like other stored secrets) and never written to the audit log. The QR code is generated on the server; nothing is sent to an outside service.
+- **Codes** are accepted for the current 30-second step ±1 and **only once**: a code, or any older one, can't be replayed after a successful sign-in.
+- **Recovery codes:** ten single-use codes, about 50 bits each, stored as SHA-256 hashes and shown only once. Turning two-factor off or creating new codes requires a current code.
+- **Wrong codes** count towards the same failed-attempt lock-out as wrong passwords, and the counter is only reset after the **second** step succeeds. Each sign-in attempt also allows at most five codes before the user has to start again with their password. The half-finished sign-in lives in a separate, encrypted five-minute cookie, so a correct password alone never creates a session.
+- **"Don't ask again on this device"** (`Authentication:TwoFactor:RememberDeviceDays`, default 30, `0` turns it off) sets an encrypted, HttpOnly, always-*Secure* cookie (so it only works over HTTPS) tied to the user and to when two-factor was last turned on, so it stops working as soon as two-factor is reset or turned off and on again.
+- **Administrators can be required** to use it (`Authentication:TwoFactor:RequireForAdministrators`): until they set it up, administrators who signed in with only a password are limited to their profile page.
+- **Resetting:** an administrator can reset a user's two-factor sign-in from the user's page (recorded in the activity log for both accounts). Keep this in mind for your support process: anyone who can convince an administrator to reset it is back to password-only.
+- Single sign-on users are not asked for a Taskist code; enforce MFA at your identity provider.
+
### Single sign-on (optional)
Taskist can sign users in through an OpenID Connect provider (`Authentication:Oidc`, off by default; setup in [docs/sso.md](docs/sso.md)).
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index cdb0e5c..c26003b 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -70,6 +70,7 @@ Restored at build time; not stored in this repository.
| [Microsoft.EntityFrameworkCore.DynamicLinq](https://dynamic-linq.net) | Apache-2.0 |
| [MiniProfiler](https://miniprofiler.com) | MIT |
| [Newtonsoft.Json](https://www.newtonsoft.com/json) | MIT |
+| [QRCoder](https://github.com/Shane32/QRCoder) (two-factor setup QR code) | MIT |
| [RestSharp](https://restsharp.dev) | Apache-2.0 |
| [ReverseMarkdown](https://github.com/mysticmind/reversemarkdown-net) | MIT |
| [Riok.Mapperly](https://mapperly.riok.app) | Apache-2.0 |
diff --git a/docker-compose.yml b/docker-compose.yml
index c7a16ab..39f4b5d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -65,6 +65,9 @@ services:
Authentication__Oidc__ClientSecret: ${SSO_CLIENT_SECRET:-}
Authentication__Oidc__AutoProvision: ${SSO_AUTO_PROVISION:-false}
Authentication__Oidc__DisableLocalLogin: ${SSO_DISABLE_LOCAL_LOGIN:-false}
+ # two-factor sign-in; see TWO_FACTOR_* in .env.example and docs/two-factor.md
+ Authentication__TwoFactor__RequireForAdministrators: ${TWO_FACTOR_REQUIRE_FOR_ADMINS:-false}
+ Authentication__TwoFactor__RememberDeviceDays: ${TWO_FACTOR_REMEMBER_DEVICE_DAYS:-30}
ports:
- "${TASKIST_PORT:-8080}:8080"
volumes:
diff --git a/docs/two-factor.md b/docs/two-factor.md
new file mode 100644
index 0000000..14f63ef
--- /dev/null
+++ b/docs/two-factor.md
@@ -0,0 +1,53 @@
+# Two-factor sign-in
+
+Two-factor sign-in asks for a code from an authenticator app after the password, so a stolen password alone isn't enough to get into Taskist. It works with any app that supports standard time-based codes (TOTP), such as Microsoft Authenticator, Google Authenticator, 1Password, Bitwarden, Authy or Aegis.
+
+- [For users: turn it on](#for-users-turn-it-on)
+- [Signing in](#signing-in)
+- [Lost your phone?](#lost-your-phone)
+- [For administrators](#for-administrators)
+
+## For users: turn it on
+
+1. Open **My profile → Security** and click **Turn on** under *Two-factor sign-in*.
+2. Scan the QR code with your authenticator app. If you can't scan it, type the key shown under the code into the app instead.
+3. Enter the 6-digit code the app shows and click **Turn on**.
+4. Taskist shows ten **recovery codes**. Save them somewhere safe, for example in your password manager. Each one signs you in once if you lose your phone. They aren't shown again.
+
+The option is only shown for accounts with a Taskist password. If you sign in with single sign-on, your organisation's identity provider handles extra verification instead.
+
+## Signing in
+
+After your password, Taskist asks for the current code from your app. If you tick **Don't ask again on this device**, that browser skips the code step for the next 30 days (your administrator can change or turn off this period).
+
+If a code is rejected, check that your phone's clock is set automatically, and use the newest code. A code can only be used once.
+
+## Lost your phone?
+
+- On the code step, click **Can't use your app? Use a recovery code** and enter one of your saved recovery codes.
+- Once you're in, go to **My profile → Security** and either turn two-factor sign-in off and on again with your new phone, or click **New recovery codes** if you've used several.
+- No phone and no recovery codes? Ask an administrator to **reset** your two-factor sign-in. You can then sign in with your password and set it up again.
+
+## For administrators
+
+### Settings
+
+| Setting | Default | Description |
+| --- | --- | --- |
+| `Authentication:TwoFactor:RequireForAdministrators` | `false` | Administrators who sign in with a password must set up two-factor sign-in. Until they do, they can only use their profile page. |
+| `Authentication:TwoFactor:RememberDeviceDays` | `30` | How long "Don't ask again on this device" lasts. `0` removes the option, so a code is asked at every sign-in. The remembered-device cookie is always marked *Secure*, so the option only works when people reach Taskist over HTTPS; on a plain-HTTP install (such as the Docker sample) a code is asked every time. |
+
+In Docker these are `TWO_FACTOR_REQUIRE_FOR_ADMINS` and `TWO_FACTOR_REMEMBER_DEVICE_DAYS` in `.env`.
+
+### Resetting a user
+
+Open **Users & Access → Users**, edit the user, and click **Reset two-factor**. This removes their authenticator key, recovery codes and remembered devices; they can sign in with just their password until they set it up again. Both your account and theirs get an entry in the activity log.
+
+Before resetting, make sure the request really comes from that person: a reset by mistake puts the account back to password-only.
+
+### Good to know
+
+- Wrong codes count towards the normal failed-attempt lock-out (**Configuration → Settings → Security**), just like wrong passwords. A locked account is unlocked from the user list as usual.
+- Turning two-factor sign-in off, or creating new recovery codes, needs a current code, so someone who briefly gets hold of an open session can't quietly remove it.
+- Single sign-on users are never asked for a Taskist code. If you require MFA, enforce it at your identity provider.
+- Keep the Data Protection key folder backed up (see [SECURITY.md](../SECURITY.md)). The authenticator keys are encrypted with it; if it's lost, every user with two-factor sign-in needs a reset.
diff --git a/sql-scripts/01_schema.sql b/sql-scripts/01_schema.sql
index 9796240..ae64a1a 100644
--- a/sql-scripts/01_schema.sql
+++ b/sql-scripts/01_schema.sql
@@ -2032,3 +2032,64 @@ END;
COMMIT;
GO
+BEGIN TRANSACTION;
+IF NOT EXISTS (
+ SELECT * FROM [__EFMigrationsHistory]
+ WHERE [MigrationId] = N'20261112183742_AddUserTwoFactor'
+)
+BEGIN
+ CREATE TABLE [UserRecoveryCode] (
+ [Id] int NOT NULL IDENTITY,
+ [UserId] int NOT NULL,
+ [CodeHash] nvarchar(64) NOT NULL,
+ [CreatedOn] datetime2 NOT NULL,
+ [UsedOn] datetime2 NULL,
+ CONSTRAINT [PK_UserRecoveryCode] PRIMARY KEY ([Id]),
+ CONSTRAINT [FK_UserRecoveryCode_User_UserId] FOREIGN KEY ([UserId]) REFERENCES [User] ([Id])
+ );
+END;
+
+IF NOT EXISTS (
+ SELECT * FROM [__EFMigrationsHistory]
+ WHERE [MigrationId] = N'20261112183742_AddUserTwoFactor'
+)
+BEGIN
+ CREATE TABLE [UserTwoFactor] (
+ [Id] int NOT NULL IDENTITY,
+ [UserId] int NOT NULL,
+ [Secret] nvarchar(max) NOT NULL,
+ [EnabledOn] datetime2 NOT NULL,
+ [LastUsedTimeStep] bigint NOT NULL,
+ CONSTRAINT [PK_UserTwoFactor] PRIMARY KEY ([Id]),
+ CONSTRAINT [FK_UserTwoFactor_User_UserId] FOREIGN KEY ([UserId]) REFERENCES [User] ([Id])
+ );
+END;
+
+IF NOT EXISTS (
+ SELECT * FROM [__EFMigrationsHistory]
+ WHERE [MigrationId] = N'20261112183742_AddUserTwoFactor'
+)
+BEGIN
+ CREATE INDEX [IX_UserRecoveryCode_UserId] ON [UserRecoveryCode] ([UserId]);
+END;
+
+IF NOT EXISTS (
+ SELECT * FROM [__EFMigrationsHistory]
+ WHERE [MigrationId] = N'20261112183742_AddUserTwoFactor'
+)
+BEGIN
+ CREATE UNIQUE INDEX [IX_UserTwoFactor_UserId] ON [UserTwoFactor] ([UserId]);
+END;
+
+IF NOT EXISTS (
+ SELECT * FROM [__EFMigrationsHistory]
+ WHERE [MigrationId] = N'20261112183742_AddUserTwoFactor'
+)
+BEGIN
+ INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
+ VALUES (N'20261112183742_AddUserTwoFactor', N'10.0.13');
+END;
+
+COMMIT;
+GO
+
diff --git a/sql-scripts/03_locale.sql b/sql-scripts/03_locale.sql
index 4a3ff2e..87633ec 100644
--- a/sql-scripts/03_locale.sql
+++ b/sql-scripts/03_locale.sql
@@ -623,6 +623,19 @@ FROM (VALUES
(N'Login.Sso.Or', N'or'),
(N'Login.Sso.PasswordSignInDisabled', N'Password sign-in is turned off. Use single sign-on instead.'),
(N'Login.Sso.SignInWith', N'Sign in with'),
+ (N'Login.TwoFactor.Cancel', N'Cancel and sign in again'),
+ (N'Login.TwoFactor.Code', N'Authentication code'),
+ (N'Login.TwoFactor.Expired', N'Your sign-in timed out or had too many wrong codes. Sign in again.'),
+ (N'Login.TwoFactor.Intro', N'Enter the 6-digit code from your authenticator app.'),
+ (N'Login.TwoFactor.RecoveryCode', N'Recovery code'),
+ (N'Login.TwoFactor.RecoveryIntro', N'Enter one of the recovery codes you saved when you set up two-factor sign-in. Each code works once.'),
+ (N'Login.TwoFactor.RememberDevice', N'Don’t ask again on this device for {0} days'),
+ (N'Login.TwoFactor.Title', N'Two-factor sign-in'),
+ (N'Login.TwoFactor.UseApp', N'Use your authenticator app instead'),
+ (N'Login.TwoFactor.UseRecovery', N'Can’t use your app? Use a recovery code'),
+ (N'Login.TwoFactor.Verify', N'Verify'),
+ (N'Login.TwoFactor.WrongCode', N'That code isn’t right. Check your authenticator app and try again.'),
+ (N'Login.TwoFactor.WrongRecoveryCode', N'That recovery code isn’t valid or has already been used.'),
(N'Message.DeleteSuccess', N'Deleted successfully'),
(N'Message.SaveSuccess', N'Saved successfully'),
(N'Message.UpdateSuccess', N'Updated successfully'),
@@ -760,6 +773,35 @@ FROM (VALUES
(N'Profile.SignIns.Unlink', N'Unlink'),
(N'Profile.SignIns.UnlinkConfirm', N'Unlink this sign-in? You can link it again by signing in with single sign-on.'),
(N'Profile.SignIns.Unlinked', N'Sign-in unlinked.'),
+ (N'Profile.TwoFactor.CodePrompt', N'Enter the current code from your authenticator app.'),
+ (N'Profile.TwoFactor.CodesIntro', N'Save these codes somewhere safe, such as a password manager. Each one signs you in once if you lose your phone. They won’t be shown again.'),
+ (N'Profile.TwoFactor.CodesLeft', N'{0} recovery codes left'),
+ (N'Profile.TwoFactor.CodesRegenerated', N'New recovery codes created. The old ones no longer work.'),
+ (N'Profile.TwoFactor.CodesTitle', N'Your recovery codes'),
+ (N'Profile.TwoFactor.Copied', N'Copied to the clipboard.'),
+ (N'Profile.TwoFactor.Copy', N'Copy'),
+ (N'Profile.TwoFactor.Disabled', N'Two-factor sign-in is off.'),
+ (N'Profile.TwoFactor.DisablePrompt', N'To turn off two-factor sign-in, enter a code from your authenticator app or a recovery code.'),
+ (N'Profile.TwoFactor.Enable', N'Turn on'),
+ (N'Profile.TwoFactor.Enabled', N'Two-factor sign-in is on.'),
+ (N'Profile.TwoFactor.Hint', N'Ask for a code from an authenticator app after your password.'),
+ (N'Profile.TwoFactor.ManualKey', N'Can’t scan it? Enter this key in the app instead:'),
+ (N'Profile.TwoFactor.NewCodes', N'New recovery codes'),
+ (N'Profile.TwoFactor.Off', N'Off'),
+ (N'Profile.TwoFactor.On', N'On'),
+ (N'Profile.TwoFactor.QrAlt', N'QR code for your authenticator app'),
+ (N'Profile.TwoFactor.RequiredHeading', N'Set up two-factor sign-in to continue'),
+ (N'Profile.TwoFactor.RequiredText', N'Administrators must use two-factor sign-in. Turn it on below; the rest of Taskist is available once it’s set up.'),
+ (N'Profile.TwoFactor.SavedThem', N'I’ve saved them'),
+ (N'Profile.TwoFactor.SetupExpired', N'The setup timed out. Close this window and start again.'),
+ (N'Profile.TwoFactor.SetupTitle', N'Set up two-factor sign-in'),
+ (N'Profile.TwoFactor.Step1', N'Scan this QR code with an authenticator app'),
+ (N'Profile.TwoFactor.Step1Hint', N'For example Microsoft Authenticator, Google Authenticator, 1Password, Bitwarden or Aegis.'),
+ (N'Profile.TwoFactor.Step2', N'Enter the 6-digit code the app shows'),
+ (N'Profile.TwoFactor.Title', N'Two-factor sign-in'),
+ (N'Profile.TwoFactor.TurnOff', N'Turn off'),
+ (N'Profile.TwoFactor.TurnOn', N'Turn on'),
+ (N'Profile.TwoFactor.WrongCode', N'That code isn’t right. Check the time on your phone and try the newest code.'),
(N'Profile.ZoomIn', N'Zoom in'),
(N'Profile.ZoomOut', N'Zoom out'),
(N'ProfilePage.Title', N'My Profile'),
@@ -1312,6 +1354,10 @@ FROM (VALUES
(N'UserPage.SignIns.Intro', N'Accounts at the identity provider that can sign this user in. Removing one doesn’t delete the user; if their e-mail still matches, it’s linked again on their next single sign-on.'),
(N'UserPage.SignIns.RemoveConfirm', N'Remove this sign-in from the user?'),
(N'UserPage.Title', N'User Registration'),
+ (N'UserPage.TwoFactor.Reset', N'Reset two-factor'),
+ (N'UserPage.TwoFactor.ResetConfirm', N'Reset two-factor sign-in for this user? Their authenticator app, recovery codes and remembered devices stop working, and they can sign in with just their password until they set it up again.'),
+ (N'UserPage.TwoFactor.ResetDone', N'Two-factor sign-in was reset.'),
+ (N'UserPage.TwoFactor.ResetHint', N'Reset it if the user has lost both their authenticator app and their recovery codes.'),
(N'UserProjectModel.CanAddWiki', N'Can Add Wiki'),
(N'UserProjectModel.CanChangeProject', N'Can Change Project'),
(N'UserProjectModel.CanClose', N'Can Close'),
diff --git a/src/Libraries/Taskist.Core/Common/ActivityType.cs b/src/Libraries/Taskist.Core/Common/ActivityType.cs
index 830eb6a..d16a042 100644
--- a/src/Libraries/Taskist.Core/Common/ActivityType.cs
+++ b/src/Libraries/Taskist.Core/Common/ActivityType.cs
@@ -9,6 +9,10 @@ public static class ActivityType
public const string Logout = "Logout";
+ public const string TwoFactorEnabled = "TwoFactorEnabled";
+
+ public const string TwoFactorDisabled = "TwoFactorDisabled";
+
public const string AccessDenied = "AccessDenied";
public const string Export = "Export";
diff --git a/src/Libraries/Taskist.Core/Domain/Users/UserRecoveryCode.cs b/src/Libraries/Taskist.Core/Domain/Users/UserRecoveryCode.cs
new file mode 100644
index 0000000..38d7ce1
--- /dev/null
+++ b/src/Libraries/Taskist.Core/Domain/Users/UserRecoveryCode.cs
@@ -0,0 +1,14 @@
+using Taskist.Core.Domain.Common;
+
+namespace Taskist.Core.Domain.Users;
+
+public class UserRecoveryCode : BaseEntity
+{
+ public int UserId { get; set; }
+
+ public string CodeHash { get; set; }
+
+ public DateTime CreatedOn { get; set; }
+
+ public DateTime? UsedOn { get; set; }
+}
diff --git a/src/Libraries/Taskist.Core/Domain/Users/UserTwoFactor.cs b/src/Libraries/Taskist.Core/Domain/Users/UserTwoFactor.cs
new file mode 100644
index 0000000..6751c0e
--- /dev/null
+++ b/src/Libraries/Taskist.Core/Domain/Users/UserTwoFactor.cs
@@ -0,0 +1,15 @@
+using Taskist.Core.Domain.Common;
+
+namespace Taskist.Core.Domain.Users;
+
+public class UserTwoFactor : BaseEntity
+{
+ public int UserId { get; set; }
+
+ [Encrypted]
+ public string Secret { get; set; }
+
+ public DateTime EnabledOn { get; set; }
+
+ public long LastUsedTimeStep { get; set; }
+}
diff --git a/src/Libraries/Taskist.Core/Security/Base32.cs b/src/Libraries/Taskist.Core/Security/Base32.cs
new file mode 100644
index 0000000..f5aed95
--- /dev/null
+++ b/src/Libraries/Taskist.Core/Security/Base32.cs
@@ -0,0 +1,73 @@
+using System.Text;
+
+namespace Taskist.Core.Security;
+
+public static class Base32
+{
+ #region Fields
+
+ private const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
+
+ #endregion
+
+ #region Methods
+
+ public static string Encode(byte[] data)
+ {
+ ArgumentNullException.ThrowIfNull(data);
+
+ var output = new StringBuilder((data.Length * 8 + 4) / 5);
+ int buffer = 0, bits = 0;
+
+ foreach (var b in data)
+ {
+ buffer = (buffer << 8) | b;
+ bits += 8;
+ while (bits >= 5)
+ {
+ output.Append(Alphabet[(buffer >> (bits - 5)) & 31]);
+ bits -= 5;
+ }
+ }
+
+ if (bits > 0)
+ output.Append(Alphabet[(buffer << (5 - bits)) & 31]);
+
+ return output.ToString();
+ }
+
+ public static byte[]? Decode(string? text)
+ {
+ if (string.IsNullOrWhiteSpace(text))
+ return null;
+
+ var output = new List(text.Length * 5 / 8);
+ int buffer = 0, bits = 0;
+
+ foreach (var raw in text)
+ {
+ if (raw == ' ' || raw == '-' || raw == '=')
+ continue;
+
+ var index = Alphabet.IndexOf(char.ToUpperInvariant(raw));
+ if (index < 0)
+ return null;
+
+ buffer = (buffer << 5) | index;
+ bits += 5;
+ if (bits >= 8)
+ {
+ output.Add((byte)((buffer >> (bits - 8)) & 0xFF));
+ bits -= 8;
+ }
+ }
+
+ return output.Count == 0 ? null : output.ToArray();
+ }
+
+ public static string Group(string value, int size = 4) =>
+ string.Join(' ', Enumerable.Range(0, (value.Length + size - 1) / size)
+ .Select(i => value.Substring(i * size, Math.Min(size, value.Length - i * size))));
+
+ #endregion
+}
diff --git a/src/Libraries/Taskist.Core/Security/OtpAuthUri.cs b/src/Libraries/Taskist.Core/Security/OtpAuthUri.cs
new file mode 100644
index 0000000..3eea9bb
--- /dev/null
+++ b/src/Libraries/Taskist.Core/Security/OtpAuthUri.cs
@@ -0,0 +1,20 @@
+namespace Taskist.Core.Security;
+
+public static class OtpAuthUri
+{
+ #region Methods
+
+ public static string Build(string issuer, string account, string base32Secret)
+ {
+ ArgumentException.ThrowIfNullOrWhiteSpace(issuer);
+ ArgumentException.ThrowIfNullOrWhiteSpace(account);
+ ArgumentException.ThrowIfNullOrWhiteSpace(base32Secret);
+
+ var label = $"{Uri.EscapeDataString(issuer.Trim())}:{Uri.EscapeDataString(account.Trim())}";
+
+ return $"otpauth://totp/{label}?secret={base32Secret}&issuer={Uri.EscapeDataString(issuer.Trim())}"
+ + $"&algorithm=SHA1&digits={Totp.Digits}&period={Totp.PeriodSeconds}";
+ }
+
+ #endregion
+}
diff --git a/src/Libraries/Taskist.Core/Security/RecoveryCodes.cs b/src/Libraries/Taskist.Core/Security/RecoveryCodes.cs
new file mode 100644
index 0000000..ce1be32
--- /dev/null
+++ b/src/Libraries/Taskist.Core/Security/RecoveryCodes.cs
@@ -0,0 +1,54 @@
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Taskist.Core.Security;
+
+public static class RecoveryCodes
+{
+ #region Fields
+
+ public const int DefaultCount = 10;
+
+ private const string Alphabet = "23456789abcdefghjkmnpqrstuvwxyz";
+
+ private const int GroupLength = 5;
+
+ #endregion
+
+ #region Methods
+
+ public static IReadOnlyList Generate(int count = DefaultCount)
+ {
+ var codes = new HashSet(StringComparer.Ordinal);
+ while (codes.Count < count)
+ {
+ var chars = new char[GroupLength * 2];
+ for (var i = 0; i < chars.Length; i++)
+ chars[i] = Alphabet[RandomNumberGenerator.GetInt32(Alphabet.Length)];
+
+ codes.Add($"{new string(chars, 0, GroupLength)}-{new string(chars, GroupLength, GroupLength)}");
+ }
+
+ return codes.ToList();
+ }
+
+ public static string? Normalize(string? code)
+ {
+ if (string.IsNullOrWhiteSpace(code))
+ return null;
+
+ var normalized = new string(code.Where(c => !char.IsWhiteSpace(c) && c != '-').ToArray()).ToLowerInvariant();
+ return normalized.Length == GroupLength * 2 && normalized.All(c => Alphabet.Contains(c)) ? normalized : null;
+ }
+
+ public static string? Hash(string? code)
+ {
+ var normalized = Normalize(code);
+ if (normalized == null)
+ return null;
+
+ return Convert.ToHexStringLower(SHA256.HashData(Encoding.ASCII.GetBytes(normalized)));
+ }
+
+ #endregion
+}
diff --git a/src/Libraries/Taskist.Core/Security/Totp.cs b/src/Libraries/Taskist.Core/Security/Totp.cs
new file mode 100644
index 0000000..2fe3674
--- /dev/null
+++ b/src/Libraries/Taskist.Core/Security/Totp.cs
@@ -0,0 +1,75 @@
+using System.Buffers.Binary;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Taskist.Core.Security;
+
+public static class Totp
+{
+ #region Fields
+
+ public const int Digits = 6;
+
+ public const int PeriodSeconds = 30;
+
+ public const int SecretBytes = 20;
+
+ public const int DefaultWindow = 1;
+
+ #endregion
+
+ #region Methods
+
+ public static string GenerateSecret() => Base32.Encode(RandomNumberGenerator.GetBytes(SecretBytes));
+
+ public static long TimeStep(DateTimeOffset time) => time.ToUnixTimeSeconds() / PeriodSeconds;
+
+ public static string ComputeCode(byte[] key, long timeStep)
+ {
+ ArgumentNullException.ThrowIfNull(key);
+
+ Span counter = stackalloc byte[8];
+ BinaryPrimitives.WriteInt64BigEndian(counter, timeStep);
+
+ var hash = HMACSHA1.HashData(key, counter);
+ var offset = hash[^1] & 0x0F;
+ var binary = ((hash[offset] & 0x7F) << 24)
+ | (hash[offset + 1] << 16)
+ | (hash[offset + 2] << 8)
+ | hash[offset + 3];
+
+ return (binary % 1_000_000).ToString("D6");
+ }
+
+ public static string? NormalizeCode(string? code)
+ {
+ if (string.IsNullOrWhiteSpace(code))
+ return null;
+
+ var digits = new string(code.Where(c => !char.IsWhiteSpace(c) && c != '-').ToArray());
+ return digits.Length == Digits && digits.All(char.IsAsciiDigit) ? digits : null;
+ }
+
+ public static long? Verify(string? base32Secret, string? code, DateTimeOffset now, long lastUsedTimeStep, int window = DefaultWindow)
+ {
+ var key = Base32.Decode(base32Secret);
+ var normalized = NormalizeCode(code);
+ if (key == null || normalized == null)
+ return null;
+
+ var expected = Encoding.ASCII.GetBytes(normalized);
+ var current = TimeStep(now);
+ long? matched = null;
+
+ for (var step = current - window; step <= current + window; step++)
+ {
+ var candidate = Encoding.ASCII.GetBytes(ComputeCode(key, step));
+ if (CryptographicOperations.FixedTimeEquals(candidate, expected) && step > lastUsedTimeStep)
+ matched ??= step;
+ }
+
+ return matched;
+ }
+
+ #endregion
+}
diff --git a/src/Libraries/Taskist.Data/Configuration/Users/UserRecoveryCodeConfig.cs b/src/Libraries/Taskist.Data/Configuration/Users/UserRecoveryCodeConfig.cs
new file mode 100644
index 0000000..a093f1b
--- /dev/null
+++ b/src/Libraries/Taskist.Data/Configuration/Users/UserRecoveryCodeConfig.cs
@@ -0,0 +1,28 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Taskist.Core.Domain.Users;
+
+namespace Taskist.Data.Configuration.Users;
+
+public class UserRecoveryCodeConfig : EntityTypeConfiguration
+{
+ public override void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable(nameof(UserRecoveryCode));
+
+ builder.HasKey(x => x.Id);
+
+ builder.Property(x => x.CodeHash)
+ .HasMaxLength(64)
+ .IsRequired();
+
+ builder.HasIndex(x => x.UserId);
+
+ builder.HasOne()
+ .WithMany()
+ .HasForeignKey(x => x.UserId)
+ .OnDelete(DeleteBehavior.NoAction);
+
+ base.Configure(builder);
+ }
+}
diff --git a/src/Libraries/Taskist.Data/Configuration/Users/UserTwoFactorConfig.cs b/src/Libraries/Taskist.Data/Configuration/Users/UserTwoFactorConfig.cs
new file mode 100644
index 0000000..04c4860
--- /dev/null
+++ b/src/Libraries/Taskist.Data/Configuration/Users/UserTwoFactorConfig.cs
@@ -0,0 +1,28 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Taskist.Core.Domain.Users;
+
+namespace Taskist.Data.Configuration.Users;
+
+public class UserTwoFactorConfig : EntityTypeConfiguration
+{
+ public override void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable(nameof(UserTwoFactor));
+
+ builder.HasKey(x => x.Id);
+
+ builder.Property(x => x.Secret)
+ .IsRequired();
+
+ builder.HasIndex(x => x.UserId)
+ .IsUnique();
+
+ builder.HasOne()
+ .WithMany()
+ .HasForeignKey(x => x.UserId)
+ .OnDelete(DeleteBehavior.NoAction);
+
+ base.Configure(builder);
+ }
+}
diff --git a/src/Libraries/Taskist.Data/Migrations/20261112183742_AddUserTwoFactor.Designer.cs b/src/Libraries/Taskist.Data/Migrations/20261112183742_AddUserTwoFactor.Designer.cs
new file mode 100644
index 0000000..ffe28bc
--- /dev/null
+++ b/src/Libraries/Taskist.Data/Migrations/20261112183742_AddUserTwoFactor.Designer.cs
@@ -0,0 +1,3497 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Taskist.Data;
+
+#nullable disable
+
+namespace Taskist.Data.Migrations
+{
+ [DbContext(typeof(ApplicationContext))]
+ [Migration("20261112183742_AddUserTwoFactor")]
+ partial class AddUserTwoFactor
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "10.0.13")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("Taskist.Core.Domain.Announcements.Announcement", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("Audience")
+ .HasColumnType("int");
+
+ b.Property("Body")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Deleted")
+ .HasColumnType("bit");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("RequiresAcknowledgement")
+ .HasColumnType("bit");
+
+ b.Property("Severity")
+ .HasColumnType("int");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("nvarchar(200)");
+
+ b.Property("Type")
+ .HasColumnType("int");
+
+ b.Property("ValidFrom")
+ .HasColumnType("date");
+
+ b.Property("ValidTo")
+ .HasColumnType("date");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Active", "Deleted");
+
+ b.ToTable("Announcement", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Announcements.AnnouncementAcknowledgement", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("AcknowledgedOnUtc")
+ .HasColumnType("datetime2");
+
+ b.Property("AnnouncementId")
+ .HasColumnType("int");
+
+ b.Property("UserId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("AnnouncementId", "UserId")
+ .IsUnique();
+
+ b.ToTable("AnnouncementAcknowledgement", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Announcements.AnnouncementRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("AnnouncementId")
+ .HasColumnType("int");
+
+ b.Property("UserRoleId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserRoleId");
+
+ b.HasIndex("AnnouncementId", "UserRoleId");
+
+ b.ToTable("AnnouncementRole", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Git.ExternalCommentLink", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("BacklogCommentId")
+ .HasColumnType("int");
+
+ b.Property("ContentHash")
+ .HasMaxLength(64)
+ .HasColumnType("nvarchar(64)");
+
+ b.Property("ExternalCommentId")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("nvarchar(64)");
+
+ b.Property("ExternalIssueLinkId")
+ .HasColumnType("int");
+
+ b.Property("Inbound")
+ .HasColumnType("bit");
+
+ b.Property("LastSyncedOn")
+ .HasColumnType("datetime2");
+
+ b.HasKey("Id");
+
+ b.HasIndex("BacklogCommentId");
+
+ b.HasIndex("ExternalIssueLinkId", "ExternalCommentId")
+ .IsUnique();
+
+ b.ToTable("ExternalCommentLink", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Git.ExternalIssueLink", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("BacklogId")
+ .HasColumnType("int");
+
+ b.Property("CreatedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("ExternalId")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("nvarchar(64)");
+
+ b.Property("LastError")
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)");
+
+ b.Property("LastSyncedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("Number")
+ .HasColumnType("int");
+
+ b.Property("ProjectRepositoryId")
+ .HasColumnType("int");
+
+ b.Property("RemoteState")
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("RemoteUpdatedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("Snapshot")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SyncEnabled")
+ .HasColumnType("bit");
+
+ b.Property("Url")
+ .HasMaxLength(500)
+ .HasColumnType("nvarchar(500)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("BacklogId");
+
+ b.HasIndex("ProjectRepositoryId", "Number")
+ .IsUnique();
+
+ b.ToTable("ExternalIssueLink", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Git.GitConnection", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("AllowInsecureHttp")
+ .HasColumnType("bit");
+
+ b.Property("ApiUrl")
+ .HasMaxLength(500)
+ .HasColumnType("nvarchar(500)");
+
+ b.Property("AppId")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("AppPrivateKey")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("AuthMode")
+ .HasColumnType("int");
+
+ b.Property("BaseUrl")
+ .IsRequired()
+ .HasMaxLength(500)
+ .HasColumnType("nvarchar(500)");
+
+ b.Property("CreatedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("Deleted")
+ .HasColumnType("bit");
+
+ b.Property("IsDefault")
+ .HasColumnType("bit");
+
+ b.Property("ModifiedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("OAuthClientId")
+ .HasMaxLength(200)
+ .HasColumnType("nvarchar(200)");
+
+ b.Property("OAuthClientSecret")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ProviderType")
+ .HasColumnType("int");
+
+ b.Property("ServiceAccountExternalId")
+ .HasMaxLength(64)
+ .HasColumnType("nvarchar(64)");
+
+ b.Property("ServiceAccountUserName")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("ServiceToken")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("GitConnection", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Git.GitWebhookDelivery", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Attempts")
+ .HasColumnType("int");
+
+ b.Property("DeliveryId")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("Error")
+ .HasMaxLength(1000)
+ .HasColumnType("nvarchar(1000)");
+
+ b.Property("EventName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("Payload")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ProcessedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("ProjectRepositoryId")
+ .HasColumnType("int");
+
+ b.Property("ReceivedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ReceivedOn");
+
+ b.HasIndex("ProjectRepositoryId", "DeliveryId")
+ .IsUnique();
+
+ b.ToTable("GitWebhookDelivery", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Git.ProjectRepository", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("CreatedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("DefaultBranch")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("Deleted")
+ .HasColumnType("bit");
+
+ b.Property("DisplayName")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("ExternalRepoId")
+ .HasMaxLength(64)
+ .HasColumnType("nvarchar(64)");
+
+ b.Property("GitConnectionId")
+ .HasColumnType("int");
+
+ b.Property("IsPrimary")
+ .HasColumnType("bit");
+
+ b.Property("IsPrivate")
+ .HasColumnType("bit");
+
+ b.Property("IssueClosedStatusId")
+ .HasColumnType("int");
+
+ b.Property("IssueImportLabel")
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("IssueImportLimitPerHour")
+ .HasColumnType("int");
+
+ b.Property("IssueLastPolledOn")
+ .HasColumnType("datetime2");
+
+ b.Property("IssueOpenStatusId")
+ .HasColumnType("int");
+
+ b.Property("IssueSeverityId")
+ .HasColumnType("int");
+
+ b.Property("IssueSyncComments")
+ .HasColumnType("bit");
+
+ b.Property("IssueSyncEnabledOn")
+ .HasColumnType("datetime2");
+
+ b.Property("IssueSyncMode")
+ .HasColumnType("int");
+
+ b.Property("IssueSyncTaskTypeIds")
+ .HasMaxLength(200)
+ .HasColumnType("nvarchar(200)");
+
+ b.Property("IssueSyncUserId")
+ .HasColumnType("int");
+
+ b.Property("IssueTaskTypeId")
+ .HasColumnType("int");
+
+ b.Property("ModifiedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("ProjectId")
+ .HasColumnType("int");
+
+ b.Property("RepoRef")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("WebUrl")
+ .HasMaxLength(500)
+ .HasColumnType("nvarchar(500)");
+
+ b.Property("WebhookKey")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("nvarchar(64)");
+
+ b.Property("WebhookLastDeliveryOn")
+ .HasColumnType("datetime2");
+
+ b.Property("WebhookSecret")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("WebhookSecretCreatedOn")
+ .HasColumnType("datetime2");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GitConnectionId");
+
+ b.HasIndex("IssueClosedStatusId");
+
+ b.HasIndex("IssueOpenStatusId");
+
+ b.HasIndex("IssueSeverityId");
+
+ b.HasIndex("IssueSyncUserId");
+
+ b.HasIndex("IssueTaskTypeId");
+
+ b.HasIndex("WebhookKey")
+ .IsUnique();
+
+ b.HasIndex("ProjectId", "GitConnectionId", "RepoRef");
+
+ b.ToTable("ProjectRepository", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Git.UserGitAccount", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("AccessToken")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ConnectedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayName")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("ExpiresOn")
+ .HasColumnType("datetime2");
+
+ b.Property("ExternalUserId")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("nvarchar(64)");
+
+ b.Property("GitConnectionId")
+ .HasColumnType("int");
+
+ b.Property("LastUsedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("RefreshExpiresOn")
+ .HasColumnType("datetime2");
+
+ b.Property("RefreshToken")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Scopes")
+ .HasMaxLength(500)
+ .HasColumnType("nvarchar(500)");
+
+ b.Property("TokenType")
+ .HasColumnType("int");
+
+ b.Property("UserId")
+ .HasColumnType("int");
+
+ b.Property("UserName")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GitConnectionId", "ExternalUserId")
+ .IsUnique();
+
+ b.HasIndex("UserId", "GitConnectionId")
+ .IsUnique();
+
+ b.ToTable("UserGitAccount", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Localization.Language", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("DisplayName")
+ .IsRequired()
+ .HasMaxLength(750)
+ .HasColumnType("nvarchar(750)");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("LanguageCulture")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(750)
+ .HasColumnType("nvarchar(750)");
+
+ b.Property("Rtl")
+ .HasColumnType("bit");
+
+ b.HasKey("Id");
+
+ b.ToTable("Language", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Localization.LocaleResource", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("LanguageId")
+ .HasColumnType("int");
+
+ b.Property("ResourceKey")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("ResourceValue")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LanguageId");
+
+ b.ToTable("LocaleResource", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Logging.ActivityLog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Comment")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("datetime2");
+
+ b.Property("EntityId")
+ .HasColumnType("int");
+
+ b.Property("EntityName")
+ .IsRequired()
+ .HasMaxLength(500)
+ .HasColumnType("nvarchar(500)");
+
+ b.Property("IpAddress")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SystemName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("UserId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("ActivityLog", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Logging.AuditLog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Action")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("datetime2");
+
+ b.Property("EntityId")
+ .HasColumnType("int");
+
+ b.Property("EntityName")
+ .IsRequired()
+ .HasMaxLength(500)
+ .HasColumnType("nvarchar(500)");
+
+ b.Property("IpAddress")
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("NewValues")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("OldValues")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("EntityName", "EntityId");
+
+ b.ToTable("AuditLog", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Logging.Log", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("datetime2");
+
+ b.Property("FullMessage")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("IpAddress")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("LogLevel")
+ .HasColumnType("int");
+
+ b.Property("LogLevelId")
+ .HasColumnType("int");
+
+ b.Property("PageUrl")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ReferrerUrl")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ShortMessage")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Log", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.Address", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Address1")
+ .IsRequired()
+ .HasMaxLength(750)
+ .HasColumnType("nvarchar(750)");
+
+ b.Property("Address2")
+ .HasMaxLength(750)
+ .HasColumnType("nvarchar(750)");
+
+ b.Property("City")
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("ZipPostalCode")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Address", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("ContactPerson")
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("Deleted")
+ .HasColumnType("bit");
+
+ b.Property("Description")
+ .HasMaxLength(250)
+ .HasColumnType("nvarchar(250)");
+
+ b.Property("Email")
+ .HasMaxLength(250)
+ .HasColumnType("nvarchar(250)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("PhoneNumber")
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("Website")
+ .HasMaxLength(750)
+ .HasColumnType("nvarchar(750)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Client", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.CustomField", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ColumnClass")
+ .HasMaxLength(20)
+ .HasColumnType("int");
+
+ b.Property("FieldType")
+ .HasColumnType("int");
+
+ b.Property("Label")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Mandatory")
+ .HasColumnType("bit");
+
+ b.Property("Options")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Placement")
+ .HasColumnType("int");
+
+ b.Property("ProjectId")
+ .HasColumnType("int");
+
+ b.Property("ResourceKey")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProjectId");
+
+ b.ToTable("CustomField", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.Document", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ContentType")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("Extension")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("FileData")
+ .IsRequired()
+ .HasColumnType("varbinary(max)");
+
+ b.Property("FileName")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("FileSize")
+ .HasColumnType("bigint");
+
+ b.HasKey("Id");
+
+ b.ToTable("Document", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.EmailAccount", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("Description")
+ .HasMaxLength(250)
+ .HasColumnType("nvarchar(250)");
+
+ b.Property("EnableSsl")
+ .HasColumnType("bit");
+
+ b.Property("FromEmail")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("FromName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Host")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Port")
+ .HasColumnType("int");
+
+ b.Property("UserName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("EmailAccount", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.EmailTemplate", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("EmailAccountId")
+ .HasColumnType("int");
+
+ b.Property("EmailBody")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("EmailSubject")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("EmailAccountId");
+
+ b.ToTable("EmailTemplate", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.GenericAttribute", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("CreatedOrUpdatedDate")
+ .HasColumnType("datetime2");
+
+ b.Property("EntityId")
+ .HasColumnType("int");
+
+ b.Property("Key")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("nvarchar(200)");
+
+ b.Property("KeyGroup")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("nvarchar(200)");
+
+ b.Property("Value")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("GenericAttribute", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.Menu", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ActionName")
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("Code")
+ .HasColumnType("int");
+
+ b.Property("ControllerName")
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("Icon")
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("ParentCode")
+ .HasColumnType("int");
+
+ b.Property("Permission")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("SystemName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Menu", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.Module", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Active")
+ .HasColumnType("bit");
+
+ b.Property("Deleted")
+ .HasColumnType("bit");
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.Property("ProjectId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProjectId");
+
+ b.ToTable("Module", (string)null);
+ });
+
+ modelBuilder.Entity("Taskist.Core.Domain.Masters.NotificationChannel", b =>
+ {
+ b.Property |