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

Add multi-user auth and management support. #2082

Merged
merged 66 commits into from
Oct 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
1b7128a
Implement OIDC
Feb 4, 2024
e406b25
Add a settings UI for OIDC.
knadh Apr 2, 2024
8ca95f6
Refactor OIDC middleware handler logic.
knadh Apr 2, 2024
f8b3ddb
Refactor the `oidc` package and separate out handlers.
knadh Apr 2, 2024
83e4f5d
Add migrations for OIDC db fields.
knadh Apr 2, 2024
4648f91
Fix bug in OIDC cookie check.
knadh Apr 2, 2024
435d6d5
Add create/add/delete user management UI and database schema.
knadh Apr 2, 2024
0968e58
Add user/password login handler.
knadh Apr 9, 2024
10f1c38
Add missing user UI files.
knadh Apr 13, 2024
bf0b500
Add API token authentication.
knadh Apr 27, 2024
1516bf2
Add `api` type user.
knadh May 7, 2024
57ac9dc
Add public login page and auth middleware and handlers.
knadh May 23, 2024
906e0f5
Refactor handler groups and add mising auth features like logout.
knadh May 25, 2024
a6e06d9
Refactor migration for the latest version.
knadh May 25, 2024
6a34ebc
Update login credentials doc in sample config.
knadh May 30, 2024
4997c10
Add user profile APIs and update UI.
knadh May 30, 2024
313b2af
Make user avatar field nullable.
knadh May 30, 2024
7bb14de
Upgrade simplesessions to v3.
knadh Jun 1, 2024
2000e9f
Style and add OIDC logo to the login page.
knadh Jun 1, 2024
d4e4c5f
Add granular permissions and role management to backend and admin UI.
knadh Jun 15, 2024
8126eec
Restyle tags on the UI.
knadh Jun 16, 2024
32d5823
Refactor 'super' user type to a pre-defined super admin role.
knadh Jun 16, 2024
09145b4
Fix profile edit page.
knadh Jun 16, 2024
dd9612b
Add user profile based permission check in auth middleware.
knadh Jun 17, 2024
474f935
Add permission checks to admin UI to toggle visibility/functionality …
knadh Jun 17, 2024
4a69f0a
Minor refactor to subscribers UI. Remove superfluous status column.
knadh Jun 17, 2024
f69aa30
Move User/Roles nav items under Settings.
knadh Jun 17, 2024
19527f9
Add new fields to `/api/config` to remove `/settings` dependency in c…
knadh Jun 19, 2024
612c1d6
Add per-list permission management to roles.
knadh Jun 23, 2024
d52eac0
Update user APIs and queries to embed role + list permissions.
knadh Jun 23, 2024
17b5cc1
Sort roles by created date.
knadh Jun 30, 2024
72c7676
Add cookie check hack to auth for v3 -> 4 browser BasicAuth session i…
knadh Jul 6, 2024
ee90496
Apply minor linting fixes to role form.
knadh Jul 6, 2024
a8c1778
Add warning on admin UI for legacy creds in the TOML file.
knadh Jul 6, 2024
4eabd96
Refactor update check.
knadh Jul 6, 2024
193f8a8
Add one-click provider config shortcut in OIDC settings.
knadh Jul 8, 2024
90591fc
Apply OIDC/user profile related changes to admin UI.
knadh Jul 8, 2024
834f541
Update OIDC auth URL in login form.
knadh Jul 8, 2024
7c92b65
Add `avatar` field to user schema for OIDC avatars.
knadh Jul 8, 2024
1e875af
Add OIDC auth hooks (init, callback, session) and finish OIDC support.
knadh Jul 8, 2024
b0f6c22
Fix broken subscription status tag on subscriber form UI.
knadh Jul 13, 2024
b7155a4
Fix admin UI legacy user warning.
knadh Jul 14, 2024
e6ec1cb
User legacy (TOML) admin credentials as API creds for backwards compa…
knadh Jul 14, 2024
0bea998
Fix role selection on in user form.
knadh Jul 15, 2024
5024ded
Add API user authentication to auth module with caching of creds on u…
knadh Jul 15, 2024
2da920d
Add legacy TOML user+password to API auth on init with warning.
knadh Jul 17, 2024
68870ad
Fix update check looping on failed HTTP requests.
knadh Jul 18, 2024
bf00fd2
Add support for setting admin user/password via env on `--install`.
knadh Jul 29, 2024
1649b3b
Fix logic for preventing sole super admin from being wrongly updated/…
knadh Jul 29, 2024
26c6db0
Remove admin user/password from sample config generation.
knadh Jul 29, 2024
f8e6eaa
Add docs for v4.x.x multi-user upgrade changes.
knadh Jul 29, 2024
982e8d8
Fix post v4.x.x upgrade warning on admin UI.
knadh Jul 29, 2024
d74e067
Add per-list permission to list management.
knadh Aug 3, 2024
12a6451
Add list permission check to subscriber calls.
knadh Aug 10, 2024
ae2a386
Add support for "list roles".
knadh Sep 2, 2024
3671a52
Update profile UI with new user data structures.
knadh Sep 2, 2024
eb47e80
Fix list auth by adding an explicit 'getAll' flag to query.
knadh Sep 2, 2024
0331e3c
Sory users by `created_at` always.
knadh Sep 3, 2024
d9b4bae
Rename migration to v4.0.0
knadh Sep 11, 2024
a268341
Refactor subscriber APIs list permission filtering.
knadh Sep 16, 2024
ee119b0
Fix import not 'unsubscribing' list subs for already blacklisted subs…
knadh Sep 17, 2024
cea65c0
Fix and refactor subscriber batch fetching in campaign processing.
knadh Sep 20, 2024
f226aca
Add missing auth permissions file.
knadh Sep 25, 2024
af06d2e
Upgrade prismjs.
knadh Oct 13, 2024
cc71899
Add non-prod ODIC URL warning on admin settings UI.
knadh Oct 13, 2024
39463d7
Refresh i18n langauge strings.
knadh Oct 13, 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
Prev Previous commit
Next Next commit
Remove admin user/password from sample config generation.
knadh committed Oct 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 26c6db0a1354b35d68bcd547ab56594c4bd442b8
8 changes: 0 additions & 8 deletions cmd/install.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"os"
"regexp"
"strings"

"github.com/gofrs/uuid/v5"
@@ -306,13 +305,6 @@ func newConfigFile(path string) error {
return fmt.Errorf("error reading sample config (is binary stuffed?): %v", err)
}

// Generate a random admin password.
pwd, err := generateRandomString(16)
if err == nil {
b = regexp.MustCompile(`admin_password\s+?=\s+?(.*)`).
ReplaceAll(b, []byte(fmt.Sprintf(`admin_password = "%s"`, pwd)))
}

return os.WriteFile(path, b, 0644)
}

12 changes: 0 additions & 12 deletions config.toml.sample
Original file line number Diff line number Diff line change
@@ -5,18 +5,6 @@
# port, use port 80 (this will require running with elevated permissions).
address = "localhost:9000"

# ###### IMPORTANT ######
# Username and password are only used during installation (--install)
# for creating the superadmin user in the database.
#
# After installation, login to the admin dashboard, update the superadmin's
# user profile with the necessary details and remove these username and
# password from here.
#
# Username should be min 3 chars and Password should be min 8 chars.
admin_username = "listmonk"
admin_password = "listmonk"

# Database.
[db]
host = "localhost"
17 changes: 8 additions & 9 deletions docs/docs/content/installation.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Installation

listmonk requires Postgres ⩾ 12.
listmonk requires Postgres ⩾ 12

See the "[Tutorials](#tutorials)" section at the bottom for detailed guides.
!!! Admin
Set environment variables `LISTMONK_ADMIN_USER` and `LISTMONK_ADMIN_PASSWORD` when installing listmonk to create the Super Admin user. If these are not set, listmonk generates a username and temporary password which are printed on the terminal output.

## Binary
- Download the [latest release](https://github.com/knadh/listmonk/releases) and extract the listmonk binary. `amd64` is the main one. It works for Intel and x86 CPUs.
- `./listmonk --new-config` to generate config.toml. Then, edit the file.
- `./listmonk --install` to install the tables in the Postgres DB.
- `./listmonk --install` to install the tables in the Postgres DB. Copy the username and password from the terminal output.
- Run `./listmonk` and visit `http://localhost:9000`.


@@ -16,7 +17,7 @@ See the "[Tutorials](#tutorials)" section at the bottom for detailed guides.
The latest image is available on DockerHub at `listmonk/listmonk:latest`

!!! note
Listmonk's docs and scripts use `docker compose`, which is compatible with the latest version of docker. If you installed docker and docker-compose from your Linux distribution, you probably have an older version and will need to use the `docker-compose` command instead, or you'll need to update docker manually. [More info](https://gist.github.com/MaximilianKohler/e5158fcfe6de80a9069926a67afcae11#docker-update).
listmonk's docs and scripts use `docker compose`, which is compatible with the latest version of docker. If you installed docker and docker-compose from your Linux distribution, you probably have an older version and will need to use the `docker-compose` command instead, or you'll need to update docker manually. [More info](https://gist.github.com/MaximilianKohler/e5158fcfe6de80a9069926a67afcae11#docker-update).

Use the sample [docker-compose.yml](https://github.com/knadh/listmonk/blob/master/docker-compose.yml) to run listmonk and Postgres DB with `docker compose` as follows:

@@ -61,7 +62,7 @@ The above shell script performs the following actions:

#### Manual Docker install

The following workflow is recommended to setup `listmonk` manually using `docker compose`. You are encouraged to customise the contents of `docker-compose.yml` to your needs. The overall setup looks like:
The following workflow is recommended to setup `listmonk` manually using `docker compose`. You are encouraged to customise the contents of [`docker-compose.yml`](https://github.com/knadh/listmonk/blob/master/docker-compose.yml) to your needs. The overall setup looks like:

- `docker compose up db` to run the Postgres DB.
- `docker compose run --rm app ./listmonk --install` to setup the DB (or `--upgrade` to upgrade an existing DB).
@@ -94,8 +95,6 @@ Here's a sample `config.toml` you can use:
```toml
[app]
address = "0.0.0.0:9000"
admin_username = "listmonk"
admin_password = "listmonk"

# Database.
[db]
@@ -177,9 +176,9 @@ $ helm upgrade \

## Tutorials

* [Informal step-by-step on how to get started with Listmonk using *Railway*](https://github.com/knadh/listmonk/issues/120#issuecomment-1421838533)
* [Informal step-by-step on how to get started with listmonk using *Railway*](https://github.com/knadh/listmonk/issues/120#issuecomment-1421838533)
* [Step-by-step tutorial for installation and all basic functions. *Amazon EC2, SES, docker & binary*](https://gist.github.com/MaximilianKohler/e5158fcfe6de80a9069926a67afcae11)
* [Step-by-step guide on how to install and set up Listmonk on *AWS Lightsail with docker* (rameerez)](https://github.com/knadh/listmonk/issues/1208)
* [Step-by-step guide on how to install and set up listmonk on *AWS Lightsail with docker* (rameerez)](https://github.com/knadh/listmonk/issues/1208)
* [Quick setup on any cloud server using *docker and caddy*](https://github.com/samyogdhital/listmonk-caddy-reverse-proxy)
* [*Binary* install on Ubuntu 22.04 as a service](https://mumaritc.hashnode.dev/how-to-install-listmonk-using-binary-on-ubuntu-2204)
* [*Binary* install on Ubuntu 18.04 as a service (Apache & Plesk)](https://devgypsy.com/post/2020-08-18-installing-listmonk-newsletter-manager/)
2 changes: 1 addition & 1 deletion docs/docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ nav:
- "Installation": installation.md
- "Configuration": configuration.md
- "Upgrade": upgrade.md
- "Using Listmonk":
- "Using listmonk":
- "Concepts": concepts.md
- "Templating": templating.md
- "Querying and segmenting subscribers": querying-and-segmentation.md