{{ t('social', '.well-known/webfinger isn\'t properly set up!') }}
+
{{ t('social', 'Social needs the .well-known auto discovery to be properly set up. If Nextcloud is not installed in the root of the domain it is often the case, that Nextcloud can\'t configure this automatically. To use Social the admin of this Nextcloud instance needs to manually configure the .well-known redirects: ') }}{{ t('social', 'Open Documentation') }} ↗
+
{{ t('social', 'The social app requires to be setup by the server administrator.') }}
@@ -57,6 +62,9 @@
#social-spacer a:focus {
border: none !important;
}
+ a.external_link {
+ text-decoration: underline;
+ }
From bb100ea8790389d3d1d7383083dd05c0cf2ccfdb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julius=20H=C3=A4rtl?=
Date: Mon, 3 Dec 2018 11:04:25 +0100
Subject: [PATCH 2/5] Add setup check for .well-known urls
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Julius Härtl
---
lib/Controller/NavigationController.php | 72 +++++++++----------
lib/Service/CheckService.php | 92 +++++++++++++++++++++++++
src/App.vue | 19 ++---
3 files changed, 140 insertions(+), 43 deletions(-)
create mode 100644 lib/Service/CheckService.php
diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php
index 223f633f..f4c569fb 100644
--- a/lib/Controller/NavigationController.php
+++ b/lib/Controller/NavigationController.php
@@ -40,9 +40,11 @@ use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Service\ActivityPub\DocumentService;
use OCA\Social\Service\ActivityPub\PersonService;
use OCA\Social\Service\ActorService;
+use OCA\Social\Service\CheckService;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\MiscService;
use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
@@ -70,9 +72,6 @@ class NavigationController extends Controller {
/** @var IURLGenerator */
private $urlGenerator;
- /** @var IClientService */
- private $clientService;
-
/** @var ActorService */
private $actorService;
@@ -90,6 +89,9 @@ class NavigationController extends Controller {
/** @var PersonService */
private $personService;
+ /** @var CheckService */
+ private $checkService;
+
/**
* NavigationController constructor.
*
@@ -97,18 +99,18 @@ class NavigationController extends Controller {
* @param string $userId
* @param IConfig $config
* @param IURLGenerator $urlGenerator
- * @param IClientService $clientService
* @param ActorService $actorService
* @param DocumentService $documentService
* @param ConfigService $configService
* @param PersonService $personService
+ * @param CheckService $checkService
* @param MiscService $miscService
* @param IL10N $l10n
*/
public function __construct(
- IRequest $request, $userId, IConfig $config, IURLGenerator $urlGenerator, IClientService $clientService,
+ IRequest $request, $userId, IConfig $config, IURLGenerator $urlGenerator,
ActorService $actorService, DocumentService $documentService, ConfigService $configService,
- PersonService $personService,
+ PersonService $personService, CheckService $checkService,
MiscService $miscService, IL10N $l10n
) {
parent::__construct(Application::APP_NAME, $request);
@@ -116,7 +118,7 @@ class NavigationController extends Controller {
$this->userId = $userId;
$this->config = $config;
$this->urlGenerator = $urlGenerator;
- $this->clientService = $clientService;
+ $this->checkService = $checkService;
$this->actorService = $actorService;
$this->documentService = $documentService;
@@ -144,50 +146,40 @@ class NavigationController extends Controller {
'public' => false,
'firstrun' => false,
'setup' => false,
+ 'isAdmin' => \OC::$server->getGroupManager()->isAdmin($this->userId),
+ 'cliUrl' => $this->config->getSystemValue(
+ 'overwrite.cli.url', \OC::$server->getURLGenerator()
+ ->getBaseUrl()
+ )
]
];
+ $checks = $this->checkService->checkDefault();
+ $data['serverData']['checks'] = $checks;
+
try {
$data['serverData']['cloudAddress'] = $this->configService->getCloudAddress();
} catch (SocialAppConfigException $e) {
- $cloudAddress = rtrim(
- $this->config->getSystemValue('overwrite.cli.url', ''), '/'
- );
- $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
+ $cloudAddress = $this->setupCloudAddress();
if ($cloudAddress !== ''){
- if (!$frontControllerActive){
- $cloudAddress .= '/index.php';
- }
- $this->configService->setCloudAddress($cloudAddress);
$data['serverData']['cloudAddress'] = $cloudAddress;
} else {
$data['serverData']['setup'] = true;
- $data['serverData']['isAdmin'] = \OC::$server->getGroupManager()
- ->isAdmin($this->userId);
+
if ($data['serverData']['isAdmin']) {
$cloudAddress = $this->request->getParam('cloudAddress');
if ($cloudAddress !== null) {
$this->configService->setCloudAddress($cloudAddress);
} else {
- $data['serverData']['cliUrl'] = $this->config->getSystemValue(
- 'overwrite.cli.url', \OC::$server->getURLGenerator()
- ->getBaseUrl()
- );
-
return new TemplateResponse(Application::APP_NAME, 'main', $data);
}
}
}
}
- try {
- $url = $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . '/.well-known/webfinger';
- $response = $this->clientService->newClient()->get($url);
- } catch (\GuzzleHttp\Exception\ClientException $e) {
- $data['serverData']['error'] = $this->l10n->t('.well-known/webfinger isn\'t properly set up');
- $data['serverData']['setup'] = true;
- }
-
+ /*
+ * Create social user account if it doesn't exist yet
+ */
try {
$this->actorService->createActor($this->userId, $this->userId);
$data['serverData']['firstrun'] = true;
@@ -199,13 +191,23 @@ class NavigationController extends Controller {
// neither.
}
- $csp = new ContentSecurityPolicy();
- $csp->addAllowedImageDomain('*');
- $response = new TemplateResponse(Application::APP_NAME, 'main', $data);
- $response->setContentSecurityPolicy($csp);
- return $response;
+ return new TemplateResponse(Application::APP_NAME, 'main', $data);
}
+ private function setupCloudAddress(): string {
+ return '';
+ $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
+
+ $cloudAddress = rtrim($this->config->getSystemValue('overwrite.cli.url', ''), '/');
+ if ($cloudAddress !== '') {
+ if (!$frontControllerActive) {
+ $cloudAddress .= '/index.php';
+ }
+ $this->configService->setCloudAddress($cloudAddress);
+ return $cloudAddress;
+ }
+ return '';
+ }
/**
* Display the navigation page of the Social app.
diff --git a/lib/Service/CheckService.php b/lib/Service/CheckService.php
new file mode 100644
index 00000000..9c5ba7c3
--- /dev/null
+++ b/lib/Service/CheckService.php
@@ -0,0 +1,92 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Social\Service;
+
+
+use OCP\AppFramework\Http;
+use OCP\Http\Client\IClientService;
+use OCP\ICache;
+use OCP\IConfig;
+use OCP\IRequest;
+
+class CheckService {
+
+ private $cache;
+ private $config;
+
+ const CACHE_PREFIX = 'social_check_';
+
+
+ public function __construct(ICache $cache, IConfig $config, IClientService $clientService, IRequest $request) {
+ $this->cache = $cache;
+ $this->config = $config;
+ $this->clientService = $clientService;
+ $this->request = $request;
+ }
+
+ public function checkDefault(): array {
+ $checks = [];
+ $checks['wellknown'] = $this->checkWellKnown();
+
+ $success = true;
+ foreach ($checks as $check) {
+ if (!$check) {
+ $success = false;
+ }
+ }
+ return [
+ 'success' => $success,
+ 'checks' => $checks
+ ];
+ }
+ public function checkWellKnown(): bool {
+ $state = (bool) ($this->cache->get(self::CACHE_PREFIX . 'wellknown') === 'true');
+ if ($state === true) {
+ return true;
+ }
+ try {
+ $url = $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . '/.well-known/webfinger';
+ $response = $this->clientService->newClient()->get($url);
+ if ($response->getStatusCode() === Http::STATUS_OK) {
+ $this->cache->set(self::CACHE_PREFIX . 'wellknown', 'true', 3600);
+ return true;
+ }
+ } catch (\GuzzleHttp\Exception\ClientException $e) {
+ } catch (\Exception $e) {
+ }
+
+ try {
+ $url = \OC::$server->getURLGenerator()->getBaseUrl() . '/.well-known/webfinger';
+ $response = $this->clientService->newClient()->get($url);
+ if ($response->getStatusCode() === Http::STATUS_OK) {
+ $this->cache->set(self::CACHE_PREFIX . 'wellknown', 'true', 3600);
+ return true;
+ }
+ } catch (\GuzzleHttp\Exception\ClientException $e) {
+ } catch (\Exception $e) {
+ }
+ return false;
+ }
+
+}
diff --git a/src/App.vue b/src/App.vue
index 299d4c2e..56a362fc 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -4,10 +4,13 @@
-
-
-
+
+
{{ t('social', '.well-known/webfinger isn\'t properly set up!') }}
+
{{ t('social', 'Social needs the .well-known auto discovery to be properly set up. If Nextcloud is not installed in the root of the domain it is often the case, that Nextcloud can\'t configure this automatically. To use Social the admin of this Nextcloud instance needs to manually configure the .well-known redirects: ') }}{{ t('social', 'Open Documentation') }} ↗
+
+
@@ -21,13 +24,13 @@
required>
+
+
{{ t('social', '.well-known/webfinger isn\'t properly set up!') }}
+
{{ t('social', 'Social needs the .well-known auto discovery to be properly set up. If Nextcloud is not installed in the root of the domain it is often the case, that Nextcloud can\'t configure this automatically. To use Social the admin of this Nextcloud instance needs to manually configure the .well-known redirects: ') }}{{ t('social', 'Open Documentation') }} ↗
+
-
-
{{ t('social', 'Social app setup') }}
-
{{ t('social', '.well-known/webfinger isn\'t properly set up!') }}
-
{{ t('social', 'Social needs the .well-known auto discovery to be properly set up. If Nextcloud is not installed in the root of the domain it is often the case, that Nextcloud can\'t configure this automatically. To use Social the admin of this Nextcloud instance needs to manually configure the .well-known redirects: ') }}{{ t('social', 'Open Documentation') }} ↗
-
{{ t('social', 'The social app requires to be setup by the server administrator.') }}
From 03d02594603b0b42a405a9ca586641c22225feeb Mon Sep 17 00:00:00 2001
From: Jan-Christoph Borchardt
Date: Mon, 3 Dec 2018 12:27:55 +0100
Subject: [PATCH 3/5] Small wording fixes on the initial setup page
Signed-off-by: Jan-Christoph Borchardt
---
src/App.vue | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 56a362fc..029bbae2 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -6,8 +6,8 @@
{{ t('social', '.well-known/webfinger isn\'t properly set up!') }}
-
{{ t('social', 'Social needs the .well-known auto discovery to be properly set up. If Nextcloud is not installed in the root of the domain it is often the case, that Nextcloud can\'t configure this automatically. To use Social the admin of this Nextcloud instance needs to manually configure the .well-known redirects: ') }}{{ t('social', 'Open Documentation') }} ↗
+
{{ t('social', 'Social needs the .well-known automatic discovery to be properly set up. If Nextcloud is not installed in the root of the domain, it is often the case that Nextcloud can\'t configure this automatically. To use Social, the admin of this Nextcloud instance needs to manually configure the .well-known redirects: ') }}{{ t('social', 'Open documentation') }} ↗
@@ -16,7 +16,7 @@
{{ t('social', 'Social app setup') }}
-
{{ t('social', 'ActivityPub requires a fixed URL to make entries unique. Please configure a URL base. Note that this cannot be changed later without resetting the social app data.') }}
+
{{ t('social', 'ActivityPub requires a fixed domain to make entries unique. Please configure a domain base. Note that this can not be changed later without resetting the Social app.') }}
-
{{ t('social', 'The social app requires to be setup by the server administrator.') }}
+
{{ t('social', 'The Social app needs to be set up by the server administrator.') }}
{{ t('social', 'ActivityPub requires a fixed domain to make entries unique. Please configure a domain base. Note that this can not be changed later without resetting the Social app.') }}
+
{{ t('social', 'ActivityPub requires a fixed URL to make entries unique. Note that this can not be changed later without resetting the Social app.') }}