fix(astrolabe): Address reviewer feedback for hybrid mode

Addresses code review feedback:

Personal.php:
- Consolidate template variables to use camelCase consistently
- Remove duplicate snake_case variables (auth_mode, supports_app_passwords)
- Add oauthUrl to standard OAuth mode parameters (fixes fallback issue)
- Add requesttoken for CSRF protection

personal.php (template):
- Use null coalescing for safe variable access
- Reuse computed $isHybridMode variable instead of duplicate check
- Remove complex fallback URL logic (oauthUrl now always provided)

IdpTokenRefresher.php:
- Use Nextcloud's overwrite.cli.url config when available
- Fall back to http://localhost for container deployments
- Better supports non-containerized environments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-01-16 10:44:52 +01:00
co-authored by Claude Opus 4.5
parent 104a2ec9e3
commit 1cc460b0d8
3 changed files with 32 additions and 22 deletions
+12 -8
View File
@@ -38,19 +38,23 @@ class IdpTokenRefresher {
/**
* Get Nextcloud base URL for constructing internal OIDC endpoint URLs.
*
* IMPORTANT: This method returns the INTERNAL URL for server-to-server
* requests within the container. External URLs (like localhost:8080) won't
* work from inside the container since localhost refers to the container itself.
* Uses Nextcloud's CLI URL config if set (for non-containerized deployments),
* otherwise defaults to http://localhost for container environments.
*
* For internal requests, we always use http://localhost (port 80) since
* Nextcloud's web server is accessible at that address inside the container.
* Configuration priority:
* 1. overwrite.cli.url - Official Nextcloud system config for CLI operations
* 2. http://localhost - Default for Docker containers (web server on port 80)
*
* @return string Base URL for internal requests (e.g., "http://localhost")
*/
private function getNextcloudBaseUrl(): string {
// For internal requests within the container, always use http://localhost
// The web server is accessible at port 80 inside the container.
// External URLs like http://localhost:8080 won't work from inside the container.
// Check for overwrite.cli.url (used in non-containerized deployments)
$cliUrl = $this->config->getSystemValue('overwrite.cli.url', '');
if (!empty($cliUrl)) {
return rtrim($cliUrl, '/');
}
// Default: container environment with web server on localhost:80
return 'http://localhost';
}