Files
nextcloud-mcp-server/third_party/astrolabe/templates/settings/error.php
T
Chris Coutinho 65c3f099fa feat(astrolabe): implement app password provisioning for multi-user background sync
Adds complete app password provisioning workflow for multi-user BasicAuth
deployments, allowing users to independently enable background sync by
generating and storing Nextcloud app passwords.

**New Components:**

Backend (PHP):
- CredentialsController: Validates and stores app passwords
  * Validates app password format and authenticity via OCS API
  * Stores encrypted passwords in oc_preferences
  * Provides status and credential management endpoints
- AstrolabeAdminSettings: Admin configuration page for MCP server URL
- AstrolabeAdminSettingsListener: Event listener for admin section
- Updated McpTokenStorage: Added background sync credential methods

Frontend:
- personalSettings.js: Form handling for app password entry
  * AJAX submission with error handling
  * Shows success/error notifications
  * Triggers page reload after successful save
- settings.css: Styling for settings pages
- Updated personal.php template: Two-option UI
  * Option 1: OAuth refresh token (future, not yet available)
  * Option 2: App password (works today, recommended)
  * Shows "Active" badge when provisioned
  * Displays credential type and provisioned timestamp

Routes:
- POST /api/v1/background-sync/credentials - Store app password
- GET /api/v1/background-sync/status - Get provisioning status
- DELETE /api/v1/background-sync/credentials - Revoke credentials
- GET /api/v1/background-sync/credentials/{userId} - Admin only

**Testing:**
- test_astrolabe_settings_buttons.py: Integration test for UI buttons

**Workflow:**
1. User generates app password in Nextcloud Security settings
2. User navigates to Astrolabe personal settings
3. User enters app password in "Option 2: App Password" form
4. Backend validates password via OCS API call
5. Password stored encrypted in oc_preferences
6. Page reloads showing "Active" badge with credential details
7. MCP server can now use stored password for background operations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 19:39:13 +01:00

52 lines
1.7 KiB
PHP

<?php
/**
* Error template for MCP Server UI settings.
*
* Displayed when the MCP server cannot be reached or returns an error.
*
* @var array $_ Template parameters
* @var string $_['error'] Error title
* @var string $_['details'] Error details/message
* @var string $_['server_url'] Configured server URL (optional)
* @var string $_['help_text'] Additional help text (optional)
*/
?>
<div class="mcp-settings-error">
<div class="notecard notecard-error">
<h3>
<span class="icon icon-error"></span>
<?php p($_['error'] ?? 'Error'); ?>
</h3>
<?php if (isset($_['details'])): ?>
<p><strong><?php p($l->t('Details:')); ?></strong></p>
<p><code><?php p($_['details']); ?></code></p>
<?php endif; ?>
<?php if (isset($_['server_url'])): ?>
<p><strong><?php p($l->t('Server URL:')); ?></strong></p>
<p><code><?php p($_['server_url']); ?></code></p>
<?php endif; ?>
<?php if (isset($_['help_text'])): ?>
<p class="mcp-help-text"><?php p($_['help_text']); ?></p>
<?php endif; ?>
<h4><?php p($l->t('Troubleshooting Steps:')); ?></h4>
<ol>
<li><?php p($l->t('Verify the MCP server is running and accessible')); ?></li>
<li><?php p($l->t('Check that mcp_server_url in config.php is correct')); ?></li>
<li><?php p($l->t('Ensure mcp_server_api_key matches the server configuration')); ?></li>
<li><?php p($l->t('Check firewall rules and network connectivity')); ?></li>
<li><?php p($l->t('Review MCP server logs for errors')); ?></li>
</ol>
<p>
<a href="https://github.com/cbcoutinho/nextcloud-mcp-server/blob/master/docs/ADR-018-nextcloud-php-app-for-settings-ui.md" target="_blank" class="button">
<?php p($l->t('View Documentation')); ?>
</a>
</p>
</div>
</div>