Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Taskist is a self-hosted **task, change request and bug tracker** built with ASP
<td width="50%" valign="top">

**⚙️ 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
Expand Down Expand Up @@ -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.


<a name="database"></a>
Expand Down
13 changes: 13 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
1 change: 1 addition & 0 deletions THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
53 changes: 53 additions & 0 deletions docs/two-factor.md
Original file line number Diff line number Diff line change
@@ -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.
61 changes: 61 additions & 0 deletions sql-scripts/01_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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

46 changes: 46 additions & 0 deletions sql-scripts/03_locale.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down
Loading
Loading