Skip to content

Commit 2ca6725

Browse files
cbcoutinhoclaude
andcommitted
docs: Replace .nextcloud_oauth_client.json references with SQLite storage
Replace all references to the JSON file-based OAuth client storage with SQLite database storage in documentation. OAuth client credentials are now stored in the SQLite database instead of .nextcloud_oauth_client.json. Changes: - Update oauth-architecture.md to reference SQLite database - Update jwt-oauth-reference.md credential storage sections - Update oauth-setup.md Docker volume mounts and security best practices - Update oauth-troubleshooting.md file permission → database permission errors - Update configuration.md to remove JSON file chmod instructions - Update troubleshooting.md database permission troubleshooting The code already uses SQLite (RefreshTokenStorage class), so only documentation needed updating. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 4c7d1cf commit 2ca6725

File tree

6 files changed

+53
-66
lines changed

6 files changed

+53
-66
lines changed

docs/configuration.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ NEXTCLOUD_HOST=https://your.nextcloud.instance.com
4545
NEXTCLOUD_OIDC_CLIENT_ID=your-client-id
4646
NEXTCLOUD_OIDC_CLIENT_SECRET=your-client-secret
4747
48-
# OAuth Storage and Callback Settings (optional)
49-
NEXTCLOUD_OIDC_CLIENT_STORAGE=.nextcloud_oauth_client.json
48+
# OAuth Callback Settings (optional)
5049
NEXTCLOUD_MCP_SERVER_URL=http://localhost:8000
5150
5251
# Leave these EMPTY for OAuth mode
@@ -61,7 +60,6 @@ NEXTCLOUD_PASSWORD=
6160
| `NEXTCLOUD_HOST` | ✅ Yes | - | Full URL of your Nextcloud instance (e.g., `https://cloud.example.com`) |
6261
| `NEXTCLOUD_OIDC_CLIENT_ID` | ⚠️ Optional | - | OAuth client ID (auto-registers if empty) |
6362
| `NEXTCLOUD_OIDC_CLIENT_SECRET` | ⚠️ Optional | - | OAuth client secret (auto-registers if empty) |
64-
| `NEXTCLOUD_OIDC_CLIENT_STORAGE` | ⚠️ Optional | `.nextcloud_oauth_client.json` | Path to store auto-registered client credentials |
6563
| `NEXTCLOUD_MCP_SERVER_URL` | ⚠️ Optional | `http://localhost:8000` | MCP server URL for OAuth callbacks |
6664
| `NEXTCLOUD_USERNAME` | ❌ Must be empty | - | Leave empty to enable OAuth mode |
6765
| `NEXTCLOUD_PASSWORD` | ❌ Must be empty | - | Leave empty to enable OAuth mode |
@@ -160,10 +158,6 @@ Options:
160158
NEXTCLOUD_OIDC_CLIENT_ID env var)
161159
--oauth-client-secret TEXT OAuth client secret (can also use
162160
NEXTCLOUD_OIDC_CLIENT_SECRET env var)
163-
--oauth-storage-path TEXT Path to store OAuth client credentials
164-
(can also use
165-
NEXTCLOUD_OIDC_CLIENT_STORAGE env var)
166-
[default: .nextcloud_oauth_client.json]
167161
--mcp-server-url TEXT MCP server URL for OAuth callbacks (can
168162
also use NEXTCLOUD_MCP_SERVER_URL env
169163
var) [default: http://localhost:8000]
@@ -225,10 +219,7 @@ uv run nextcloud-mcp-server --no-oauth \
225219
- Store OAuth client credentials securely
226220
- Use environment variables from your deployment platform (Docker secrets, Kubernetes ConfigMaps, etc.)
227221
- Never commit credentials to version control
228-
- Set appropriate file permissions on credential storage:
229-
```bash
230-
chmod 600 .nextcloud_oauth_client.json
231-
```
222+
- SQLite database permissions are handled automatically by the server
232223

233224
### For Docker
234225

docs/jwt-oauth-reference.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ mcp-oauth:
272272
273273
**Key Points:**
274274
- **No credentials needed** - DCR automatically registers the client on first start
275-
- **Credentials persist** - Saved to `.nextcloud_oauth_client.json` and reused
275+
- **Credentials persist** - Saved to SQLite database and reused
276276
- **JWT tokens** - Use `--oauth-token-type jwt` for better performance
277277
- **Token verifier supports both** - Can handle JWT and opaque tokens
278278
- **Pre-configured credentials** - Providing `CLIENT_ID`/`CLIENT_SECRET` skips DCR
@@ -286,7 +286,6 @@ mcp-oauth:
286286
| `NEXTCLOUD_PUBLIC_ISSUER_URL` | Public issuer URL for JWT validation | (uses `NEXTCLOUD_HOST`) |
287287
| `NEXTCLOUD_OIDC_CLIENT_ID` | Pre-configured OAuth client ID | (optional - uses DCR if unset) |
288288
| `NEXTCLOUD_OIDC_CLIENT_SECRET` | Pre-configured OAuth client secret | (optional - uses DCR if unset) |
289-
| `NEXTCLOUD_OIDC_CLIENT_STORAGE` | Path to persist DCR-registered credentials | `.nextcloud_oauth_client.json` |
290289
| `NEXTCLOUD_OIDC_SCOPES` | Space-separated scopes to request | `"openid profile email mcp:notes:read mcp:notes:write"` |
291290
| `NEXTCLOUD_OIDC_TOKEN_TYPE` | Token format: `"jwt"` or `"Bearer"` | `"Bearer"` |
292291

@@ -303,8 +302,8 @@ When the MCP server starts in OAuth mode, it follows this **three-tier credentia
303302
├─ NEXTCLOUD_OIDC_CLIENT_ID
304303
└─ NEXTCLOUD_OIDC_CLIENT_SECRET
305304
306-
2. Storage File (Second Priority)
307-
└─ NEXTCLOUD_OIDC_CLIENT_STORAGE (.nextcloud_oauth_client.json)
305+
2. SQLite Database (Second Priority)
306+
└─ OAuth client credentials table
308307
309308
3. Dynamic Client Registration (Automatic Fallback)
310309
├─ Discovers registration endpoint from /.well-known/openid-configuration
@@ -327,10 +326,10 @@ export NEXTCLOUD_OIDC_TOKEN_TYPE=jwt # or "Bearer" for opaque tokens
327326

328327
**Credential Storage:**
329328

330-
- Registered credentials are saved to `NEXTCLOUD_OIDC_CLIENT_STORAGE` (default: `.nextcloud_oauth_client.json`)
331-
- File has restrictive permissions (0600 - owner read/write only)
329+
- Registered credentials are saved to SQLite database
330+
- Database is encrypted and protected by file system permissions
332331
- Credentials are reused on subsequent starts (no re-registration needed)
333-
- Storage file is checked for expiration (auto-regenerates if expired)
332+
- Stored credentials are checked for expiration (auto-regenerates if expired)
334333

335334
**Format:**
336335
```json
@@ -386,9 +385,9 @@ export NEXTCLOUD_OIDC_CLIENT_ID="<client_id>"
386385
export NEXTCLOUD_OIDC_CLIENT_SECRET="<client_secret>"
387386
export NEXTCLOUD_OIDC_TOKEN_TYPE="jwt"
388387
389-
# Option 2: Storage file (second priority)
390-
# Save the JSON response to .nextcloud_oauth_client.json
391-
# Server will automatically load it on startup
388+
# Option 2: SQLite database (second priority)
389+
# Credentials are automatically saved to the database after DCR
390+
# Server will automatically load them on startup
392391
```
393392

394393
When credentials are provided via environment variables or storage file, **DCR is skipped**.
@@ -724,7 +723,7 @@ docker compose exec db mariadb -u nextcloud -ppassword nextcloud \
724723
1. Ensure `NEXTCLOUD_OIDC_SCOPES` environment variable is set correctly
725724
2. Check MCP server startup logs for the scopes being requested
726725
3. Verify DCR is enabled in Nextcloud OIDC app settings
727-
4. Delete `.nextcloud_oauth_client.json` and restart to force re-registration
726+
4. Clear the SQLite database OAuth client entry and restart to force re-registration
728727

729728
### Issue: Token Type Case Sensitivity
730729

docs/oauth-architecture.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Phase 0: MCP Server Startup & Client Registration (DCR - RFC 7591)
3939
│ 0d. Client credentials │
4040
│<────────────────────────────────────┤
4141
│ {client_id, client_secret} │
42-
│ → Saved to .nextcloud_oauth_*.json
42+
│ → Saved to SQLite database
4343
│ │
4444
│ ✓ Server ready for connections │
4545
@@ -211,7 +211,7 @@ Insufficient Scope Example (Step-Up Authorization)
211211
- **PKCE Validation**: Verifies server advertises S256 code challenge method
212212
- **Dynamic Client Registration (DCR)**: Automatically registers OAuth client via `/apps/oidc/register` (RFC 7591)
213213
- Or loads pre-configured client credentials
214-
- Saves credentials to `.nextcloud_oauth_client.json`
214+
- Saves credentials to SQLite database
215215
- **Tool Registration**: Loads all MCP tools with their `@require_scopes` decorators
216216

217217
#### Client Connection Phase
@@ -324,7 +324,7 @@ The OAuth flow consists of four distinct phases (see diagram above for visual re
324324
- MCP server registers itself as OAuth client (RFC 7591)
325325
- Provides: client name, redirect URIs, requested scopes, token type
326326
- Receives: `client_id`, `client_secret`
327-
- Saves credentials to `.nextcloud_oauth_client.json`
327+
- Saves credentials to SQLite database
328328

329329
3. **Tool Registration**
330330
- All MCP tools loaded with their `@require_scopes` decorators
@@ -515,7 +515,7 @@ NEXTCLOUD_HOST=https://nextcloud.example.com
515515
**How it works**:
516516
1. Server checks `/.well-known/openid-configuration` for `registration_endpoint`
517517
2. Calls `/apps/oidc/register` to register a client on first startup
518-
3. Saves credentials to `.nextcloud_oauth_client.json`
518+
3. Saves credentials to SQLite database
519519
4. Reuses these credentials on subsequent startups
520520
5. Re-registers only if credentials are missing or expired
521521

@@ -718,7 +718,6 @@ See [Configuration Guide](configuration.md) for all OAuth environment variables:
718718
| `NEXTCLOUD_OIDC_CLIENT_ID` | Pre-configured client ID (optional) |
719719
| `NEXTCLOUD_OIDC_CLIENT_SECRET` | Pre-configured client secret (optional) |
720720
| `NEXTCLOUD_MCP_SERVER_URL` | MCP server URL for OAuth callbacks |
721-
| `NEXTCLOUD_OIDC_CLIENT_STORAGE` | Path for auto-registered credentials |
722721

723722
## Testing
724723

docs/oauth-setup.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ You have two options for managing OAuth clients:
170170
**How it works**:
171171
- MCP server automatically registers an OAuth client on first startup
172172
- Uses Nextcloud's dynamic client registration endpoint
173-
- Saves credentials to `.nextcloud_oauth_client.json`
173+
- Saves credentials to SQLite database
174174
- Reuses stored credentials on subsequent restarts
175175
- Re-registers automatically if credentials expire
176176

@@ -253,9 +253,6 @@ NEXTCLOUD_PASSWORD=
253253
254254
# Optional: MCP server URL (for OAuth callbacks)
255255
NEXTCLOUD_MCP_SERVER_URL=http://localhost:8000
256-
257-
# Optional: Client storage path
258-
NEXTCLOUD_OIDC_CLIENT_STORAGE=.nextcloud_oauth_client.json
259256
EOF
260257
```
261258

@@ -291,7 +288,6 @@ EOF
291288
| `NEXTCLOUD_OIDC_CLIENT_ID` | ⚠️ Mode B only | - | OAuth client ID |
292289
| `NEXTCLOUD_OIDC_CLIENT_SECRET` | ⚠️ Mode B only | - | OAuth client secret |
293290
| `NEXTCLOUD_MCP_SERVER_URL` | ⚠️ Optional | `http://localhost:8000` | MCP server URL for callbacks |
294-
| `NEXTCLOUD_OIDC_CLIENT_STORAGE` | ⚠️ Optional | `.nextcloud_oauth_client.json` | Client credentials storage path |
295291
| `NEXTCLOUD_USERNAME` | ❌ Must be empty | - | Leave empty for OAuth |
296292
| `NEXTCLOUD_PASSWORD` | ❌ Must be empty | - | Leave empty for OAuth |
297293

@@ -334,7 +330,7 @@ INFO OIDC discovery successful
334330
INFO Attempting dynamic client registration...
335331
INFO Dynamic client registration successful
336332
INFO OAuth client ready: <client-id>...
337-
INFO Saved OAuth client credentials to .nextcloud_oauth_client.json
333+
INFO Saved OAuth client credentials to SQLite database
338334
INFO OAuth initialization complete
339335
INFO MCP server ready at http://127.0.0.1:8000
340336
```
@@ -427,9 +423,9 @@ uv run nextcloud-mcp-server --oauth --log-level debug
427423

428424
2. **Secure Credential Storage**
429425
```bash
430-
# Set restrictive permissions
431-
chmod 600 .nextcloud_oauth_client.json
426+
# Set restrictive permissions on environment file
432427
chmod 600 .env
428+
# Database permissions are handled automatically
433429
```
434430

435431
3. **Use HTTPS for MCP Server**
@@ -474,7 +470,7 @@ services:
474470
NEXTCLOUD_OIDC_CLIENT_SECRET: ${NEXTCLOUD_OIDC_CLIENT_SECRET}
475471
NEXTCLOUD_MCP_SERVER_URL: http://your-server:8000
476472
volumes:
477-
- ./oauth_client.json:/app/.nextcloud_oauth_client.json
473+
- ./data:/app/data # For SQLite database persistence
478474
command: ["--oauth", "--transport", "streamable-http"]
479475
restart: unless-stopped
480476
```

docs/oauth-troubleshooting.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Start here to identify your issue:
1717
| Only seeing Notes tools (7 instead of 90+) | Limited OAuth scopes granted | [Limited Scopes](#limited-scopes---only-seeing-notes-tools) |
1818
| HTTP 401 for Notes API | Bearer token patch missing | [Bearer Token Auth Fails](#bearer-token-authentication-fails) |
1919
| "OIDC discovery failed" | Network or configuration issue | [Discovery Failed](#oidc-discovery-failed) |
20-
| "Permission denied" on .nextcloud_oauth_client.json | File permissions issue | [File Permission Error](#file-permission-error) |
20+
| "Database error" on OAuth client storage | Database permissions issue | [Database Permission Error](#database-permission-error) |
2121

2222
## Configuration Issues
2323

@@ -161,39 +161,38 @@ php occ config:app:set oidc expire_time --value "86400" # 24 hours
161161

162162
---
163163

164-
### File Permission Error
164+
### Database Permission Error
165165

166166
**Error Message**:
167167
```
168-
Permission denied when reading/writing .nextcloud_oauth_client.json
168+
Permission denied when accessing SQLite database
169+
Database is locked
169170
```
170171

171-
**Cause**: The server cannot access the OAuth client storage file.
172+
**Cause**: The server cannot access the SQLite database file.
172173

173174
**Solution**:
174175

175176
```bash
176-
# Check file permissions
177-
ls -la .nextcloud_oauth_client.json
178-
179-
# Fix file permissions (owner read/write only)
180-
chmod 600 .nextcloud_oauth_client.json
177+
# Check database directory permissions
178+
ls -la /app/data/
181179

182180
# Ensure directory is writable
183-
chmod 755 $(dirname .nextcloud_oauth_client.json)
181+
chmod 755 /app/data
184182

185-
# If file doesn't exist, ensure directory is writable
186-
mkdir -p $(dirname .nextcloud_oauth_client.json)
187-
```
183+
# Check if database file exists and has correct permissions
184+
ls -la /app/data/tokens.db
185+
chmod 644 /app/data/tokens.db
188186

189-
For custom storage paths:
190-
```bash
191-
# Set custom path in .env
192-
NEXTCLOUD_OIDC_CLIENT_STORAGE=/path/to/custom/oauth_client.json
187+
# If running in Docker, ensure volume is mounted correctly
188+
docker compose logs mcp-oauth | grep -i "database\|sqlite"
189+
```
193190

194-
# Ensure directory exists and is writable
195-
mkdir -p $(dirname /path/to/custom/oauth_client.json)
196-
chmod 755 $(dirname /path/to/custom/oauth_client.json)
191+
**For Docker deployments**:
192+
Ensure the data directory is properly mounted as a volume:
193+
```yaml
194+
volumes:
195+
- ./data:/app/data # Persistent storage for SQLite database
197196
```
198197
199198
---

docs/troubleshooting.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,27 @@ A patch for the `user_oidc` app is required to fix Bearer token support. See [oa
136136

137137
---
138138

139-
### Issue: "Permission denied" when reading/writing OAuth client credentials file
139+
### Issue: "Permission denied" or "Database is locked" when accessing OAuth client storage
140140

141-
**Cause:** The server cannot access the OAuth client storage file (default: `.nextcloud_oauth_client.json`).
141+
**Cause:** The server cannot access the SQLite database for OAuth client credentials storage.
142142

143143
**Solution:**
144144

145145
```bash
146-
# Check file permissions
147-
ls -la .nextcloud_oauth_client.json
146+
# Check database directory permissions
147+
ls -la data/
148148

149-
# Fix file permissions (should be 0600 - owner read/write only)
150-
chmod 600 .nextcloud_oauth_client.json
149+
# Ensure directory is writable
150+
chmod 755 data/
151151

152-
# Ensure the directory is writable
153-
chmod 755 $(dirname .nextcloud_oauth_client.json)
152+
# Check if database file exists and has correct permissions
153+
ls -la data/tokens.db
154+
chmod 644 data/tokens.db
154155

155-
# If the file doesn't exist, ensure the directory is writable so it can be created
156-
mkdir -p $(dirname .nextcloud_oauth_client.json)
156+
# For Docker deployments, ensure volume is mounted correctly:
157+
# docker-compose.yml should have:
158+
# volumes:
159+
# - ./data:/app/data
157160
```
158161

159162
---

0 commit comments

Comments
 (0)