-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use new appstore API #1940
Use new appstore API #1940
Conversation
@LukasReschke, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975, @nickvergessen and @rullzer to be potential reviewers. |
@@ -674,20 +674,6 @@ | |||
'appstoreenabled' => true, | |||
|
|||
/** | |||
* The URL of the appstore to use. | |||
*/ | |||
'appstoreurl' => 'https://api.owncloud.com/v1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure on that. So the problem is there are a ton of people out there who actually have no idea what they are doing™️ and just copy the sample config file. I don't really look forward to have around 30 people asking why their appstore doesn't work anymore and because nobody fills out the issue template that's just a waste of time.
So we either have to rename that variable (suggestions welcome) or go with hard-coded for now. I'd be fine with hard-coded for the moment, especially since you also can't easily replace the certificate use for verification. (neither one could before)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point about renaming the value, that would relieve us from the need to migrate existing overrides. It's still probably better to keep it configurable for maintainability and flexibility purposes. As for certificate locations: should probably also be configurable but can be added later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to think about that a bit more. Especially since we also now have a proxy in place which would also be another config value.
$this->fileName = 'apps.json'; | ||
$this->endpointUrl = sprintf( | ||
'https://apps.nextcloud.com/api/v1/platform/%s/apps.json', | ||
substr(implode(\OC_Util::getVersion(), '.'), 0, 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why substr? looks dangerous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, pretty much, also this needs at least a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OC_Util::getVersion returns the version from config.php such as array(9, 2, 0, 4)
. But the appstore only takes 3 numbers and ignores the internal patch level.
That said, will add a comment. It's also tested at https://github.com/nextcloud/server/blob/ea32ef300c214c5af4a78f2650801bb856a03395/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, but substr(..., 0,5) will break with 11.0.0
which is 0,6 ...
and so on...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing just fyi: you need to pass Nextcloud versions, not ownCloud internal versions. Using 9.2.0 won't yield any compatible apps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing just fyi: you need to pass Nextcloud versions, not ownCloud internal versions. Using 9.2.0 won't yield any compatible apps
Well… It does 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we'll likely just bump that to 11 for 11 so that it then would request the right URL :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, but substr(..., 0,5) will break with 11.0.0 which is 0,6 ....
True. So let's just read the array elements on it's own.
return new Version(substr($matches[0][0], 2), substr($matches[0][1], 2)); | ||
break; | ||
default: | ||
throw new \Exception('Version cannot be parsed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably include the version string that can not be parsed
|
||
// Count the amount of =, if it is one then it's either maximum or minimum | ||
// version. If it is two then it is maximum and minimum. | ||
if (preg_match_all('/(?:>|<)(?:=|)[0-9.]+/', $versionSpec, $matches)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a regex to parse a simple version string is maybe a bit overkill. explode() and strpos() may be faster and easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
$x509 = new X509(); | ||
$x509->loadCA(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt')); | ||
$x509->loadX509($app['certificate']); | ||
if($x509->validateSignature() !== true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose CRL support will be added later on :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually let's just add that here as well and add tests for this.
'app' => 'core', | ||
] | ||
); | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for this? Should probably throw an exception with your logging string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same applies to the following lines
new \OC\App\AppStore\Fetcher\AppFetcher( | ||
\OC::$server->getAppDataDir('appstore'), | ||
\OC::$server->getHTTPClientService(), | ||
new \OC\AppFramework\Utility\TimeFactory(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just query the class from the server e.g. $server->query(\OC\AppFramework\Utility\TimeFactory::class)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naive question: Any advantage of doing so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If things change your code won't break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would go for the public interface however :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Querying the interface doesn't seem to work. But the other thing works. Replacing.
$params['category'] = $category; | ||
$params['appstoreEnabled'] = $this->config->getSystemValue('appstoreenabled', true) === true; | ||
$this->navigationManager->setActiveEntry('core_apps'); | ||
|
||
$templateResponse = new TemplateResponse($this->appName, 'apps', $params, 'user'); | ||
$policy = new ContentSecurityPolicy(); | ||
$policy->addAllowedImageDomain('https://apps.owncloud.com'); | ||
$policy->addAllowedImageDomain('*'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can actually use https instead of *
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will also use an image proxy. So we can limit even further. Just waiting for the domain :)
Ref #1939
$this->endpointUrl = sprintf( | ||
'https://apps.nextcloud.com/api/v1/platform/%s/apps.json', | ||
substr(implode(\OC_Util::getVersion(), '.'), 0, 5) | ||
'https://apps.nextcloud.com/api/v1/platform/%s.%s.%s/apps.json', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%d
since it's only numbers? 🙊
This change introduces the new appstore API in Nextcloud. Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
Otherwise this would break with 11.0.0 Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
These are only numbers. THX @nickvergessen Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
5848ac7
to
a685957
Compare
The other function doesn't work if the appstore is disabled Signed-off-by: Lukas Reschke <[email protected]>
Ready for review. Will also add some more tests. |
The static version is used nowhere in the code and just decreases coverage Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
Signed-off-by: Lukas Reschke <[email protected]>
Ok so. I have been playing with this for a while now and haven't hit weird errors yet. I'd say lets merge 👍 |
* @param array $groups (optional) when set, only these groups will have access to the app | ||
* @throws \Exception | ||
* @return void | ||
* | ||
* This function set an app as enabled in appconfig. | ||
*/ | ||
public static function enable($app, $groups = null) { | ||
public function enable($appId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this breaking change really required?
Can't you just make that change in the AppManager and leave the old static stuff as a wrapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well. This is private API and the usages in core have been adjusted. If someone relies on private API then they are to blame themselves. I'm not a fan of limiting myself just because some other people may do it majorly wrong. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also \OC\App\AppManager
does a ton of different stuff not related to the appstore at all… I don't really want to pull that into that class at the moment as well. (also since it's public API and thus the expectation is that it will work nearly forever)
lgtm |
* experimental apps where removed with 32cf661 (#1940) * fixes #2183 Signed-off-by: Morris Jobke <[email protected]>
Left over from a refactoring #1940 Signed-off-by: Morris Jobke <[email protected]>
Left over from a refactoring #1940 Signed-off-by: Morris Jobke <[email protected]>
This change introduces the new appstore API in Nextcloud.
Todo
Signed-off-by: Lukas Reschke [email protected]