You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 10 години
преди 9 години
преди 7 години
преди 7 години
преди 8 години
преди 9 години
преди 7 години
преди 8 години
преди 7 години
преди 8 години
преди 9 години
преди 7 години
преди 8 години
преди 7 години
преди 9 години
преди 9 години
преди 9 години
преди 10 години
преди 10 години
преди 9 години
преди 8 години
преди 8 години
преди 8 години
преди 9 години
преди 9 години
преди 9 години
Add code integrity check This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository. Furthermore, there is a basic implementation to display problems with the code integrity on the update screen. Code signing basically happens the following way: - There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates. - Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID. - The command generates a signature.json file of the following format: ```json { "hashes": { "/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d", "/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9" }, "certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----", "signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl" } ``` `hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`. Steps to do in other PRs, this is already a quite huge one: - Add nag screen in case the code check fails to ensure that administrators are aware of this. - Add code verification also to OCC upgrade and unify display code more. - Add enforced code verification to apps shipped from the appstore with a level of "official" - Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release - Add some developer documentation on how devs can request their own certificate - Check when installing ownCloud - Add support for CRLs to allow revoking certificates **Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature: ``` ➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt Successfully signed "core" ``` Then increase the version and you should see something like the following: ![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png) As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen. For packaging stable releases this requires the following additional steps as a last action before zipping: 1. Run `./occ integrity:sign-core` once 2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
преди 8 години
преди 9 години
преди 8 години
преди 9 години
преди 9 години
преди 9 години
Add public API to give developers the possibility to adjust the global CSP defaults Allows to inject something into the default content policy. This is for example useful when you're injecting Javascript code into a view belonging to another controller and cannot modify its Content-Security-Policy itself. Note that the adjustment is only applied to applications that use AppFramework controllers. To use this from your `app.php` use `\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy)`, $policy has to be of type `\OCP\AppFramework\Http\ContentSecurityPolicy`. To test this add something like the following into an `app.php` of any enabled app: ``` $manager = \OC::$server->getContentSecurityPolicyManager(); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFrameDomain('asdf'); $policy->addAllowedScriptDomain('yolo.com'); $policy->allowInlineScript(false); $manager->addDefaultPolicy($policy); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFontDomain('yolo.com'); $manager->addDefaultPolicy($policy); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFrameDomain('banana.com'); $manager->addDefaultPolicy($policy); ``` If you now open the files app the policy should be: ``` Content-Security-Policy:default-src 'none';script-src yolo.com 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src yolo.com 'self';connect-src 'self';media-src 'self';frame-src asdf banana.com 'self' ```
преди 8 години
преди 10 години
преди 10 години
преди 10 години
преди 9 години
преди 8 години
преди 9 години
преди 8 години
преди 9 години
преди 10 години
преди 6 години
преди 8 години
преди 10 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 8 години
преди 8 години
преди 8 години
преди 10 години
преди 10 години
преди 10 години
преди 6 години
преди 8 години
преди 8 години
преди 6 години
преди 6 години
преди 6 години
преди 6 години
Add code integrity check This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository. Furthermore, there is a basic implementation to display problems with the code integrity on the update screen. Code signing basically happens the following way: - There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates. - Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID. - The command generates a signature.json file of the following format: ```json { "hashes": { "/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d", "/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9" }, "certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----", "signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl" } ``` `hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`. Steps to do in other PRs, this is already a quite huge one: - Add nag screen in case the code check fails to ensure that administrators are aware of this. - Add code verification also to OCC upgrade and unify display code more. - Add enforced code verification to apps shipped from the appstore with a level of "official" - Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release - Add some developer documentation on how devs can request their own certificate - Check when installing ownCloud - Add support for CRLs to allow revoking certificates **Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature: ``` ➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt Successfully signed "core" ``` Then increase the version and you should see something like the following: ![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png) As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen. For packaging stable releases this requires the following additional steps as a last action before zipping: 1. Run `./occ integrity:sign-core` once 2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
преди 8 години
Add code integrity check This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository. Furthermore, there is a basic implementation to display problems with the code integrity on the update screen. Code signing basically happens the following way: - There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates. - Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID. - The command generates a signature.json file of the following format: ```json { "hashes": { "/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d", "/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9" }, "certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----", "signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl" } ``` `hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`. Steps to do in other PRs, this is already a quite huge one: - Add nag screen in case the code check fails to ensure that administrators are aware of this. - Add code verification also to OCC upgrade and unify display code more. - Add enforced code verification to apps shipped from the appstore with a level of "official" - Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release - Add some developer documentation on how devs can request their own certificate - Check when installing ownCloud - Add support for CRLs to allow revoking certificates **Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature: ``` ➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt Successfully signed "core" ``` Then increase the version and you should see something like the following: ![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png) As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen. For packaging stable releases this requires the following additional steps as a last action before zipping: 1. Run `./occ integrity:sign-core` once 2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
преди 8 години
Add code integrity check This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository. Furthermore, there is a basic implementation to display problems with the code integrity on the update screen. Code signing basically happens the following way: - There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates. - Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID. - The command generates a signature.json file of the following format: ```json { "hashes": { "/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d", "/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9" }, "certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----", "signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl" } ``` `hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`. Steps to do in other PRs, this is already a quite huge one: - Add nag screen in case the code check fails to ensure that administrators are aware of this. - Add code verification also to OCC upgrade and unify display code more. - Add enforced code verification to apps shipped from the appstore with a level of "official" - Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release - Add some developer documentation on how devs can request their own certificate - Check when installing ownCloud - Add support for CRLs to allow revoking certificates **Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature: ``` ➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt Successfully signed "core" ``` Then increase the version and you should see something like the following: ![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png) As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen. For packaging stable releases this requires the following additional steps as a last action before zipping: 1. Run `./occ integrity:sign-core` once 2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
преди 8 години
преди 6 години
преди 6 години
Add code integrity check This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository. Furthermore, there is a basic implementation to display problems with the code integrity on the update screen. Code signing basically happens the following way: - There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates. - Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID. - The command generates a signature.json file of the following format: ```json { "hashes": { "/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d", "/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9" }, "certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----", "signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl" } ``` `hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`. Steps to do in other PRs, this is already a quite huge one: - Add nag screen in case the code check fails to ensure that administrators are aware of this. - Add code verification also to OCC upgrade and unify display code more. - Add enforced code verification to apps shipped from the appstore with a level of "official" - Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release - Add some developer documentation on how devs can request their own certificate - Check when installing ownCloud - Add support for CRLs to allow revoking certificates **Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature: ``` ➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt Successfully signed "core" ``` Then increase the version and you should see something like the following: ![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png) As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen. For packaging stable releases this requires the following additional steps as a last action before zipping: 1. Run `./occ integrity:sign-core` once 2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
преди 8 години
преди 9 години
преди 9 години
преди 7 години
преди 7 години
преди 7 години
преди 9 години
преди 9 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 6 години
преди 8 години
преди 6 години
преди 9 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 8 години
преди 8 години
преди 8 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 8 години
преди 8 години
преди 8 години
преди 10 години
преди 10 години
преди 10 години
преди 9 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 9 години
преди 9 години
преди 9 години
преди 9 години
преди 9 години
преди 9 години
преди 9 години
преди 9 години
преди 9 години
преди 8 години
преди 9 години
преди 8 години
преди 9 години
преди 9 години
преди 9 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
Add code integrity check This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository. Furthermore, there is a basic implementation to display problems with the code integrity on the update screen. Code signing basically happens the following way: - There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates. - Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID. - The command generates a signature.json file of the following format: ```json { "hashes": { "/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d", "/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9" }, "certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----", "signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl" } ``` `hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`. Steps to do in other PRs, this is already a quite huge one: - Add nag screen in case the code check fails to ensure that administrators are aware of this. - Add code verification also to OCC upgrade and unify display code more. - Add enforced code verification to apps shipped from the appstore with a level of "official" - Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release - Add some developer documentation on how devs can request their own certificate - Check when installing ownCloud - Add support for CRLs to allow revoking certificates **Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature: ``` ➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt Successfully signed "core" ``` Then increase the version and you should see something like the following: ![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png) As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen. For packaging stable releases this requires the following additional steps as a last action before zipping: 1. Run `./occ integrity:sign-core` once 2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
преди 8 години
Add code integrity check This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository. Furthermore, there is a basic implementation to display problems with the code integrity on the update screen. Code signing basically happens the following way: - There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates. - Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID. - The command generates a signature.json file of the following format: ```json { "hashes": { "/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d", "/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9" }, "certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----", "signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl" } ``` `hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`. Steps to do in other PRs, this is already a quite huge one: - Add nag screen in case the code check fails to ensure that administrators are aware of this. - Add code verification also to OCC upgrade and unify display code more. - Add enforced code verification to apps shipped from the appstore with a level of "official" - Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release - Add some developer documentation on how devs can request their own certificate - Check when installing ownCloud - Add support for CRLs to allow revoking certificates **Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature: ``` ➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt Successfully signed "core" ``` Then increase the version and you should see something like the following: ![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png) As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen. For packaging stable releases this requires the following additional steps as a last action before zipping: 1. Run `./occ integrity:sign-core` once 2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
преди 8 години
Add code integrity check This PR implements the base foundation of the code signing and integrity check. In this PR implemented is the signing and verification logic, as well as commands to sign single apps or the core repository. Furthermore, there is a basic implementation to display problems with the code integrity on the update screen. Code signing basically happens the following way: - There is a ownCloud Root Certificate authority stored `resources/codesigning/root.crt` (in this PR I also ship the private key which we obviously need to change before a release :wink:). This certificate is not intended to be used for signing directly and only is used to sign new certificates. - Using the `integrity:sign-core` and `integrity:sign-app` commands developers can sign either the core release or a single app. The core release needs to be signed with a certificate that has a CN of `core`, apps need to be signed with a certificate that either has a CN of `core` (shipped apps!) or the AppID. - The command generates a signature.json file of the following format: ```json { "hashes": { "/filename.php": "2401fed2eea6f2c1027c482a633e8e25cd46701f811e2d2c10dc213fd95fa60e350bccbbebdccc73a042b1a2799f673fbabadc783284cc288e4f1a1eacb74e3d", "/lib/base.php": "55548cc16b457cd74241990cc9d3b72b6335f2e5f45eee95171da024087d114fcbc2effc3d5818a6d5d55f2ae960ab39fd0414d0c542b72a3b9e08eb21206dd9" }, "certificate": "-----BEGIN CERTIFICATE-----MIIBvTCCASagAwIBAgIUPvawyqJwCwYazcv7iz16TWxfeUMwDQYJKoZIhvcNAQEF\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTAx\nNDEzMTcxMFoXDTE2MTAxNDEzMTcxMFowEzERMA8GA1UEAwwIY29udGFjdHMwgZ8w\nDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANoQesGdCW0L2L+a2xITYipixkScrIpB\nkX5Snu3fs45MscDb61xByjBSlFgR4QI6McoCipPw4SUr28EaExVvgPSvqUjYLGps\nfiv0Cvgquzbx/X3mUcdk9LcFo1uWGtrTfkuXSKX41PnJGTr6RQWGIBd1V52q1qbC\nJKkfzyeMeuQfAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvF/KIhRMQ3tYTmgHWsiM\nwDMgIDb7iaHF0fS+/Nvo4PzoTO/trev6tMyjLbJ7hgdCpz/1sNzE11Cibf6V6dsz\njCE9invP368Xv0bTRObRqeSNsGogGl5ceAvR0c9BG+NRIKHcly3At3gLkS2791bC\niG+UxI/MNcWV0uJg9S63LF8=\n-----END CERTIFICATE-----", "signature": "U29tZVNpZ25lZERhdGFFeGFtcGxl" } ``` `hashes` is an array of all files in the folder with their corresponding SHA512 hashes (this is actually quite cheap to calculate), the `certificate` is the certificate used for signing. It has to be issued by the ownCloud Root Authority and it's CN needs to be permitted to perform the required action. The `signature` is then a signature of the `hashes` which can be verified using the `certificate`. Steps to do in other PRs, this is already a quite huge one: - Add nag screen in case the code check fails to ensure that administrators are aware of this. - Add code verification also to OCC upgrade and unify display code more. - Add enforced code verification to apps shipped from the appstore with a level of "official" - Add enfocrced code verification to apps shipped from the appstore that were already signed in a previous release - Add some developer documentation on how devs can request their own certificate - Check when installing ownCloud - Add support for CRLs to allow revoking certificates **Note:** The upgrade checks are only run when the instance has a defined release channel of `stable` (defined in `version.php`). If you want to test this, you need to change the channel thus and then generate the core signature: ``` ➜ master git:(add-integrity-checker) ✗ ./occ integrity:sign-core --privateKey=resources/codesigning/core.key --certificate=resources/codesigning/core.crt Successfully signed "core" ``` Then increase the version and you should see something like the following: ![2015-11-04_12-02-57](https://cloud.githubusercontent.com/assets/878997/10936336/6adb1d14-82ec-11e5-8f06-9a74801c9abf.png) As you can see a failed code check will not prevent the further update. It will instead just be a notice to the admin. In a next step we will add some nag screen. For packaging stable releases this requires the following additional steps as a last action before zipping: 1. Run `./occ integrity:sign-core` once 2. Run `./occ integrity:sign-app` _for each_ app. However, this can be simply automated using a simple foreach on the apps folder.
преди 8 години
Add public API to give developers the possibility to adjust the global CSP defaults Allows to inject something into the default content policy. This is for example useful when you're injecting Javascript code into a view belonging to another controller and cannot modify its Content-Security-Policy itself. Note that the adjustment is only applied to applications that use AppFramework controllers. To use this from your `app.php` use `\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy)`, $policy has to be of type `\OCP\AppFramework\Http\ContentSecurityPolicy`. To test this add something like the following into an `app.php` of any enabled app: ``` $manager = \OC::$server->getContentSecurityPolicyManager(); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFrameDomain('asdf'); $policy->addAllowedScriptDomain('yolo.com'); $policy->allowInlineScript(false); $manager->addDefaultPolicy($policy); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFontDomain('yolo.com'); $manager->addDefaultPolicy($policy); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFrameDomain('banana.com'); $manager->addDefaultPolicy($policy); ``` If you now open the files app the policy should be: ``` Content-Security-Policy:default-src 'none';script-src yolo.com 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src yolo.com 'self';connect-src 'self';media-src 'self';frame-src asdf banana.com 'self' ```
преди 8 години
Add public API to give developers the possibility to adjust the global CSP defaults Allows to inject something into the default content policy. This is for example useful when you're injecting Javascript code into a view belonging to another controller and cannot modify its Content-Security-Policy itself. Note that the adjustment is only applied to applications that use AppFramework controllers. To use this from your `app.php` use `\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy)`, $policy has to be of type `\OCP\AppFramework\Http\ContentSecurityPolicy`. To test this add something like the following into an `app.php` of any enabled app: ``` $manager = \OC::$server->getContentSecurityPolicyManager(); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFrameDomain('asdf'); $policy->addAllowedScriptDomain('yolo.com'); $policy->allowInlineScript(false); $manager->addDefaultPolicy($policy); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFontDomain('yolo.com'); $manager->addDefaultPolicy($policy); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFrameDomain('banana.com'); $manager->addDefaultPolicy($policy); ``` If you now open the files app the policy should be: ``` Content-Security-Policy:default-src 'none';script-src yolo.com 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src yolo.com 'self';connect-src 'self';media-src 'self';frame-src asdf banana.com 'self' ```
преди 8 години
Add public API to give developers the possibility to adjust the global CSP defaults Allows to inject something into the default content policy. This is for example useful when you're injecting Javascript code into a view belonging to another controller and cannot modify its Content-Security-Policy itself. Note that the adjustment is only applied to applications that use AppFramework controllers. To use this from your `app.php` use `\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy)`, $policy has to be of type `\OCP\AppFramework\Http\ContentSecurityPolicy`. To test this add something like the following into an `app.php` of any enabled app: ``` $manager = \OC::$server->getContentSecurityPolicyManager(); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFrameDomain('asdf'); $policy->addAllowedScriptDomain('yolo.com'); $policy->allowInlineScript(false); $manager->addDefaultPolicy($policy); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFontDomain('yolo.com'); $manager->addDefaultPolicy($policy); $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false); $policy->addAllowedFrameDomain('banana.com'); $manager->addDefaultPolicy($policy); ``` If you now open the files app the policy should be: ``` Content-Security-Policy:default-src 'none';script-src yolo.com 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src yolo.com 'self';connect-src 'self';media-src 'self';frame-src asdf banana.com 'self' ```
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 8 години
преди 7 години
преди 7 години
преди 7 години
преди 10 години
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
  5. *
  6. * @author Arne Hamann <kontakt+github@arne.email>
  7. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  8. * @author Bart Visscher <bartv@thisnet.nl>
  9. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  10. * @author Bernhard Reiter <ockham@raz.or.at>
  11. * @author Bjoern Schiessle <bjoern@schiessle.org>
  12. * @author Björn Schießle <bjoern@schiessle.org>
  13. * @author Christopher Schäpers <kondou@ts.unde.re>
  14. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  15. * @author Damjan Georgievski <gdamjan@gmail.com>
  16. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  17. * @author Georg Ehrke <oc.list@georgehrke.com>
  18. * @author Joas Schilling <coding@schilljs.com>
  19. * @author John Molakvoæ <skjnldsv@protonmail.com>
  20. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  21. * @author Julius Haertl <jus@bitgrid.net>
  22. * @author Julius Härtl <jus@bitgrid.net>
  23. * @author Lionel Elie Mamane <lionel@mamane.lu>
  24. * @author Lukas Reschke <lukas@statuscode.ch>
  25. * @author Maxence Lange <maxence@artificial-owl.com>
  26. * @author Michael Weimann <mail@michael-weimann.eu>
  27. * @author Morris Jobke <hey@morrisjobke.de>
  28. * @author Piotr Mrówczyński <mrow4a@yahoo.com>
  29. * @author Robin Appelman <robin@icewind.nl>
  30. * @author Robin McCorkell <robin@mccorkell.me.uk>
  31. * @author Roeland Jago Douma <roeland@famdouma.nl>
  32. * @author root <root@localhost.localdomain>
  33. * @author Thomas Müller <thomas.mueller@tmit.eu>
  34. * @author Thomas Tanghus <thomas@tanghus.net>
  35. * @author Tobia De Koninck <tobia@ledfan.be>
  36. * @author Vincent Petry <vincent@nextcloud.com>
  37. *
  38. * @license AGPL-3.0
  39. *
  40. * This code is free software: you can redistribute it and/or modify
  41. * it under the terms of the GNU Affero General Public License, version 3,
  42. * as published by the Free Software Foundation.
  43. *
  44. * This program is distributed in the hope that it will be useful,
  45. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  46. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  47. * GNU Affero General Public License for more details.
  48. *
  49. * You should have received a copy of the GNU Affero General Public License, version 3,
  50. * along with this program. If not, see <http://www.gnu.org/licenses/>
  51. *
  52. */
  53. namespace OC;
  54. use bantu\IniGetWrapper\IniGetWrapper;
  55. use OC\Accounts\AccountManager;
  56. use OC\App\AppManager;
  57. use OC\App\AppStore\Bundles\BundleFetcher;
  58. use OC\App\AppStore\Fetcher\AppFetcher;
  59. use OC\App\AppStore\Fetcher\CategoryFetcher;
  60. use OC\AppFramework\Bootstrap\Coordinator;
  61. use OC\AppFramework\Http\Request;
  62. use OC\AppFramework\Http\RequestId;
  63. use OC\AppFramework\Utility\TimeFactory;
  64. use OC\Authentication\Events\LoginFailed;
  65. use OC\Authentication\Listeners\LoginFailedListener;
  66. use OC\Authentication\Listeners\UserLoggedInListener;
  67. use OC\Authentication\LoginCredentials\Store;
  68. use OC\Authentication\Token\IProvider;
  69. use OC\Avatar\AvatarManager;
  70. use OC\Blurhash\Listener\GenerateBlurhashMetadata;
  71. use OC\Collaboration\Collaborators\GroupPlugin;
  72. use OC\Collaboration\Collaborators\MailPlugin;
  73. use OC\Collaboration\Collaborators\RemoteGroupPlugin;
  74. use OC\Collaboration\Collaborators\RemotePlugin;
  75. use OC\Collaboration\Collaborators\UserPlugin;
  76. use OC\Collaboration\Reference\ReferenceManager;
  77. use OC\Command\CronBus;
  78. use OC\Comments\ManagerFactory as CommentsManagerFactory;
  79. use OC\Contacts\ContactsMenu\ActionFactory;
  80. use OC\Contacts\ContactsMenu\ContactsStore;
  81. use OC\DB\Connection;
  82. use OC\DB\ConnectionAdapter;
  83. use OC\Diagnostics\EventLogger;
  84. use OC\Diagnostics\QueryLogger;
  85. use OC\Federation\CloudFederationFactory;
  86. use OC\Federation\CloudFederationProviderManager;
  87. use OC\Federation\CloudIdManager;
  88. use OC\Files\Config\MountProviderCollection;
  89. use OC\Files\Config\UserMountCache;
  90. use OC\Files\Config\UserMountCacheListener;
  91. use OC\Files\Lock\LockManager;
  92. use OC\Files\Mount\CacheMountProvider;
  93. use OC\Files\Mount\LocalHomeMountProvider;
  94. use OC\Files\Mount\ObjectHomeMountProvider;
  95. use OC\Files\Mount\ObjectStorePreviewCacheMountProvider;
  96. use OC\Files\Mount\RootMountProvider;
  97. use OC\Files\Node\HookConnector;
  98. use OC\Files\Node\LazyRoot;
  99. use OC\Files\Node\Root;
  100. use OC\Files\SetupManager;
  101. use OC\Files\Storage\StorageFactory;
  102. use OC\Files\Template\TemplateManager;
  103. use OC\Files\Type\Loader;
  104. use OC\Files\View;
  105. use OC\FilesMetadata\FilesMetadataManager;
  106. use OC\FullTextSearch\FullTextSearchManager;
  107. use OC\Http\Client\ClientService;
  108. use OC\Http\Client\NegativeDnsCache;
  109. use OC\IntegrityCheck\Checker;
  110. use OC\IntegrityCheck\Helpers\AppLocator;
  111. use OC\IntegrityCheck\Helpers\EnvironmentHelper;
  112. use OC\IntegrityCheck\Helpers\FileAccessHelper;
  113. use OC\KnownUser\KnownUserService;
  114. use OC\LDAP\NullLDAPProviderFactory;
  115. use OC\Lock\DBLockingProvider;
  116. use OC\Lock\MemcacheLockingProvider;
  117. use OC\Lock\NoopLockingProvider;
  118. use OC\Lockdown\LockdownManager;
  119. use OC\Log\LogFactory;
  120. use OC\Log\PsrLoggerAdapter;
  121. use OC\Mail\Mailer;
  122. use OC\Memcache\ArrayCache;
  123. use OC\Memcache\Factory;
  124. use OC\Notification\Manager;
  125. use OC\OCM\Model\OCMProvider;
  126. use OC\OCM\OCMDiscoveryService;
  127. use OC\OCS\DiscoveryService;
  128. use OC\Preview\GeneratorHelper;
  129. use OC\Preview\IMagickSupport;
  130. use OC\Preview\MimeIconProvider;
  131. use OC\Profile\ProfileManager;
  132. use OC\Profiler\Profiler;
  133. use OC\Remote\Api\ApiFactory;
  134. use OC\Remote\InstanceFactory;
  135. use OC\RichObjectStrings\Validator;
  136. use OC\Route\CachingRouter;
  137. use OC\Route\Router;
  138. use OC\Security\Bruteforce\Throttler;
  139. use OC\Security\CertificateManager;
  140. use OC\Security\CredentialsManager;
  141. use OC\Security\Crypto;
  142. use OC\Security\CSP\ContentSecurityPolicyManager;
  143. use OC\Security\CSP\ContentSecurityPolicyNonceManager;
  144. use OC\Security\CSRF\CsrfTokenManager;
  145. use OC\Security\CSRF\TokenStorage\SessionStorage;
  146. use OC\Security\Hasher;
  147. use OC\Security\RateLimiting\Limiter;
  148. use OC\Security\SecureRandom;
  149. use OC\Security\TrustedDomainHelper;
  150. use OC\Security\VerificationToken\VerificationToken;
  151. use OC\Session\CryptoWrapper;
  152. use OC\Settings\DeclarativeManager;
  153. use OC\SetupCheck\SetupCheckManager;
  154. use OC\Share20\ProviderFactory;
  155. use OC\Share20\ShareHelper;
  156. use OC\SpeechToText\SpeechToTextManager;
  157. use OC\SystemTag\ManagerFactory as SystemTagManagerFactory;
  158. use OC\Tagging\TagMapper;
  159. use OC\Talk\Broker;
  160. use OC\Teams\TeamManager;
  161. use OC\Template\JSCombiner;
  162. use OC\Translation\TranslationManager;
  163. use OC\User\AvailabilityCoordinator;
  164. use OC\User\DisplayNameCache;
  165. use OC\User\Listeners\BeforeUserDeletedListener;
  166. use OC\User\Listeners\UserChangedListener;
  167. use OC\User\Session;
  168. use OCA\Files_External\Service\BackendService;
  169. use OCA\Files_External\Service\GlobalStoragesService;
  170. use OCA\Files_External\Service\UserGlobalStoragesService;
  171. use OCA\Files_External\Service\UserStoragesService;
  172. use OCA\Theming\ImageManager;
  173. use OCA\Theming\ThemingDefaults;
  174. use OCA\Theming\Util;
  175. use OCP\Accounts\IAccountManager;
  176. use OCP\App\IAppManager;
  177. use OCP\AppFramework\Utility\ITimeFactory;
  178. use OCP\Authentication\LoginCredentials\IStore;
  179. use OCP\Authentication\Token\IProvider as OCPIProvider;
  180. use OCP\BackgroundJob\IJobList;
  181. use OCP\Collaboration\AutoComplete\IManager;
  182. use OCP\Collaboration\Reference\IReferenceManager;
  183. use OCP\Command\IBus;
  184. use OCP\Comments\ICommentsManager;
  185. use OCP\Contacts\ContactsMenu\IActionFactory;
  186. use OCP\Contacts\ContactsMenu\IContactsStore;
  187. use OCP\Defaults;
  188. use OCP\Diagnostics\IEventLogger;
  189. use OCP\Diagnostics\IQueryLogger;
  190. use OCP\Encryption\IFile;
  191. use OCP\Encryption\Keys\IStorage;
  192. use OCP\EventDispatcher\IEventDispatcher;
  193. use OCP\Federation\ICloudFederationFactory;
  194. use OCP\Federation\ICloudFederationProviderManager;
  195. use OCP\Federation\ICloudIdManager;
  196. use OCP\Files\Config\IMountProviderCollection;
  197. use OCP\Files\Config\IUserMountCache;
  198. use OCP\Files\IMimeTypeDetector;
  199. use OCP\Files\IMimeTypeLoader;
  200. use OCP\Files\IRootFolder;
  201. use OCP\Files\Lock\ILockManager;
  202. use OCP\Files\Mount\IMountManager;
  203. use OCP\Files\Storage\IStorageFactory;
  204. use OCP\Files\Template\ITemplateManager;
  205. use OCP\FilesMetadata\IFilesMetadataManager;
  206. use OCP\FullTextSearch\IFullTextSearchManager;
  207. use OCP\GlobalScale\IConfig;
  208. use OCP\Group\ISubAdmin;
  209. use OCP\Http\Client\IClientService;
  210. use OCP\IAppConfig;
  211. use OCP\IAvatarManager;
  212. use OCP\IBinaryFinder;
  213. use OCP\ICache;
  214. use OCP\ICacheFactory;
  215. use OCP\ICertificateManager;
  216. use OCP\IDateTimeFormatter;
  217. use OCP\IDateTimeZone;
  218. use OCP\IDBConnection;
  219. use OCP\IEventSourceFactory;
  220. use OCP\IGroupManager;
  221. use OCP\IInitialStateService;
  222. use OCP\IL10N;
  223. use OCP\ILogger;
  224. use OCP\INavigationManager;
  225. use OCP\IPhoneNumberUtil;
  226. use OCP\IPreview;
  227. use OCP\IRequest;
  228. use OCP\IRequestId;
  229. use OCP\ISearch;
  230. use OCP\IServerContainer;
  231. use OCP\ISession;
  232. use OCP\ITagManager;
  233. use OCP\ITempManager;
  234. use OCP\IURLGenerator;
  235. use OCP\IUserManager;
  236. use OCP\IUserSession;
  237. use OCP\L10N\IFactory;
  238. use OCP\LDAP\ILDAPProvider;
  239. use OCP\LDAP\ILDAPProviderFactory;
  240. use OCP\Lock\ILockingProvider;
  241. use OCP\Lockdown\ILockdownManager;
  242. use OCP\Log\ILogFactory;
  243. use OCP\Mail\IMailer;
  244. use OCP\OCM\IOCMDiscoveryService;
  245. use OCP\OCM\IOCMProvider;
  246. use OCP\Preview\IMimeIconProvider;
  247. use OCP\Profile\IProfileManager;
  248. use OCP\Profiler\IProfiler;
  249. use OCP\Remote\Api\IApiFactory;
  250. use OCP\Remote\IInstanceFactory;
  251. use OCP\RichObjectStrings\IValidator;
  252. use OCP\Route\IRouter;
  253. use OCP\Security\Bruteforce\IThrottler;
  254. use OCP\Security\IContentSecurityPolicyManager;
  255. use OCP\Security\ICredentialsManager;
  256. use OCP\Security\ICrypto;
  257. use OCP\Security\IHasher;
  258. use OCP\Security\ISecureRandom;
  259. use OCP\Security\ITrustedDomainHelper;
  260. use OCP\Security\RateLimiting\ILimiter;
  261. use OCP\Security\VerificationToken\IVerificationToken;
  262. use OCP\Settings\IDeclarativeManager;
  263. use OCP\SetupCheck\ISetupCheckManager;
  264. use OCP\Share\IProviderFactory;
  265. use OCP\Share\IShareHelper;
  266. use OCP\SpeechToText\ISpeechToTextManager;
  267. use OCP\SystemTag\ISystemTagManager;
  268. use OCP\SystemTag\ISystemTagObjectMapper;
  269. use OCP\Talk\IBroker;
  270. use OCP\Teams\ITeamManager;
  271. use OCP\Translation\ITranslationManager;
  272. use OCP\User\Events\BeforeUserDeletedEvent;
  273. use OCP\User\Events\BeforeUserLoggedInEvent;
  274. use OCP\User\Events\BeforeUserLoggedInWithCookieEvent;
  275. use OCP\User\Events\BeforeUserLoggedOutEvent;
  276. use OCP\User\Events\PostLoginEvent;
  277. use OCP\User\Events\UserChangedEvent;
  278. use OCP\User\Events\UserLoggedInEvent;
  279. use OCP\User\Events\UserLoggedInWithCookieEvent;
  280. use OCP\User\Events\UserLoggedOutEvent;
  281. use OCP\User\IAvailabilityCoordinator;
  282. use Psr\Container\ContainerExceptionInterface;
  283. use Psr\Container\ContainerInterface;
  284. use Psr\Log\LoggerInterface;
  285. /**
  286. * Class Server
  287. *
  288. * @package OC
  289. *
  290. * TODO: hookup all manager classes
  291. */
  292. class Server extends ServerContainer implements IServerContainer {
  293. /** @var string */
  294. private $webRoot;
  295. /**
  296. * @param string $webRoot
  297. * @param \OC\Config $config
  298. */
  299. public function __construct($webRoot, \OC\Config $config) {
  300. parent::__construct();
  301. $this->webRoot = $webRoot;
  302. // To find out if we are running from CLI or not
  303. $this->registerParameter('isCLI', \OC::$CLI);
  304. $this->registerParameter('serverRoot', \OC::$SERVERROOT);
  305. $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
  306. return $c;
  307. });
  308. $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
  309. return $c;
  310. });
  311. $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
  312. /** @deprecated 19.0.0 */
  313. $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
  314. $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
  315. /** @deprecated 19.0.0 */
  316. $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
  317. $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
  318. /** @deprecated 19.0.0 */
  319. $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
  320. $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
  321. /** @deprecated 19.0.0 */
  322. $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
  323. $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
  324. $this->registerAlias(ITemplateManager::class, TemplateManager::class);
  325. $this->registerAlias(IActionFactory::class, ActionFactory::class);
  326. $this->registerService(View::class, function (Server $c) {
  327. return new View();
  328. }, false);
  329. $this->registerService(IPreview::class, function (ContainerInterface $c) {
  330. return new PreviewManager(
  331. $c->get(\OCP\IConfig::class),
  332. $c->get(IRootFolder::class),
  333. new \OC\Preview\Storage\Root(
  334. $c->get(IRootFolder::class),
  335. $c->get(SystemConfig::class)
  336. ),
  337. $c->get(IEventDispatcher::class),
  338. $c->get(GeneratorHelper::class),
  339. $c->get(ISession::class)->get('user_id'),
  340. $c->get(Coordinator::class),
  341. $c->get(IServerContainer::class),
  342. $c->get(IBinaryFinder::class),
  343. $c->get(IMagickSupport::class)
  344. );
  345. });
  346. /** @deprecated 19.0.0 */
  347. $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
  348. $this->registerAlias(IMimeIconProvider::class, MimeIconProvider::class);
  349. $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
  350. return new \OC\Preview\Watcher(
  351. new \OC\Preview\Storage\Root(
  352. $c->get(IRootFolder::class),
  353. $c->get(SystemConfig::class)
  354. )
  355. );
  356. });
  357. $this->registerService(IProfiler::class, function (Server $c) {
  358. return new Profiler($c->get(SystemConfig::class));
  359. });
  360. $this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
  361. $view = new View();
  362. $util = new Encryption\Util(
  363. $view,
  364. $c->get(IUserManager::class),
  365. $c->get(IGroupManager::class),
  366. $c->get(\OCP\IConfig::class)
  367. );
  368. return new Encryption\Manager(
  369. $c->get(\OCP\IConfig::class),
  370. $c->get(LoggerInterface::class),
  371. $c->getL10N('core'),
  372. new View(),
  373. $util,
  374. new ArrayCache()
  375. );
  376. });
  377. /** @deprecated 19.0.0 */
  378. $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
  379. /** @deprecated 21.0.0 */
  380. $this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
  381. $this->registerService(IFile::class, function (ContainerInterface $c) {
  382. $util = new Encryption\Util(
  383. new View(),
  384. $c->get(IUserManager::class),
  385. $c->get(IGroupManager::class),
  386. $c->get(\OCP\IConfig::class)
  387. );
  388. return new Encryption\File(
  389. $util,
  390. $c->get(IRootFolder::class),
  391. $c->get(\OCP\Share\IManager::class)
  392. );
  393. });
  394. /** @deprecated 21.0.0 */
  395. $this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
  396. $this->registerService(IStorage::class, function (ContainerInterface $c) {
  397. $view = new View();
  398. $util = new Encryption\Util(
  399. $view,
  400. $c->get(IUserManager::class),
  401. $c->get(IGroupManager::class),
  402. $c->get(\OCP\IConfig::class)
  403. );
  404. return new Encryption\Keys\Storage(
  405. $view,
  406. $util,
  407. $c->get(ICrypto::class),
  408. $c->get(\OCP\IConfig::class)
  409. );
  410. });
  411. /** @deprecated 20.0.0 */
  412. $this->registerDeprecatedAlias('TagMapper', TagMapper::class);
  413. $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
  414. /** @deprecated 19.0.0 */
  415. $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
  416. $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
  417. /** @var \OCP\IConfig $config */
  418. $config = $c->get(\OCP\IConfig::class);
  419. $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
  420. return new $factoryClass($this);
  421. });
  422. $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
  423. return $c->get('SystemTagManagerFactory')->getManager();
  424. });
  425. /** @deprecated 19.0.0 */
  426. $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
  427. $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
  428. return $c->get('SystemTagManagerFactory')->getObjectMapper();
  429. });
  430. $this->registerService('RootFolder', function (ContainerInterface $c) {
  431. $manager = \OC\Files\Filesystem::getMountManager();
  432. $view = new View();
  433. /** @var IUserSession $userSession */
  434. $userSession = $c->get(IUserSession::class);
  435. $root = new Root(
  436. $manager,
  437. $view,
  438. $userSession->getUser(),
  439. $c->get(IUserMountCache::class),
  440. $this->get(LoggerInterface::class),
  441. $this->get(IUserManager::class),
  442. $this->get(IEventDispatcher::class),
  443. $this->get(ICacheFactory::class),
  444. );
  445. $previewConnector = new \OC\Preview\WatcherConnector(
  446. $root,
  447. $c->get(SystemConfig::class)
  448. );
  449. $previewConnector->connectWatcher();
  450. return $root;
  451. });
  452. $this->registerService(HookConnector::class, function (ContainerInterface $c) {
  453. return new HookConnector(
  454. $c->get(IRootFolder::class),
  455. new View(),
  456. $c->get(IEventDispatcher::class),
  457. $c->get(LoggerInterface::class)
  458. );
  459. });
  460. /** @deprecated 19.0.0 */
  461. $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
  462. $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
  463. return new LazyRoot(function () use ($c) {
  464. return $c->get('RootFolder');
  465. });
  466. });
  467. /** @deprecated 19.0.0 */
  468. $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
  469. /** @deprecated 19.0.0 */
  470. $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
  471. $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
  472. $this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
  473. return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
  474. });
  475. $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
  476. $groupManager = new \OC\Group\Manager(
  477. $this->get(IUserManager::class),
  478. $this->get(IEventDispatcher::class),
  479. $this->get(LoggerInterface::class),
  480. $this->get(ICacheFactory::class)
  481. );
  482. return $groupManager;
  483. });
  484. /** @deprecated 19.0.0 */
  485. $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
  486. $this->registerService(Store::class, function (ContainerInterface $c) {
  487. $session = $c->get(ISession::class);
  488. if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
  489. $tokenProvider = $c->get(IProvider::class);
  490. } else {
  491. $tokenProvider = null;
  492. }
  493. $logger = $c->get(LoggerInterface::class);
  494. return new Store($session, $logger, $tokenProvider);
  495. });
  496. $this->registerAlias(IStore::class, Store::class);
  497. $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
  498. $this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
  499. $this->registerService(\OC\User\Session::class, function (Server $c) {
  500. $manager = $c->get(IUserManager::class);
  501. $session = new \OC\Session\Memory('');
  502. $timeFactory = new TimeFactory();
  503. // Token providers might require a working database. This code
  504. // might however be called when Nextcloud is not yet setup.
  505. if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
  506. $provider = $c->get(IProvider::class);
  507. } else {
  508. $provider = null;
  509. }
  510. $userSession = new \OC\User\Session(
  511. $manager,
  512. $session,
  513. $timeFactory,
  514. $provider,
  515. $c->get(\OCP\IConfig::class),
  516. $c->get(ISecureRandom::class),
  517. $c->getLockdownManager(),
  518. $c->get(LoggerInterface::class),
  519. $c->get(IEventDispatcher::class)
  520. );
  521. /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
  522. $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
  523. \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
  524. });
  525. /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
  526. $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
  527. /** @var \OC\User\User $user */
  528. \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
  529. });
  530. /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
  531. $userSession->listen('\OC\User', 'preDelete', function ($user) {
  532. /** @var \OC\User\User $user */
  533. \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
  534. });
  535. /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
  536. $userSession->listen('\OC\User', 'postDelete', function ($user) {
  537. /** @var \OC\User\User $user */
  538. \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
  539. });
  540. $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
  541. /** @var \OC\User\User $user */
  542. \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
  543. });
  544. $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
  545. /** @var \OC\User\User $user */
  546. \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
  547. });
  548. $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
  549. \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
  550. /** @var IEventDispatcher $dispatcher */
  551. $dispatcher = $this->get(IEventDispatcher::class);
  552. $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
  553. });
  554. $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
  555. /** @var \OC\User\User $user */
  556. \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
  557. /** @var IEventDispatcher $dispatcher */
  558. $dispatcher = $this->get(IEventDispatcher::class);
  559. $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
  560. });
  561. $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
  562. /** @var IEventDispatcher $dispatcher */
  563. $dispatcher = $this->get(IEventDispatcher::class);
  564. $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
  565. });
  566. $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
  567. /** @var \OC\User\User $user */
  568. \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
  569. /** @var IEventDispatcher $dispatcher */
  570. $dispatcher = $this->get(IEventDispatcher::class);
  571. $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
  572. });
  573. $userSession->listen('\OC\User', 'logout', function ($user) {
  574. \OC_Hook::emit('OC_User', 'logout', []);
  575. /** @var IEventDispatcher $dispatcher */
  576. $dispatcher = $this->get(IEventDispatcher::class);
  577. $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
  578. });
  579. $userSession->listen('\OC\User', 'postLogout', function ($user) {
  580. /** @var IEventDispatcher $dispatcher */
  581. $dispatcher = $this->get(IEventDispatcher::class);
  582. $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
  583. });
  584. $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
  585. /** @var \OC\User\User $user */
  586. \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
  587. });
  588. return $userSession;
  589. });
  590. $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
  591. /** @deprecated 19.0.0 */
  592. $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
  593. $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
  594. $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
  595. /** @deprecated 19.0.0 */
  596. $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
  597. /** @deprecated 19.0.0 */
  598. $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
  599. $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
  600. $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
  601. return new \OC\SystemConfig($config);
  602. });
  603. /** @deprecated 19.0.0 */
  604. $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
  605. /** @deprecated 19.0.0 */
  606. $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
  607. $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
  608. $this->registerService(IFactory::class, function (Server $c) {
  609. return new \OC\L10N\Factory(
  610. $c->get(\OCP\IConfig::class),
  611. $c->getRequest(),
  612. $c->get(IUserSession::class),
  613. $c->get(ICacheFactory::class),
  614. \OC::$SERVERROOT
  615. );
  616. });
  617. /** @deprecated 19.0.0 */
  618. $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
  619. $this->registerAlias(IURLGenerator::class, URLGenerator::class);
  620. /** @deprecated 19.0.0 */
  621. $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
  622. /** @deprecated 19.0.0 */
  623. $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
  624. /** @deprecated 19.0.0 */
  625. $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
  626. $this->registerService(ICache::class, function ($c) {
  627. return new Cache\File();
  628. });
  629. /** @deprecated 19.0.0 */
  630. $this->registerDeprecatedAlias('UserCache', ICache::class);
  631. $this->registerService(Factory::class, function (Server $c) {
  632. $profiler = $c->get(IProfiler::class);
  633. $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
  634. $profiler,
  635. ArrayCache::class,
  636. ArrayCache::class,
  637. ArrayCache::class
  638. );
  639. /** @var \OCP\IConfig $config */
  640. $config = $c->get(\OCP\IConfig::class);
  641. if ($config->getSystemValueBool('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
  642. if (!$config->getSystemValueBool('log_query')) {
  643. try {
  644. $v = \OC_App::getAppVersions();
  645. } catch (\Doctrine\DBAL\Exception $e) {
  646. // Database service probably unavailable
  647. // Probably related to https://github.com/nextcloud/server/issues/37424
  648. return $arrayCacheFactory;
  649. }
  650. } else {
  651. // If the log_query is enabled, we can not get the app versions
  652. // as that does a query, which will be logged and the logging
  653. // depends on redis and here we are back again in the same function.
  654. $v = [
  655. 'log_query' => 'enabled',
  656. ];
  657. }
  658. $v['core'] = implode(',', \OC_Util::getVersion());
  659. $version = implode(',', $v);
  660. $instanceId = \OC_Util::getInstanceId();
  661. $path = \OC::$SERVERROOT;
  662. $prefix = md5($instanceId . '-' . $version . '-' . $path);
  663. return new \OC\Memcache\Factory($prefix,
  664. $c->get(LoggerInterface::class),
  665. $profiler,
  666. $config->getSystemValue('memcache.local', null),
  667. $config->getSystemValue('memcache.distributed', null),
  668. $config->getSystemValue('memcache.locking', null),
  669. $config->getSystemValueString('redis_log_file')
  670. );
  671. }
  672. return $arrayCacheFactory;
  673. });
  674. /** @deprecated 19.0.0 */
  675. $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
  676. $this->registerAlias(ICacheFactory::class, Factory::class);
  677. $this->registerService('RedisFactory', function (Server $c) {
  678. $systemConfig = $c->get(SystemConfig::class);
  679. return new RedisFactory($systemConfig, $c->get(IEventLogger::class));
  680. });
  681. $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
  682. $l10n = $this->get(IFactory::class)->get('lib');
  683. return new \OC\Activity\Manager(
  684. $c->getRequest(),
  685. $c->get(IUserSession::class),
  686. $c->get(\OCP\IConfig::class),
  687. $c->get(IValidator::class),
  688. $l10n
  689. );
  690. });
  691. /** @deprecated 19.0.0 */
  692. $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
  693. $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
  694. return new \OC\Activity\EventMerger(
  695. $c->getL10N('lib')
  696. );
  697. });
  698. $this->registerAlias(IValidator::class, Validator::class);
  699. $this->registerService(AvatarManager::class, function (Server $c) {
  700. return new AvatarManager(
  701. $c->get(IUserSession::class),
  702. $c->get(\OC\User\Manager::class),
  703. $c->getAppDataDir('avatar'),
  704. $c->getL10N('lib'),
  705. $c->get(LoggerInterface::class),
  706. $c->get(\OCP\IConfig::class),
  707. $c->get(IAccountManager::class),
  708. $c->get(KnownUserService::class)
  709. );
  710. });
  711. $this->registerAlias(IAvatarManager::class, AvatarManager::class);
  712. /** @deprecated 19.0.0 */
  713. $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
  714. $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
  715. $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
  716. $this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
  717. $this->registerService(\OC\Log::class, function (Server $c) {
  718. $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
  719. $factory = new LogFactory($c, $this->get(SystemConfig::class));
  720. $logger = $factory->get($logType);
  721. $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
  722. return new Log($logger, $this->get(SystemConfig::class), null, $registry);
  723. });
  724. $this->registerAlias(ILogger::class, \OC\Log::class);
  725. /** @deprecated 19.0.0 */
  726. $this->registerDeprecatedAlias('Logger', \OC\Log::class);
  727. // PSR-3 logger
  728. $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
  729. $this->registerService(ILogFactory::class, function (Server $c) {
  730. return new LogFactory($c, $this->get(SystemConfig::class));
  731. });
  732. $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
  733. /** @deprecated 19.0.0 */
  734. $this->registerDeprecatedAlias('JobList', IJobList::class);
  735. $this->registerService(Router::class, function (Server $c) {
  736. $cacheFactory = $c->get(ICacheFactory::class);
  737. if ($cacheFactory->isLocalCacheAvailable()) {
  738. $router = $c->resolve(CachingRouter::class);
  739. } else {
  740. $router = $c->resolve(Router::class);
  741. }
  742. return $router;
  743. });
  744. $this->registerAlias(IRouter::class, Router::class);
  745. /** @deprecated 19.0.0 */
  746. $this->registerDeprecatedAlias('Router', IRouter::class);
  747. $this->registerAlias(ISearch::class, Search::class);
  748. /** @deprecated 19.0.0 */
  749. $this->registerDeprecatedAlias('Search', ISearch::class);
  750. $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
  751. $config = $c->get(\OCP\IConfig::class);
  752. if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
  753. $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
  754. $c->get(AllConfig::class),
  755. $this->get(ICacheFactory::class),
  756. new \OC\AppFramework\Utility\TimeFactory()
  757. );
  758. } else {
  759. $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
  760. $c->get(AllConfig::class),
  761. $c->get(IDBConnection::class),
  762. new \OC\AppFramework\Utility\TimeFactory()
  763. );
  764. }
  765. return $backend;
  766. });
  767. $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
  768. /** @deprecated 19.0.0 */
  769. $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
  770. $this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
  771. $this->registerAlias(IVerificationToken::class, VerificationToken::class);
  772. $this->registerAlias(ICrypto::class, Crypto::class);
  773. /** @deprecated 19.0.0 */
  774. $this->registerDeprecatedAlias('Crypto', ICrypto::class);
  775. $this->registerAlias(IHasher::class, Hasher::class);
  776. /** @deprecated 19.0.0 */
  777. $this->registerDeprecatedAlias('Hasher', IHasher::class);
  778. $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
  779. /** @deprecated 19.0.0 */
  780. $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
  781. $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
  782. $this->registerService(Connection::class, function (Server $c) {
  783. $systemConfig = $c->get(SystemConfig::class);
  784. $factory = new \OC\DB\ConnectionFactory($systemConfig);
  785. $type = $systemConfig->getValue('dbtype', 'sqlite');
  786. if (!$factory->isValidType($type)) {
  787. throw new \OC\DatabaseException('Invalid database type');
  788. }
  789. $connection = $factory->getConnection($type, []);
  790. return $connection;
  791. });
  792. /** @deprecated 19.0.0 */
  793. $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
  794. $this->registerAlias(ICertificateManager::class, CertificateManager::class);
  795. $this->registerAlias(IClientService::class, ClientService::class);
  796. $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
  797. return new NegativeDnsCache(
  798. $c->get(ICacheFactory::class),
  799. );
  800. });
  801. $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
  802. $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
  803. return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
  804. });
  805. /** @deprecated 19.0.0 */
  806. $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
  807. $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
  808. $queryLogger = new QueryLogger();
  809. if ($c->get(SystemConfig::class)->getValue('debug', false)) {
  810. // In debug mode, module is being activated by default
  811. $queryLogger->activate();
  812. }
  813. return $queryLogger;
  814. });
  815. /** @deprecated 19.0.0 */
  816. $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
  817. /** @deprecated 19.0.0 */
  818. $this->registerDeprecatedAlias('TempManager', TempManager::class);
  819. $this->registerAlias(ITempManager::class, TempManager::class);
  820. $this->registerService(AppManager::class, function (ContainerInterface $c) {
  821. // TODO: use auto-wiring
  822. return new \OC\App\AppManager(
  823. $c->get(IUserSession::class),
  824. $c->get(\OCP\IConfig::class),
  825. $c->get(\OC\AppConfig::class),
  826. $c->get(IGroupManager::class),
  827. $c->get(ICacheFactory::class),
  828. $c->get(IEventDispatcher::class),
  829. $c->get(LoggerInterface::class),
  830. $c->get(IURLGenerator::class),
  831. );
  832. });
  833. /** @deprecated 19.0.0 */
  834. $this->registerDeprecatedAlias('AppManager', AppManager::class);
  835. $this->registerAlias(IAppManager::class, AppManager::class);
  836. $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
  837. /** @deprecated 19.0.0 */
  838. $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
  839. $this->registerService(IDateTimeFormatter::class, function (Server $c) {
  840. $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
  841. return new DateTimeFormatter(
  842. $c->get(IDateTimeZone::class)->getTimeZone(),
  843. $c->getL10N('lib', $language)
  844. );
  845. });
  846. /** @deprecated 19.0.0 */
  847. $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
  848. $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
  849. $mountCache = $c->get(UserMountCache::class);
  850. $listener = new UserMountCacheListener($mountCache);
  851. $listener->listen($c->get(IUserManager::class));
  852. return $mountCache;
  853. });
  854. /** @deprecated 19.0.0 */
  855. $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
  856. $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
  857. $loader = $c->get(IStorageFactory::class);
  858. $mountCache = $c->get(IUserMountCache::class);
  859. $eventLogger = $c->get(IEventLogger::class);
  860. $manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
  861. // builtin providers
  862. $config = $c->get(\OCP\IConfig::class);
  863. $logger = $c->get(LoggerInterface::class);
  864. $manager->registerProvider(new CacheMountProvider($config));
  865. $manager->registerHomeProvider(new LocalHomeMountProvider());
  866. $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
  867. $manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
  868. $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
  869. return $manager;
  870. });
  871. /** @deprecated 19.0.0 */
  872. $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
  873. /** @deprecated 20.0.0 */
  874. $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
  875. $this->registerService(IBus::class, function (ContainerInterface $c) {
  876. $busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
  877. if ($busClass) {
  878. [$app, $class] = explode('::', $busClass, 2);
  879. if ($c->get(IAppManager::class)->isInstalled($app)) {
  880. \OC_App::loadApp($app);
  881. return $c->get($class);
  882. } else {
  883. throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
  884. }
  885. } else {
  886. $jobList = $c->get(IJobList::class);
  887. return new CronBus($jobList);
  888. }
  889. });
  890. $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
  891. /** @deprecated 20.0.0 */
  892. $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
  893. $this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
  894. /** @deprecated 19.0.0 */
  895. $this->registerDeprecatedAlias('Throttler', Throttler::class);
  896. $this->registerAlias(IThrottler::class, Throttler::class);
  897. $this->registerService(\OC\Security\Bruteforce\Backend\IBackend::class, function ($c) {
  898. $config = $c->get(\OCP\IConfig::class);
  899. if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
  900. $backend = $c->get(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class);
  901. } else {
  902. $backend = $c->get(\OC\Security\Bruteforce\Backend\DatabaseBackend::class);
  903. }
  904. return $backend;
  905. });
  906. $this->registerDeprecatedAlias('IntegrityCodeChecker', Checker::class);
  907. $this->registerService(Checker::class, function (ContainerInterface $c) {
  908. // IConfig and IAppManager requires a working database. This code
  909. // might however be called when ownCloud is not yet setup.
  910. if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
  911. $config = $c->get(\OCP\IConfig::class);
  912. $appConfig = $c->get(\OCP\IAppConfig::class);
  913. $appManager = $c->get(IAppManager::class);
  914. } else {
  915. $config = $appConfig = $appManager = null;
  916. }
  917. return new Checker(
  918. new EnvironmentHelper(),
  919. new FileAccessHelper(),
  920. new AppLocator(),
  921. $config,
  922. $appConfig,
  923. $c->get(ICacheFactory::class),
  924. $appManager,
  925. $c->get(IMimeTypeDetector::class)
  926. );
  927. });
  928. $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
  929. if (isset($this['urlParams'])) {
  930. $urlParams = $this['urlParams'];
  931. } else {
  932. $urlParams = [];
  933. }
  934. if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
  935. && in_array('fakeinput', stream_get_wrappers())
  936. ) {
  937. $stream = 'fakeinput://data';
  938. } else {
  939. $stream = 'php://input';
  940. }
  941. return new Request(
  942. [
  943. 'get' => $_GET,
  944. 'post' => $_POST,
  945. 'files' => $_FILES,
  946. 'server' => $_SERVER,
  947. 'env' => $_ENV,
  948. 'cookies' => $_COOKIE,
  949. 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
  950. ? $_SERVER['REQUEST_METHOD']
  951. : '',
  952. 'urlParams' => $urlParams,
  953. ],
  954. $this->get(IRequestId::class),
  955. $this->get(\OCP\IConfig::class),
  956. $this->get(CsrfTokenManager::class),
  957. $stream
  958. );
  959. });
  960. /** @deprecated 19.0.0 */
  961. $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
  962. $this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
  963. return new RequestId(
  964. $_SERVER['UNIQUE_ID'] ?? '',
  965. $this->get(ISecureRandom::class)
  966. );
  967. });
  968. $this->registerService(IMailer::class, function (Server $c) {
  969. return new Mailer(
  970. $c->get(\OCP\IConfig::class),
  971. $c->get(LoggerInterface::class),
  972. $c->get(Defaults::class),
  973. $c->get(IURLGenerator::class),
  974. $c->getL10N('lib'),
  975. $c->get(IEventDispatcher::class),
  976. $c->get(IFactory::class)
  977. );
  978. });
  979. /** @deprecated 19.0.0 */
  980. $this->registerDeprecatedAlias('Mailer', IMailer::class);
  981. /** @deprecated 21.0.0 */
  982. $this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
  983. $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
  984. $config = $c->get(\OCP\IConfig::class);
  985. $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
  986. if (is_null($factoryClass) || !class_exists($factoryClass)) {
  987. return new NullLDAPProviderFactory($this);
  988. }
  989. /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
  990. return new $factoryClass($this);
  991. });
  992. $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
  993. $factory = $c->get(ILDAPProviderFactory::class);
  994. return $factory->getLDAPProvider();
  995. });
  996. $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
  997. $ini = $c->get(IniGetWrapper::class);
  998. $config = $c->get(\OCP\IConfig::class);
  999. $ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
  1000. if ($config->getSystemValueBool('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
  1001. /** @var \OC\Memcache\Factory $memcacheFactory */
  1002. $memcacheFactory = $c->get(ICacheFactory::class);
  1003. $memcache = $memcacheFactory->createLocking('lock');
  1004. if (!($memcache instanceof \OC\Memcache\NullCache)) {
  1005. $timeFactory = $c->get(ITimeFactory::class);
  1006. return new MemcacheLockingProvider($memcache, $timeFactory, $ttl);
  1007. }
  1008. return new DBLockingProvider(
  1009. $c->get(IDBConnection::class),
  1010. new TimeFactory(),
  1011. $ttl,
  1012. !\OC::$CLI
  1013. );
  1014. }
  1015. return new NoopLockingProvider();
  1016. });
  1017. /** @deprecated 19.0.0 */
  1018. $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
  1019. $this->registerService(ILockManager::class, function (Server $c): LockManager {
  1020. return new LockManager();
  1021. });
  1022. $this->registerAlias(ILockdownManager::class, 'LockdownManager');
  1023. $this->registerService(SetupManager::class, function ($c) {
  1024. // create the setupmanager through the mount manager to resolve the cyclic dependency
  1025. return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
  1026. });
  1027. $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
  1028. /** @deprecated 19.0.0 */
  1029. $this->registerDeprecatedAlias('MountManager', IMountManager::class);
  1030. $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
  1031. return new \OC\Files\Type\Detection(
  1032. $c->get(IURLGenerator::class),
  1033. $c->get(LoggerInterface::class),
  1034. \OC::$configDir,
  1035. \OC::$SERVERROOT . '/resources/config/'
  1036. );
  1037. });
  1038. /** @deprecated 19.0.0 */
  1039. $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
  1040. $this->registerAlias(IMimeTypeLoader::class, Loader::class);
  1041. /** @deprecated 19.0.0 */
  1042. $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
  1043. $this->registerService(BundleFetcher::class, function () {
  1044. return new BundleFetcher($this->getL10N('lib'));
  1045. });
  1046. $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
  1047. /** @deprecated 19.0.0 */
  1048. $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
  1049. $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
  1050. $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
  1051. $manager->registerCapability(function () use ($c) {
  1052. return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
  1053. });
  1054. $manager->registerCapability(function () use ($c) {
  1055. return $c->get(\OC\Security\Bruteforce\Capabilities::class);
  1056. });
  1057. return $manager;
  1058. });
  1059. /** @deprecated 19.0.0 */
  1060. $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
  1061. $this->registerService(ICommentsManager::class, function (Server $c) {
  1062. $config = $c->get(\OCP\IConfig::class);
  1063. $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
  1064. /** @var \OCP\Comments\ICommentsManagerFactory $factory */
  1065. $factory = new $factoryClass($this);
  1066. $manager = $factory->getManager();
  1067. $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
  1068. $manager = $c->get(IUserManager::class);
  1069. $userDisplayName = $manager->getDisplayName($id);
  1070. if ($userDisplayName === null) {
  1071. $l = $c->get(IFactory::class)->get('core');
  1072. return $l->t('Unknown account');
  1073. }
  1074. return $userDisplayName;
  1075. });
  1076. return $manager;
  1077. });
  1078. /** @deprecated 19.0.0 */
  1079. $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
  1080. $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
  1081. $this->registerService('ThemingDefaults', function (Server $c) {
  1082. try {
  1083. $classExists = class_exists('OCA\Theming\ThemingDefaults');
  1084. } catch (\OCP\AutoloadNotAllowedException $e) {
  1085. // App disabled or in maintenance mode
  1086. $classExists = false;
  1087. }
  1088. if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
  1089. $imageManager = new ImageManager(
  1090. $c->get(\OCP\IConfig::class),
  1091. $c->getAppDataDir('theming'),
  1092. $c->get(IURLGenerator::class),
  1093. $this->get(ICacheFactory::class),
  1094. $this->get(LoggerInterface::class),
  1095. $this->get(ITempManager::class)
  1096. );
  1097. return new ThemingDefaults(
  1098. $c->get(\OCP\IConfig::class),
  1099. $c->getL10N('theming'),
  1100. $c->get(IUserSession::class),
  1101. $c->get(IURLGenerator::class),
  1102. $c->get(ICacheFactory::class),
  1103. new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
  1104. $imageManager,
  1105. $c->get(IAppManager::class),
  1106. $c->get(INavigationManager::class)
  1107. );
  1108. }
  1109. return new \OC_Defaults();
  1110. });
  1111. $this->registerService(JSCombiner::class, function (Server $c) {
  1112. return new JSCombiner(
  1113. $c->getAppDataDir('js'),
  1114. $c->get(IURLGenerator::class),
  1115. $this->get(ICacheFactory::class),
  1116. $c->get(SystemConfig::class),
  1117. $c->get(LoggerInterface::class)
  1118. );
  1119. });
  1120. $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
  1121. $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
  1122. // FIXME: Instantiated here due to cyclic dependency
  1123. $request = new Request(
  1124. [
  1125. 'get' => $_GET,
  1126. 'post' => $_POST,
  1127. 'files' => $_FILES,
  1128. 'server' => $_SERVER,
  1129. 'env' => $_ENV,
  1130. 'cookies' => $_COOKIE,
  1131. 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
  1132. ? $_SERVER['REQUEST_METHOD']
  1133. : null,
  1134. ],
  1135. $c->get(IRequestId::class),
  1136. $c->get(\OCP\IConfig::class)
  1137. );
  1138. return new CryptoWrapper(
  1139. $c->get(\OCP\IConfig::class),
  1140. $c->get(ICrypto::class),
  1141. $c->get(ISecureRandom::class),
  1142. $request
  1143. );
  1144. });
  1145. /** @deprecated 19.0.0 */
  1146. $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
  1147. $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
  1148. return new SessionStorage($c->get(ISession::class));
  1149. });
  1150. $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
  1151. /** @deprecated 19.0.0 */
  1152. $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
  1153. $this->registerService(IProviderFactory::class, function (ContainerInterface $c) {
  1154. $config = $c->get(\OCP\IConfig::class);
  1155. $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
  1156. /** @var \OCP\Share\IProviderFactory $factory */
  1157. return new $factoryClass($this);
  1158. });
  1159. $this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class);
  1160. /** @deprecated 19.0.0 */
  1161. $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
  1162. $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
  1163. $instance = new Collaboration\Collaborators\Search($c);
  1164. // register default plugins
  1165. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
  1166. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
  1167. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
  1168. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
  1169. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
  1170. return $instance;
  1171. });
  1172. /** @deprecated 19.0.0 */
  1173. $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
  1174. $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
  1175. $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
  1176. $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
  1177. $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
  1178. $this->registerAlias(IReferenceManager::class, ReferenceManager::class);
  1179. $this->registerAlias(ITeamManager::class, TeamManager::class);
  1180. $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
  1181. $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
  1182. $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
  1183. return new \OC\Files\AppData\Factory(
  1184. $c->get(IRootFolder::class),
  1185. $c->get(SystemConfig::class)
  1186. );
  1187. });
  1188. $this->registerService('LockdownManager', function (ContainerInterface $c) {
  1189. return new LockdownManager(function () use ($c) {
  1190. return $c->get(ISession::class);
  1191. });
  1192. });
  1193. $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
  1194. return new DiscoveryService(
  1195. $c->get(ICacheFactory::class),
  1196. $c->get(IClientService::class)
  1197. );
  1198. });
  1199. $this->registerAlias(IOCMDiscoveryService::class, OCMDiscoveryService::class);
  1200. $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
  1201. return new CloudIdManager(
  1202. $c->get(\OCP\Contacts\IManager::class),
  1203. $c->get(IURLGenerator::class),
  1204. $c->get(IUserManager::class),
  1205. $c->get(ICacheFactory::class),
  1206. $c->get(IEventDispatcher::class),
  1207. );
  1208. });
  1209. $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
  1210. $this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
  1211. return new CloudFederationProviderManager(
  1212. $c->get(\OCP\IConfig::class),
  1213. $c->get(IAppManager::class),
  1214. $c->get(IClientService::class),
  1215. $c->get(ICloudIdManager::class),
  1216. $c->get(IOCMDiscoveryService::class),
  1217. $c->get(LoggerInterface::class)
  1218. );
  1219. });
  1220. $this->registerService(ICloudFederationFactory::class, function (Server $c) {
  1221. return new CloudFederationFactory();
  1222. });
  1223. $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
  1224. /** @deprecated 19.0.0 */
  1225. $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
  1226. $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
  1227. $this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
  1228. /** @deprecated 19.0.0 */
  1229. $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
  1230. $this->registerService(Defaults::class, function (Server $c) {
  1231. return new Defaults(
  1232. $c->getThemingDefaults()
  1233. );
  1234. });
  1235. /** @deprecated 19.0.0 */
  1236. $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
  1237. $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
  1238. return $c->get(\OCP\IUserSession::class)->getSession();
  1239. }, false);
  1240. $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
  1241. return new ShareHelper(
  1242. $c->get(\OCP\Share\IManager::class)
  1243. );
  1244. });
  1245. $this->registerService(Installer::class, function (ContainerInterface $c) {
  1246. return new Installer(
  1247. $c->get(AppFetcher::class),
  1248. $c->get(IClientService::class),
  1249. $c->get(ITempManager::class),
  1250. $c->get(LoggerInterface::class),
  1251. $c->get(\OCP\IConfig::class),
  1252. \OC::$CLI
  1253. );
  1254. });
  1255. $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
  1256. return new ApiFactory($c->get(IClientService::class));
  1257. });
  1258. $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
  1259. $memcacheFactory = $c->get(ICacheFactory::class);
  1260. return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
  1261. });
  1262. $this->registerAlias(IContactsStore::class, ContactsStore::class);
  1263. $this->registerAlias(IAccountManager::class, AccountManager::class);
  1264. $this->registerAlias(IStorageFactory::class, StorageFactory::class);
  1265. $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
  1266. $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
  1267. $this->registerAlias(IFilesMetadataManager::class, FilesMetadataManager::class);
  1268. $this->registerAlias(ISubAdmin::class, SubAdmin::class);
  1269. $this->registerAlias(IInitialStateService::class, InitialStateService::class);
  1270. $this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
  1271. $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
  1272. $this->registerAlias(IBroker::class, Broker::class);
  1273. $this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
  1274. $this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
  1275. $this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
  1276. $this->registerAlias(ITranslationManager::class, TranslationManager::class);
  1277. $this->registerAlias(ISpeechToTextManager::class, SpeechToTextManager::class);
  1278. $this->registerAlias(IEventSourceFactory::class, EventSourceFactory::class);
  1279. $this->registerAlias(\OCP\TextProcessing\IManager::class, \OC\TextProcessing\Manager::class);
  1280. $this->registerAlias(\OCP\TextToImage\IManager::class, \OC\TextToImage\Manager::class);
  1281. $this->registerAlias(ILimiter::class, Limiter::class);
  1282. $this->registerAlias(IPhoneNumberUtil::class, PhoneNumberUtil::class);
  1283. $this->registerAlias(IOCMProvider::class, OCMProvider::class);
  1284. $this->registerAlias(ISetupCheckManager::class, SetupCheckManager::class);
  1285. $this->registerAlias(IProfileManager::class, ProfileManager::class);
  1286. $this->registerAlias(IAvailabilityCoordinator::class, AvailabilityCoordinator::class);
  1287. $this->registerAlias(IDeclarativeManager::class, DeclarativeManager::class);
  1288. $this->connectDispatcher();
  1289. }
  1290. public function boot() {
  1291. /** @var HookConnector $hookConnector */
  1292. $hookConnector = $this->get(HookConnector::class);
  1293. $hookConnector->viewToNode();
  1294. }
  1295. /**
  1296. * @return \OCP\Calendar\IManager
  1297. * @deprecated 20.0.0
  1298. */
  1299. public function getCalendarManager() {
  1300. return $this->get(\OC\Calendar\Manager::class);
  1301. }
  1302. /**
  1303. * @return \OCP\Calendar\Resource\IManager
  1304. * @deprecated 20.0.0
  1305. */
  1306. public function getCalendarResourceBackendManager() {
  1307. return $this->get(\OC\Calendar\Resource\Manager::class);
  1308. }
  1309. /**
  1310. * @return \OCP\Calendar\Room\IManager
  1311. * @deprecated 20.0.0
  1312. */
  1313. public function getCalendarRoomBackendManager() {
  1314. return $this->get(\OC\Calendar\Room\Manager::class);
  1315. }
  1316. private function connectDispatcher(): void {
  1317. /** @var IEventDispatcher $eventDispatcher */
  1318. $eventDispatcher = $this->get(IEventDispatcher::class);
  1319. $eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
  1320. $eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
  1321. $eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
  1322. $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
  1323. FilesMetadataManager::loadListeners($eventDispatcher);
  1324. GenerateBlurhashMetadata::loadListeners($eventDispatcher);
  1325. }
  1326. /**
  1327. * @return \OCP\Contacts\IManager
  1328. * @deprecated 20.0.0
  1329. */
  1330. public function getContactsManager() {
  1331. return $this->get(\OCP\Contacts\IManager::class);
  1332. }
  1333. /**
  1334. * @return \OC\Encryption\Manager
  1335. * @deprecated 20.0.0
  1336. */
  1337. public function getEncryptionManager() {
  1338. return $this->get(\OCP\Encryption\IManager::class);
  1339. }
  1340. /**
  1341. * @return \OC\Encryption\File
  1342. * @deprecated 20.0.0
  1343. */
  1344. public function getEncryptionFilesHelper() {
  1345. return $this->get(IFile::class);
  1346. }
  1347. /**
  1348. * @return \OCP\Encryption\Keys\IStorage
  1349. * @deprecated 20.0.0
  1350. */
  1351. public function getEncryptionKeyStorage() {
  1352. return $this->get(IStorage::class);
  1353. }
  1354. /**
  1355. * The current request object holding all information about the request
  1356. * currently being processed is returned from this method.
  1357. * In case the current execution was not initiated by a web request null is returned
  1358. *
  1359. * @return \OCP\IRequest
  1360. * @deprecated 20.0.0
  1361. */
  1362. public function getRequest() {
  1363. return $this->get(IRequest::class);
  1364. }
  1365. /**
  1366. * Returns the preview manager which can create preview images for a given file
  1367. *
  1368. * @return IPreview
  1369. * @deprecated 20.0.0
  1370. */
  1371. public function getPreviewManager() {
  1372. return $this->get(IPreview::class);
  1373. }
  1374. /**
  1375. * Returns the tag manager which can get and set tags for different object types
  1376. *
  1377. * @see \OCP\ITagManager::load()
  1378. * @return ITagManager
  1379. * @deprecated 20.0.0
  1380. */
  1381. public function getTagManager() {
  1382. return $this->get(ITagManager::class);
  1383. }
  1384. /**
  1385. * Returns the system-tag manager
  1386. *
  1387. * @return ISystemTagManager
  1388. *
  1389. * @since 9.0.0
  1390. * @deprecated 20.0.0
  1391. */
  1392. public function getSystemTagManager() {
  1393. return $this->get(ISystemTagManager::class);
  1394. }
  1395. /**
  1396. * Returns the system-tag object mapper
  1397. *
  1398. * @return ISystemTagObjectMapper
  1399. *
  1400. * @since 9.0.0
  1401. * @deprecated 20.0.0
  1402. */
  1403. public function getSystemTagObjectMapper() {
  1404. return $this->get(ISystemTagObjectMapper::class);
  1405. }
  1406. /**
  1407. * Returns the avatar manager, used for avatar functionality
  1408. *
  1409. * @return IAvatarManager
  1410. * @deprecated 20.0.0
  1411. */
  1412. public function getAvatarManager() {
  1413. return $this->get(IAvatarManager::class);
  1414. }
  1415. /**
  1416. * Returns the root folder of ownCloud's data directory
  1417. *
  1418. * @return IRootFolder
  1419. * @deprecated 20.0.0
  1420. */
  1421. public function getRootFolder() {
  1422. return $this->get(IRootFolder::class);
  1423. }
  1424. /**
  1425. * Returns the root folder of ownCloud's data directory
  1426. * This is the lazy variant so this gets only initialized once it
  1427. * is actually used.
  1428. *
  1429. * @return IRootFolder
  1430. * @deprecated 20.0.0
  1431. */
  1432. public function getLazyRootFolder() {
  1433. return $this->get(IRootFolder::class);
  1434. }
  1435. /**
  1436. * Returns a view to ownCloud's files folder
  1437. *
  1438. * @param string $userId user ID
  1439. * @return \OCP\Files\Folder|null
  1440. * @deprecated 20.0.0
  1441. */
  1442. public function getUserFolder($userId = null) {
  1443. if ($userId === null) {
  1444. $user = $this->get(IUserSession::class)->getUser();
  1445. if (!$user) {
  1446. return null;
  1447. }
  1448. $userId = $user->getUID();
  1449. }
  1450. $root = $this->get(IRootFolder::class);
  1451. return $root->getUserFolder($userId);
  1452. }
  1453. /**
  1454. * @return \OC\User\Manager
  1455. * @deprecated 20.0.0
  1456. */
  1457. public function getUserManager() {
  1458. return $this->get(IUserManager::class);
  1459. }
  1460. /**
  1461. * @return \OC\Group\Manager
  1462. * @deprecated 20.0.0
  1463. */
  1464. public function getGroupManager() {
  1465. return $this->get(IGroupManager::class);
  1466. }
  1467. /**
  1468. * @return \OC\User\Session
  1469. * @deprecated 20.0.0
  1470. */
  1471. public function getUserSession() {
  1472. return $this->get(IUserSession::class);
  1473. }
  1474. /**
  1475. * @return \OCP\ISession
  1476. * @deprecated 20.0.0
  1477. */
  1478. public function getSession() {
  1479. return $this->get(Session::class)->getSession();
  1480. }
  1481. /**
  1482. * @param \OCP\ISession $session
  1483. * @return void
  1484. */
  1485. public function setSession(\OCP\ISession $session) {
  1486. $this->get(SessionStorage::class)->setSession($session);
  1487. $this->get(Session::class)->setSession($session);
  1488. $this->get(Store::class)->setSession($session);
  1489. }
  1490. /**
  1491. * @return \OC\Authentication\TwoFactorAuth\Manager
  1492. * @deprecated 20.0.0
  1493. */
  1494. public function getTwoFactorAuthManager() {
  1495. return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
  1496. }
  1497. /**
  1498. * @return \OC\NavigationManager
  1499. * @deprecated 20.0.0
  1500. */
  1501. public function getNavigationManager() {
  1502. return $this->get(INavigationManager::class);
  1503. }
  1504. /**
  1505. * @return \OCP\IConfig
  1506. * @deprecated 20.0.0
  1507. */
  1508. public function getConfig() {
  1509. return $this->get(AllConfig::class);
  1510. }
  1511. /**
  1512. * @return \OC\SystemConfig
  1513. * @deprecated 20.0.0
  1514. */
  1515. public function getSystemConfig() {
  1516. return $this->get(SystemConfig::class);
  1517. }
  1518. /**
  1519. * Returns the app config manager
  1520. *
  1521. * @return IAppConfig
  1522. * @deprecated 20.0.0
  1523. */
  1524. public function getAppConfig() {
  1525. return $this->get(IAppConfig::class);
  1526. }
  1527. /**
  1528. * @return IFactory
  1529. * @deprecated 20.0.0
  1530. */
  1531. public function getL10NFactory() {
  1532. return $this->get(IFactory::class);
  1533. }
  1534. /**
  1535. * get an L10N instance
  1536. *
  1537. * @param string $app appid
  1538. * @param string $lang
  1539. * @return IL10N
  1540. * @deprecated 20.0.0 use DI of {@see IL10N} or {@see IFactory} instead, or {@see \OCP\Util::getL10N()} as a last resort
  1541. */
  1542. public function getL10N($app, $lang = null) {
  1543. return $this->get(IFactory::class)->get($app, $lang);
  1544. }
  1545. /**
  1546. * @return IURLGenerator
  1547. * @deprecated 20.0.0
  1548. */
  1549. public function getURLGenerator() {
  1550. return $this->get(IURLGenerator::class);
  1551. }
  1552. /**
  1553. * @return AppFetcher
  1554. * @deprecated 20.0.0
  1555. */
  1556. public function getAppFetcher() {
  1557. return $this->get(AppFetcher::class);
  1558. }
  1559. /**
  1560. * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
  1561. * getMemCacheFactory() instead.
  1562. *
  1563. * @return ICache
  1564. * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
  1565. */
  1566. public function getCache() {
  1567. return $this->get(ICache::class);
  1568. }
  1569. /**
  1570. * Returns an \OCP\CacheFactory instance
  1571. *
  1572. * @return \OCP\ICacheFactory
  1573. * @deprecated 20.0.0
  1574. */
  1575. public function getMemCacheFactory() {
  1576. return $this->get(ICacheFactory::class);
  1577. }
  1578. /**
  1579. * Returns an \OC\RedisFactory instance
  1580. *
  1581. * @return \OC\RedisFactory
  1582. * @deprecated 20.0.0
  1583. */
  1584. public function getGetRedisFactory() {
  1585. return $this->get('RedisFactory');
  1586. }
  1587. /**
  1588. * Returns the current session
  1589. *
  1590. * @return \OCP\IDBConnection
  1591. * @deprecated 20.0.0
  1592. */
  1593. public function getDatabaseConnection() {
  1594. return $this->get(IDBConnection::class);
  1595. }
  1596. /**
  1597. * Returns the activity manager
  1598. *
  1599. * @return \OCP\Activity\IManager
  1600. * @deprecated 20.0.0
  1601. */
  1602. public function getActivityManager() {
  1603. return $this->get(\OCP\Activity\IManager::class);
  1604. }
  1605. /**
  1606. * Returns an job list for controlling background jobs
  1607. *
  1608. * @return IJobList
  1609. * @deprecated 20.0.0
  1610. */
  1611. public function getJobList() {
  1612. return $this->get(IJobList::class);
  1613. }
  1614. /**
  1615. * Returns a logger instance
  1616. *
  1617. * @return ILogger
  1618. * @deprecated 20.0.0
  1619. */
  1620. public function getLogger() {
  1621. return $this->get(ILogger::class);
  1622. }
  1623. /**
  1624. * @return ILogFactory
  1625. * @throws \OCP\AppFramework\QueryException
  1626. * @deprecated 20.0.0
  1627. */
  1628. public function getLogFactory() {
  1629. return $this->get(ILogFactory::class);
  1630. }
  1631. /**
  1632. * Returns a router for generating and matching urls
  1633. *
  1634. * @return IRouter
  1635. * @deprecated 20.0.0
  1636. */
  1637. public function getRouter() {
  1638. return $this->get(IRouter::class);
  1639. }
  1640. /**
  1641. * Returns a search instance
  1642. *
  1643. * @return ISearch
  1644. * @deprecated 20.0.0
  1645. */
  1646. public function getSearch() {
  1647. return $this->get(ISearch::class);
  1648. }
  1649. /**
  1650. * Returns a SecureRandom instance
  1651. *
  1652. * @return \OCP\Security\ISecureRandom
  1653. * @deprecated 20.0.0
  1654. */
  1655. public function getSecureRandom() {
  1656. return $this->get(ISecureRandom::class);
  1657. }
  1658. /**
  1659. * Returns a Crypto instance
  1660. *
  1661. * @return ICrypto
  1662. * @deprecated 20.0.0
  1663. */
  1664. public function getCrypto() {
  1665. return $this->get(ICrypto::class);
  1666. }
  1667. /**
  1668. * Returns a Hasher instance
  1669. *
  1670. * @return IHasher
  1671. * @deprecated 20.0.0
  1672. */
  1673. public function getHasher() {
  1674. return $this->get(IHasher::class);
  1675. }
  1676. /**
  1677. * Returns a CredentialsManager instance
  1678. *
  1679. * @return ICredentialsManager
  1680. * @deprecated 20.0.0
  1681. */
  1682. public function getCredentialsManager() {
  1683. return $this->get(ICredentialsManager::class);
  1684. }
  1685. /**
  1686. * Get the certificate manager
  1687. *
  1688. * @return \OCP\ICertificateManager
  1689. */
  1690. public function getCertificateManager() {
  1691. return $this->get(ICertificateManager::class);
  1692. }
  1693. /**
  1694. * Returns an instance of the HTTP client service
  1695. *
  1696. * @return IClientService
  1697. * @deprecated 20.0.0
  1698. */
  1699. public function getHTTPClientService() {
  1700. return $this->get(IClientService::class);
  1701. }
  1702. /**
  1703. * Get the active event logger
  1704. *
  1705. * The returned logger only logs data when debug mode is enabled
  1706. *
  1707. * @return IEventLogger
  1708. * @deprecated 20.0.0
  1709. */
  1710. public function getEventLogger() {
  1711. return $this->get(IEventLogger::class);
  1712. }
  1713. /**
  1714. * Get the active query logger
  1715. *
  1716. * The returned logger only logs data when debug mode is enabled
  1717. *
  1718. * @return IQueryLogger
  1719. * @deprecated 20.0.0
  1720. */
  1721. public function getQueryLogger() {
  1722. return $this->get(IQueryLogger::class);
  1723. }
  1724. /**
  1725. * Get the manager for temporary files and folders
  1726. *
  1727. * @return \OCP\ITempManager
  1728. * @deprecated 20.0.0
  1729. */
  1730. public function getTempManager() {
  1731. return $this->get(ITempManager::class);
  1732. }
  1733. /**
  1734. * Get the app manager
  1735. *
  1736. * @return \OCP\App\IAppManager
  1737. * @deprecated 20.0.0
  1738. */
  1739. public function getAppManager() {
  1740. return $this->get(IAppManager::class);
  1741. }
  1742. /**
  1743. * Creates a new mailer
  1744. *
  1745. * @return IMailer
  1746. * @deprecated 20.0.0
  1747. */
  1748. public function getMailer() {
  1749. return $this->get(IMailer::class);
  1750. }
  1751. /**
  1752. * Get the webroot
  1753. *
  1754. * @return string
  1755. * @deprecated 20.0.0
  1756. */
  1757. public function getWebRoot() {
  1758. return $this->webRoot;
  1759. }
  1760. /**
  1761. * @return \OC\OCSClient
  1762. * @deprecated 20.0.0
  1763. */
  1764. public function getOcsClient() {
  1765. return $this->get('OcsClient');
  1766. }
  1767. /**
  1768. * @return IDateTimeZone
  1769. * @deprecated 20.0.0
  1770. */
  1771. public function getDateTimeZone() {
  1772. return $this->get(IDateTimeZone::class);
  1773. }
  1774. /**
  1775. * @return IDateTimeFormatter
  1776. * @deprecated 20.0.0
  1777. */
  1778. public function getDateTimeFormatter() {
  1779. return $this->get(IDateTimeFormatter::class);
  1780. }
  1781. /**
  1782. * @return IMountProviderCollection
  1783. * @deprecated 20.0.0
  1784. */
  1785. public function getMountProviderCollection() {
  1786. return $this->get(IMountProviderCollection::class);
  1787. }
  1788. /**
  1789. * Get the IniWrapper
  1790. *
  1791. * @return IniGetWrapper
  1792. * @deprecated 20.0.0
  1793. */
  1794. public function getIniWrapper() {
  1795. return $this->get(IniGetWrapper::class);
  1796. }
  1797. /**
  1798. * @return \OCP\Command\IBus
  1799. * @deprecated 20.0.0
  1800. */
  1801. public function getCommandBus() {
  1802. return $this->get(IBus::class);
  1803. }
  1804. /**
  1805. * Get the trusted domain helper
  1806. *
  1807. * @return TrustedDomainHelper
  1808. * @deprecated 20.0.0
  1809. */
  1810. public function getTrustedDomainHelper() {
  1811. return $this->get(TrustedDomainHelper::class);
  1812. }
  1813. /**
  1814. * Get the locking provider
  1815. *
  1816. * @return ILockingProvider
  1817. * @since 8.1.0
  1818. * @deprecated 20.0.0
  1819. */
  1820. public function getLockingProvider() {
  1821. return $this->get(ILockingProvider::class);
  1822. }
  1823. /**
  1824. * @return IMountManager
  1825. * @deprecated 20.0.0
  1826. **/
  1827. public function getMountManager() {
  1828. return $this->get(IMountManager::class);
  1829. }
  1830. /**
  1831. * @return IUserMountCache
  1832. * @deprecated 20.0.0
  1833. */
  1834. public function getUserMountCache() {
  1835. return $this->get(IUserMountCache::class);
  1836. }
  1837. /**
  1838. * Get the MimeTypeDetector
  1839. *
  1840. * @return IMimeTypeDetector
  1841. * @deprecated 20.0.0
  1842. */
  1843. public function getMimeTypeDetector() {
  1844. return $this->get(IMimeTypeDetector::class);
  1845. }
  1846. /**
  1847. * Get the MimeTypeLoader
  1848. *
  1849. * @return IMimeTypeLoader
  1850. * @deprecated 20.0.0
  1851. */
  1852. public function getMimeTypeLoader() {
  1853. return $this->get(IMimeTypeLoader::class);
  1854. }
  1855. /**
  1856. * Get the manager of all the capabilities
  1857. *
  1858. * @return CapabilitiesManager
  1859. * @deprecated 20.0.0
  1860. */
  1861. public function getCapabilitiesManager() {
  1862. return $this->get(CapabilitiesManager::class);
  1863. }
  1864. /**
  1865. * Get the Notification Manager
  1866. *
  1867. * @return \OCP\Notification\IManager
  1868. * @since 8.2.0
  1869. * @deprecated 20.0.0
  1870. */
  1871. public function getNotificationManager() {
  1872. return $this->get(\OCP\Notification\IManager::class);
  1873. }
  1874. /**
  1875. * @return ICommentsManager
  1876. * @deprecated 20.0.0
  1877. */
  1878. public function getCommentsManager() {
  1879. return $this->get(ICommentsManager::class);
  1880. }
  1881. /**
  1882. * @return \OCA\Theming\ThemingDefaults
  1883. * @deprecated 20.0.0
  1884. */
  1885. public function getThemingDefaults() {
  1886. return $this->get('ThemingDefaults');
  1887. }
  1888. /**
  1889. * @return \OC\IntegrityCheck\Checker
  1890. * @deprecated 20.0.0
  1891. */
  1892. public function getIntegrityCodeChecker() {
  1893. return $this->get('IntegrityCodeChecker');
  1894. }
  1895. /**
  1896. * @return \OC\Session\CryptoWrapper
  1897. * @deprecated 20.0.0
  1898. */
  1899. public function getSessionCryptoWrapper() {
  1900. return $this->get('CryptoWrapper');
  1901. }
  1902. /**
  1903. * @return CsrfTokenManager
  1904. * @deprecated 20.0.0
  1905. */
  1906. public function getCsrfTokenManager() {
  1907. return $this->get(CsrfTokenManager::class);
  1908. }
  1909. /**
  1910. * @return IThrottler
  1911. * @deprecated 20.0.0
  1912. */
  1913. public function getBruteForceThrottler() {
  1914. return $this->get(Throttler::class);
  1915. }
  1916. /**
  1917. * @return IContentSecurityPolicyManager
  1918. * @deprecated 20.0.0
  1919. */
  1920. public function getContentSecurityPolicyManager() {
  1921. return $this->get(ContentSecurityPolicyManager::class);
  1922. }
  1923. /**
  1924. * @return ContentSecurityPolicyNonceManager
  1925. * @deprecated 20.0.0
  1926. */
  1927. public function getContentSecurityPolicyNonceManager() {
  1928. return $this->get(ContentSecurityPolicyNonceManager::class);
  1929. }
  1930. /**
  1931. * Not a public API as of 8.2, wait for 9.0
  1932. *
  1933. * @return \OCA\Files_External\Service\BackendService
  1934. * @deprecated 20.0.0
  1935. */
  1936. public function getStoragesBackendService() {
  1937. return $this->get(BackendService::class);
  1938. }
  1939. /**
  1940. * Not a public API as of 8.2, wait for 9.0
  1941. *
  1942. * @return \OCA\Files_External\Service\GlobalStoragesService
  1943. * @deprecated 20.0.0
  1944. */
  1945. public function getGlobalStoragesService() {
  1946. return $this->get(GlobalStoragesService::class);
  1947. }
  1948. /**
  1949. * Not a public API as of 8.2, wait for 9.0
  1950. *
  1951. * @return \OCA\Files_External\Service\UserGlobalStoragesService
  1952. * @deprecated 20.0.0
  1953. */
  1954. public function getUserGlobalStoragesService() {
  1955. return $this->get(UserGlobalStoragesService::class);
  1956. }
  1957. /**
  1958. * Not a public API as of 8.2, wait for 9.0
  1959. *
  1960. * @return \OCA\Files_External\Service\UserStoragesService
  1961. * @deprecated 20.0.0
  1962. */
  1963. public function getUserStoragesService() {
  1964. return $this->get(UserStoragesService::class);
  1965. }
  1966. /**
  1967. * @return \OCP\Share\IManager
  1968. * @deprecated 20.0.0
  1969. */
  1970. public function getShareManager() {
  1971. return $this->get(\OCP\Share\IManager::class);
  1972. }
  1973. /**
  1974. * @return \OCP\Collaboration\Collaborators\ISearch
  1975. * @deprecated 20.0.0
  1976. */
  1977. public function getCollaboratorSearch() {
  1978. return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
  1979. }
  1980. /**
  1981. * @return \OCP\Collaboration\AutoComplete\IManager
  1982. * @deprecated 20.0.0
  1983. */
  1984. public function getAutoCompleteManager() {
  1985. return $this->get(IManager::class);
  1986. }
  1987. /**
  1988. * Returns the LDAP Provider
  1989. *
  1990. * @return \OCP\LDAP\ILDAPProvider
  1991. * @deprecated 20.0.0
  1992. */
  1993. public function getLDAPProvider() {
  1994. return $this->get('LDAPProvider');
  1995. }
  1996. /**
  1997. * @return \OCP\Settings\IManager
  1998. * @deprecated 20.0.0
  1999. */
  2000. public function getSettingsManager() {
  2001. return $this->get(\OC\Settings\Manager::class);
  2002. }
  2003. /**
  2004. * @return \OCP\Files\IAppData
  2005. * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
  2006. */
  2007. public function getAppDataDir($app) {
  2008. /** @var \OC\Files\AppData\Factory $factory */
  2009. $factory = $this->get(\OC\Files\AppData\Factory::class);
  2010. return $factory->get($app);
  2011. }
  2012. /**
  2013. * @return \OCP\Lockdown\ILockdownManager
  2014. * @deprecated 20.0.0
  2015. */
  2016. public function getLockdownManager() {
  2017. return $this->get('LockdownManager');
  2018. }
  2019. /**
  2020. * @return \OCP\Federation\ICloudIdManager
  2021. * @deprecated 20.0.0
  2022. */
  2023. public function getCloudIdManager() {
  2024. return $this->get(ICloudIdManager::class);
  2025. }
  2026. /**
  2027. * @return \OCP\GlobalScale\IConfig
  2028. * @deprecated 20.0.0
  2029. */
  2030. public function getGlobalScaleConfig() {
  2031. return $this->get(IConfig::class);
  2032. }
  2033. /**
  2034. * @return \OCP\Federation\ICloudFederationProviderManager
  2035. * @deprecated 20.0.0
  2036. */
  2037. public function getCloudFederationProviderManager() {
  2038. return $this->get(ICloudFederationProviderManager::class);
  2039. }
  2040. /**
  2041. * @return \OCP\Remote\Api\IApiFactory
  2042. * @deprecated 20.0.0
  2043. */
  2044. public function getRemoteApiFactory() {
  2045. return $this->get(IApiFactory::class);
  2046. }
  2047. /**
  2048. * @return \OCP\Federation\ICloudFederationFactory
  2049. * @deprecated 20.0.0
  2050. */
  2051. public function getCloudFederationFactory() {
  2052. return $this->get(ICloudFederationFactory::class);
  2053. }
  2054. /**
  2055. * @return \OCP\Remote\IInstanceFactory
  2056. * @deprecated 20.0.0
  2057. */
  2058. public function getRemoteInstanceFactory() {
  2059. return $this->get(IInstanceFactory::class);
  2060. }
  2061. /**
  2062. * @return IStorageFactory
  2063. * @deprecated 20.0.0
  2064. */
  2065. public function getStorageFactory() {
  2066. return $this->get(IStorageFactory::class);
  2067. }
  2068. /**
  2069. * Get the Preview GeneratorHelper
  2070. *
  2071. * @return GeneratorHelper
  2072. * @since 17.0.0
  2073. * @deprecated 20.0.0
  2074. */
  2075. public function getGeneratorHelper() {
  2076. return $this->get(\OC\Preview\GeneratorHelper::class);
  2077. }
  2078. private function registerDeprecatedAlias(string $alias, string $target) {
  2079. $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
  2080. try {
  2081. /** @var LoggerInterface $logger */
  2082. $logger = $container->get(LoggerInterface::class);
  2083. $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
  2084. } catch (ContainerExceptionInterface $e) {
  2085. // Could not get logger. Continue
  2086. }
  2087. return $container->get($target);
  2088. }, false);
  2089. }
  2090. }