Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature addition: Multi-Factor Authentication #163

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
3fb4d95
Adding basic MFA in the form of TOTP
BrandonMauldin May 2, 2024
baca395
Started integrating totp into startup sequance
BrandonMauldin May 2, 2024
fad5140
Continued integrating TOTP.
BrandonMauldin May 3, 2024
4574b81
TOTP fully working MVP
BrandonMauldin May 3, 2024
f8d1d55
Added regenerate totp button to the click event for enabling totp
BrandonMauldin May 3, 2024
18a2305
Added secret validation
BrandonMauldin May 3, 2024
f466cd0
Saving TOTP secret requires password verification
BrandonMauldin May 6, 2024
b873e8b
Merge branch 'zadam:master' into mfa
chesspro13 May 6, 2024
25c9869
Updated TOTP explination
BrandonMauldin May 7, 2024
bc2f082
Corrected white space
BrandonMauldin May 7, 2024
4e22065
Started to add recovery code feature
BrandonMauldin May 9, 2024
8997eb5
Updated api to pull codes from the server
BrandonMauldin May 9, 2024
41764e3
Added random codes
BrandonMauldin May 10, 2024
e88f1e5
Recovery key can take place of TOTP.
BrandonMauldin May 11, 2024
1879588
Recovery Code Functionality complete
BrandonMauldin May 12, 2024
7f039a0
Formatting
chesspro13 May 12, 2024
7020ae0
Formatting
chesspro13 May 12, 2024
2f62efd
Formatting
chesspro13 May 12, 2024
349f6b0
Formatting
chesspro13 May 12, 2024
28151d7
Removed unused code
chesspro13 May 12, 2024
cab43c7
Formatting/minor changes
chesspro13 May 12, 2024
6780172
Formatting
chesspro13 May 12, 2024
73259e5
Formatting
chesspro13 May 12, 2024
fe1d251
Formatting
chesspro13 May 12, 2024
a50c8d6
Removed POST from middle of string
chesspro13 May 12, 2024
ad7a171
Formatting + minor changes
chesspro13 May 13, 2024
369034c
testing
BrandonMauldin May 15, 2024
e62edb4
Can access OpenID providers and login. Has no bearing on logging in t…
chesspro13 May 18, 2024
28b506e
Logout issue fixed
chesspro13 May 20, 2024
7e86d79
Working on setup
BrandonMauldin May 20, 2024
c84280a
Cleaned up. Still login looping when server restarts.
chesspro13 May 22, 2024
9947084
Login loop fixed
chesspro13 May 23, 2024
091764c
Cleanup/refactoring
BrandonMauldin May 23, 2024
796d7cc
Merge pull request #160 from chesspro13/OIDC
chesspro13 May 23, 2024
bfc5778
Merged TOTP and OAuth into MFA widget.
BrandonMauldin May 23, 2024
7b2ce8a
Changed TOTP to require authenticator code to save secret instead of …
chesspro13 May 23, 2024
78fc105
Added MFA reference
chesspro13 May 23, 2024
42f774f
Fixed SQL init error
chesspro13 May 23, 2024
61c7065
Changed TOTP to be loaded from .env
chesspro13 May 24, 2024
7681851
Fixed outdated import
chesspro13 May 24, 2024
fdda99c
Added MFA description/refactored
chesspro13 May 24, 2024
c76898a
Fixing OAuth
chesspro13 May 24, 2024
e7825e5
Fixed OAuth login and TOTP enabled by default
chesspro13 May 27, 2024
b0c04b8
Fixed redirect error
chesspro13 May 27, 2024
6f1856d
Minor Fixes
chesspro13 May 27, 2024
a582a2c
Fixed initial OAuth crash
chesspro13 May 27, 2024
e5763e0
Force user to have env variables set to use OAuth and TOTP.
chesspro13 May 27, 2024
ac90e1c
Force user to have env variables set to use OAuth and TOTP server side
chesspro13 May 27, 2024
6e9deed
Update settings.json
chesspro13 May 29, 2024
0818eb4
Formatting
chesspro13 May 30, 2024
5535252
Switched from unmaintained library "Speakeasy" to "time2fa"
chesspro13 May 31, 2024
97df8f8
Removed depricated functions/files
chesspro13 May 31, 2024
124cac4
Refactoring
chesspro13 Jun 6, 2024
2e8350d
Added user_data table to track user ID for oauth
chesspro13 Jun 7, 2024
4869851
Re-wrote userID getting saved to DB
chesspro13 Jun 10, 2024
50dbf87
Still refactoring
chesspro13 Jun 11, 2024
788ca9a
Reworking and refactoring
chesspro13 Jun 12, 2024
0029ad9
Working on decryption
chesspro13 Jun 12, 2024
c5200b8
Debugging SQL
chesspro13 Jun 17, 2024
16830d2
OpenID 90% working.
chesspro13 Jun 18, 2024
3fdc6ae
Fixed salt missing from table.
chesspro13 Aug 11, 2024
6fe45a9
Fixed Logout Issue
chesspro13 Aug 11, 2024
8abdca9
Untrack README.md
chesspro13 Aug 11, 2024
62f5298
Formatting Updates part 1
chesspro13 Aug 11, 2024
fa885e7
Merge Attempt 1
chesspro13 Aug 15, 2024
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
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
OAUTH_ENABLED="false"
BASE_URL="http://localhost:8080"
CLIENT_ID="1234"
ISSUER_BASE_URL="https://example.com/xyz/.well-known/openid-configuration"
SECRET="I-Like-Trilium-Notes"
AUTH_0_LOGOUT="false"

TOTP_ENABLED="false"
TOTP_SECRET="Trilium-Notes-is-the-best"
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@ data/
data-test/
tmp/
.eslintcache
.env

out/

images/app-icons/png/512x512.png
images/app-icons/png/1024x1024.png
images/app-icons/mac/*.png
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"editor.formatOnSave": true,
"files.eol": "\n",
"typescript.tsdk": "node_modules/typescript/lib"
"editor.formatOnSave": false,
"files.eol": "\n",
"typescript.tsdk": "node_modules/typescript/lib"
}
114 changes: 63 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,101 @@
# Trilium Notes
# TriliumNext Notes

## Trilium is in maintenance mode - see details in https://github.com/zadam/trilium/issues/4620
[English](https://github.com/TriliumNext/Notes/blob/master/README.md) | [Chinese](https://github.com/TriliumNext/Notes/blob/master/README-ZH_CN.md) | [Russian](https://github.com/TriliumNext/Notes/blob/master/README.ru.md) | [Japanese](https://github.com/TriliumNext/Notes/blob/master/README.ja.md) | [Italian](https://github.com/TriliumNext/Notes/blob/master/README.it.md)

Preliminary disccusions on the successor organization are taking place in [Trilium Next discussions](https://github.com/orgs/TriliumNext/discussions).
TriliumNext Notes is an open-source, cross-platform hierarchical note taking application with focus on building large personal knowledge bases.

[![Join the chat at https://gitter.im/trilium-notes/Lobby](https://badges.gitter.im/trilium-notes/Lobby.svg)](https://gitter.im/trilium-notes/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [English](https://github.com/zadam/trilium/blob/master/README.md) | [Chinese](https://github.com/zadam/trilium/blob/master/README-ZH_CN.md) | [Russian](https://github.com/zadam/trilium/blob/master/README.ru.md) | [Japanese](https://github.com/zadam/trilium/blob/master/README.ja.md) | [Italian](https://github.com/zadam/trilium/blob/master/README.it.md)
See [screenshots](https://triliumnext.github.io/Docs/Wiki/screenshot-tour) for quick overview:

<a href="https://triliumnext.github.io/Docs/Wiki/screenshot-tour"><img src="https://github.com/TriliumNext/Docs/blob/main/Wiki/images/screenshot.png?raw=true" alt="Trilium Screenshot" width="1000"></a>

Trilium Notes is a hierarchical note taking application with focus on building large personal knowledge bases.
## ⚠️ Why TriliumNext?

See [screenshots](https://github.com/zadam/trilium/wiki/Screenshot-tour) for quick overview:
[The original Trilium project is in maintenance mode](https://github.com/zadam/trilium/issues/4620)

<a href="https://github.com/zadam/trilium/wiki/Screenshot-tour"><img src="https://raw.githubusercontent.com/wiki/zadam/trilium/images/screenshot.png" alt="Trilium Screenshot" width="1000"></a>
## 💬 Discuss with us

Ukraine is currently defending itself from Russian aggression, please consider [donating to Ukrainian Army or humanitarian charities](https://standforukraine.com/).
Feel free to join our official conversations. We would love to hear what features, suggestions, or issues you may have!

<p float="left">
<img src="https://upload.wikimedia.org/wikipedia/commons/4/49/Flag_of_Ukraine.svg" alt="drawing" width="400"/>
<img src="https://signmyrocket.com//uploads/2b2a523cd0c0e76cdbba95a89a9636b2_1676971281.jpg" alt="Trilium Notes supports Ukraine!" width="570"/>
</p>
- [Matrix](https://matrix.to/#/#triliumnext:matrix.org) (For synchronous discussions)
- The `General` Matrix room is also bridged to [XMPP](xmpp:[email protected]?join)
- [Github Discussions](https://github.com/TriliumNext/Notes/discussions) (For Asynchronous discussions)
- [Wiki](https://triliumnext.github.io/Docs/) (For common how-to questions and user guides)

## 🎁 Features

* Notes can be arranged into arbitrarily deep tree. Single note can be placed into multiple places in the tree (see [cloning](https://github.com/zadam/trilium/wiki/Cloning-notes))
* Rich WYSIWYG note editing including e.g. tables, images and [math](https://github.com/zadam/trilium/wiki/Text-notes#math-support) with markdown [autoformat](https://github.com/zadam/trilium/wiki/Text-notes#autoformat)
* Support for editing [notes with source code](https://github.com/zadam/trilium/wiki/Code-notes), including syntax highlighting
* Fast and easy [navigation between notes](https://github.com/zadam/trilium/wiki/Note-navigation), full text search and [note hoisting](https://github.com/zadam/trilium/wiki/Note-hoisting)
* Seamless [note versioning](https://github.com/zadam/trilium/wiki/Note-revisions)
* Note [attributes](https://github.com/zadam/trilium/wiki/Attributes) can be used for note organization, querying and advanced [scripting](https://github.com/zadam/trilium/wiki/Scripts)
* [Synchronization](https://github.com/zadam/trilium/wiki/Synchronization) with self-hosted sync server
* there's a [3rd party service for hosting synchronisation server](https://trilium.cc/paid-hosting)
* [Sharing](https://github.com/zadam/trilium/wiki/Sharing) (publishing) notes to public internet
* Strong [note encryption](https://github.com/zadam/trilium/wiki/Protected-notes) with per-note granularity
* Sketching diagrams with built-in Excalidraw (note type "canvas")
* [Relation maps](https://github.com/zadam/trilium/wiki/Relation-map) and [link maps](https://github.com/zadam/trilium/wiki/Link-map) for visualizing notes and their relations
* [Scripting](https://github.com/zadam/trilium/wiki/Scripts) - see [Advanced showcases](https://github.com/zadam/trilium/wiki/Advanced-showcases)
* [REST API](https://github.com/zadam/trilium/wiki/ETAPI) for automation
* Scales well in both usability and performance upwards of 100 000 notes
* Touch optimized [mobile frontend](https://github.com/zadam/trilium/wiki/Mobile-frontend) for smartphones and tablets
* [Night theme](https://github.com/zadam/trilium/wiki/Themes)
* [Evernote](https://github.com/zadam/trilium/wiki/Evernote-import) and [Markdown import & export](https://github.com/zadam/trilium/wiki/Markdown)
* [Web Clipper](https://github.com/zadam/trilium/wiki/Web-clipper) for easy saving of web content
- Notes can be arranged into arbitrarily deep tree. Single note can be placed into multiple places in the tree (see [cloning](https://triliumnext.github.io/Docs/Wiki/cloning-notes)
- Rich WYSIWYG note editing including e.g. tables, images and [math](https://triliumnext.github.io/Docs/Wiki/text-notes) with markdown [autoformat](https://triliumnext.github.io/Docs/Wiki/text-notes#autoformat)
- Support for editing [notes with source code](https://triliumnext.github.io/Docs/Wiki/code-notes), including syntax highlighting
- Fast and easy [navigation between notes](https://triliumnext.github.io/Docs/Wiki/note-navigation), full text search and [note hoisting](https://triliumnext.github.io/Docs/Wiki/note-hoisting)
- Seamless [note versioning](https://triliumnext.github.io/Docs/Wiki/note-revisions)
- Note [attributes](https://triliumnext.github.io/Docs/Wiki/attributes) can be used for note organization, querying and advanced [scripting](https://triliumnext.github.io/Docs/Wiki/scripts)
- [Synchronization](https://triliumnext.github.io/Docs/Wiki/synchronization) with self-hosted sync server
- there's a [3rd party service for hosting synchronisation server](https://trilium.cc/paid-hosting)
- [Sharing](https://triliumnext.github.io/Docs/Wiki/sharing) (publishing) notes to public internet
- Strong [note encryption](https://triliumnext.github.io/Docs/Wiki/protected-notes) with per-note granularity
- Sketching diagrams with built-in Excalidraw (note type "canvas")
- [Relation maps](https://triliumnext.github.io/Docs/Wiki/relation-map) and [link maps](https://triliumnext.github.io/Docs/Wiki/link-map) for visualizing notes and their relations
- [Scripting](https://triliumnext.github.io/Docs/Wiki/scripts) - see [Advanced showcases](https://triliumnext.github.io/Docs/Wiki/advanced-showcases)
- [REST API](https://triliumnext.github.io/Docs/Wiki/etapi) for automation
- Scales well in both usability and performance upwards of 100 000 notes
- Touch optimized [mobile frontend](https://triliumnext.github.io/Docs/Wiki/mobile-frontend) for smartphones and tablets
- [Night theme](https://triliumnext.github.io/Docs/Wiki/themes)
- [Evernote](https://triliumnext.github.io/Docs/Wiki/evernote-import) and [Markdown import & export](https://triliumnext.github.io/Docs/Wiki/markdown)
- [Web Clipper](https://triliumnext.github.io/Docs/Wiki/web-clipper) for easy saving of web content

Check out [awesome-trilium](https://github.com/Nriver/awesome-trilium) for 3rd party themes, scripts, plugins and more.
Check out the following third-party resources/communities for more TriliumNext related goodies:

## 🏗 Builds
- [awesome-trilium](https://github.com/Nriver/awesome-trilium) for 3rd party themes, scripts, plugins and more.
- [TriliumRocks!](https://trilium.rocks/) for tutorials, guides, and much more.

Trilium is provided as either desktop application (Linux and Windows) or web application hosted on your server (Linux). Mac OS desktop build is available, but it is [unsupported](https://github.com/zadam/trilium/wiki/FAQ#mac-os-support).
## 🏗 Installation

* If you want to use Trilium on the desktop, download binary release for your platform from [latest release](https://github.com/zadam/trilium/releases/latest), unzip the package and run ```trilium``` executable.
* If you want to install Trilium on server, follow [this page](https://github.com/zadam/trilium/wiki/Server-installation).
* Currently only recent Chrome and Firefox are supported (tested) browsers.
### Desktop

Trilium is also provided as a Flatpak:
To use TriliumNext on your desktop machine (Linux, MacOS, and Windows) you have a few options:

[<img width="240" src="https://flathub.org/assets/badges/flathub-badge-en.png">](https://flathub.org/apps/details/com.github.zadam.trilium)
- Download the binary release for your platform from the [latest release page](https://github.com/TriliumNext/Notes/releases/latest), unzip the package and run the `trilium` executable.
- Access TriliumNext via the web interface of a server installation (see below)
- Currently only the latest versions of Chrome & Firefox are supported (and tested).
- (Coming Soon) TriliumNext will also be provided as a Flatpak

### Mobile

To use TriliumNext on a mobile device:

- Use a mobile web browser to access the mobile interface of a server installation (see below)
- Use of a mobile app is not yet supported ([see here](https://github.com/TriliumNext/Notes/issues/72)) to track mobile improvements.

### Server

To install TriliumNext on your own server (including via Docker from [Dockerhub](https://hub.docker.com/r/triliumnext/notes)) follow [the server installation docs](https://triliumnext.github.io/Docs/Wiki/server-installation).

## 📝 Documentation

[See wiki for complete list of documentation pages.](https://github.com/zadam/trilium/wiki/)
[See wiki for complete list of documentation pages.](https://triliumnext.github.io/Docs)

You can also read [Patterns of personal knowledge base](https://github.com/zadam/trilium/wiki/Patterns-of-personal-knowledge-base) to get some inspiration on how you might use Trilium.
You can also read [Patterns of personal knowledge base](https://triliumnext.github.io/Docs/Wiki/patterns-of-personal-knowledge) to get some inspiration on how you might use TriliumNext.

## 💻 Contribute

Use a browser based dev environment

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/zadam/trilium)
Clone locally and run

Or clone locally and run
```
npm install
npm run start-server
```

## 📢 Shoutouts
## 👏 Shoutouts

* [CKEditor 5](https://github.com/ckeditor/ckeditor5) - best WYSIWYG editor on the market, very interactive and listening team
* [FancyTree](https://github.com/mar10/fancytree) - very feature rich tree library without real competition. Trilium Notes would not be the same without it.
* [CodeMirror](https://github.com/codemirror/CodeMirror) - code editor with support for huge amount of languages
* [jsPlumb](https://github.com/jsplumb/jsplumb) - visual connectivity library without competition. Used in [relation maps](https://github.com/zadam/trilium/wiki/Relation-map) and [link maps](https://github.com/zadam/trilium/wiki/Link-map)
- [CKEditor 5](https://github.com/ckeditor/ckeditor5) - best WYSIWYG editor on the market, very interactive and listening team
- [FancyTree](https://github.com/mar10/fancytree) - very feature rich tree library without real competition. TriliumNext Notes would not be the same without it.
- [CodeMirror](https://github.com/codemirror/CodeMirror) - code editor with support for huge amount of languages
- [jsPlumb](https://github.com/jsplumb/jsplumb) - visual connectivity library without competition. Used in [relation maps](https://triliumnext.github.io/Docs/Wiki/Relation-map) and [link maps](https://triliumnext.github.io/Docs/Wiki/Link-map)

## 🤝 Support

You can support Trilium using GitHub Sponsors, [PayPal](https://paypal.me/za4am) or Bitcoin (bitcoin:bc1qv3svjn40v89mnkre5vyvs2xw6y8phaltl385d2).
You can support the original Trilium developer using GitHub Sponsors, [PayPal](https://paypal.me/za4am) or Bitcoin (bitcoin:bc1qv3svjn40v89mnkre5vyvs2xw6y8phaltl385d2).
Support for the TriliumNext organization will be possible in the near future.

## 🔑 License

Expand Down
11 changes: 11 additions & 0 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ CREATE TABLE IF NOT EXISTS "options"
isSynced INTEGER default 0 not null,
utcDateModified TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS "user_data"
(
tmpID INT,
userIDEcnryptedDataKey TEXT,
userIDVerificationHash TEXT,
salt TEXT,
derivedKey TEXT,
isSetup TEXT DEFAULT "false",
UNIQUE (tmpID),
PRIMARY KEY (tmpID)
);
CREATE TABLE IF NOT EXISTS "attributes"
(
attributeId TEXT not null primary key,
Expand Down
Loading