Skip to content

Commit 23e8d0c

Browse files
committed
implement credentials auth provider
1 parent f068368 commit 23e8d0c

File tree

6 files changed

+1417
-436
lines changed

6 files changed

+1417
-436
lines changed
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# Credentials Auth Provider
2+
3+
Username/password authentication for LLMS. Provides a Sign In page, user management
4+
for admins, and account self-service for all users.
5+
6+
## Enabling
7+
8+
Credentials auth is the default provider. It activates automatically when at least
9+
one user has been created via `--adduser`. You can also set it explicitly:
10+
11+
```bash
12+
llms --auth credentials
13+
```
14+
15+
Or via environment variable:
16+
17+
```bash
18+
export LLMS_AUTH=credentials
19+
```
20+
21+
If no users exist, the extension disables itself and the app runs without authentication.
22+
23+
## Getting Started
24+
25+
Create your first admin user and start the server:
26+
27+
```bash
28+
llms --adduser admin
29+
# Enter password when prompted
30+
# The "admin" username automatically gets the Admin role
31+
32+
llms
33+
```
34+
35+
You'll be presented with the Sign In page. After logging in as `admin`, you can
36+
create additional users from the **Manage Users** page in the UI.
37+
38+
## CLI Commands
39+
40+
All commands operate on the user store at `~/.llms/credentials/users.json`.
41+
42+
### `--adduser USERNAME`
43+
44+
Create a new user or update an existing user's password. Prompts for password
45+
with confirmation.
46+
47+
```bash
48+
# Create a regular user
49+
llms --adduser alice
50+
51+
# Create an admin (the username "admin" auto-assigns the Admin role)
52+
llms --adduser admin
53+
```
54+
55+
### `--removeuser USERNAME`
56+
57+
Delete a user and invalidate all their active sessions.
58+
59+
```bash
60+
llms --removeuser alice
61+
```
62+
63+
### `--listusers`
64+
65+
List all users with their creation date and lock status.
66+
67+
```bash
68+
llms --listusers
69+
# admin (created: 2025-03-15 10:30:00)
70+
# alice (created: 2025-03-15 11:00:00)
71+
# bob (created: 2025-03-16 09:15:00) LOCKED: Account suspended
72+
```
73+
74+
### `--lockuser [USERNAME]`
75+
76+
Lock a user account, preventing them from signing in. All active sessions are
77+
immediately invalidated. Prompts for a lock reason (defaults to "Account suspended").
78+
79+
```bash
80+
# Lock a specific user
81+
llms --lockuser bob
82+
83+
# List users with lock status (omit username)
84+
llms --lockuser
85+
```
86+
87+
### `--unlockuser USERNAME`
88+
89+
Restore access for a locked user account.
90+
91+
```bash
92+
llms --unlockuser bob
93+
```
94+
95+
## UI Features
96+
97+
### Sign In Page
98+
99+
When authentication is enabled, unauthenticated users see a Sign In form with
100+
username and password fields. Validation errors and incorrect credentials are
101+
displayed inline.
102+
103+
### User Menu
104+
105+
After signing in, the user avatar dropdown shows:
106+
107+
- **Display name** and email
108+
- **Manage Users** link (Admin only)
109+
- **My Account** link
110+
- **Sign Out** button
111+
112+
### Manage Users (Admin only)
113+
114+
Accessible at `/admin` for users with the Admin role. Provides a table of all
115+
users showing:
116+
117+
| Column | Description |
118+
|------------|------------------------------------------|
119+
| Username | Account name |
120+
| Roles | Assigned roles (Admin badge highlighted) |
121+
| Status | Active or Locked (with lock icon) |
122+
| Created | Account creation date |
123+
| Last Login | IP address and relative timestamp |
124+
| Actions | Per-user action buttons |
125+
126+
**Available actions per user:**
127+
128+
- **Change Password** - Set a new password for any user (modal dialog)
129+
- **Lock** - Suspend the account with confirmation (not available for admins or yourself)
130+
- **Unlock** - Restore a locked account
131+
- **Delete** - Permanently remove the account with confirmation (cannot delete yourself)
132+
133+
**Create User** - Click "New User" to create accounts with a username, password,
134+
and optional Admin role.
135+
136+
### My Account
137+
138+
Accessible at `/account` for all authenticated users. Shows your profile
139+
information (avatar, username, roles) and provides a **Change Password** button
140+
that requires your current password for verification.
141+
142+
## How To
143+
144+
### Set up authentication for the first time
145+
146+
```bash
147+
# 1. Create an admin user
148+
llms --adduser admin
149+
# Enter and confirm password
150+
151+
# 2. Start the server
152+
llms
153+
154+
# 3. Sign in at the web UI, then use Manage Users to create more accounts
155+
```
156+
157+
### Create multiple users from the CLI
158+
159+
```bash
160+
llms --adduser admin
161+
llms --adduser alice
162+
llms --adduser bob
163+
```
164+
165+
### Reset a user's password from the CLI
166+
167+
Re-running `--adduser` with an existing username updates their password:
168+
169+
```bash
170+
llms --adduser alice
171+
# "User 'alice' already exists. Updating password."
172+
# Enter new password
173+
```
174+
175+
### Reset a user's password from the UI
176+
177+
Sign in as an Admin, go to **Manage Users** (`/admin`), and click the key icon
178+
next to the user to open the Change Password dialog.
179+
180+
### Temporarily disable a user
181+
182+
```bash
183+
# Lock the account
184+
llms --lockuser bob
185+
# Reason: "On vacation until March"
186+
187+
# Later, restore access
188+
llms --unlockuser bob
189+
```
190+
191+
Or from the UI: go to **Manage Users**, click the lock icon next to the user,
192+
and confirm.
193+
194+
### Change your own password
195+
196+
Sign in, click your avatar, select **My Account**, and click **Change Password**.
197+
You'll need to enter your current password first.
198+
199+
### Switch to a different auth provider
200+
201+
```bash
202+
# Use GitHub OAuth instead
203+
llms --auth github_auth
204+
205+
# Or disable auth entirely
206+
llms --auth none
207+
```
208+
209+
## Session Details
210+
211+
- Sessions are stored in memory and persisted to `~/.llms/credentials/sessions/`
212+
- Sessions expire after **30 days**
213+
- Sessions survive server restarts (loaded from disk on startup)
214+
- The session token is stored in an HTTP-only cookie (`llms-token`)
215+
- Locking or deleting a user immediately invalidates all their sessions

0 commit comments

Comments
 (0)