aboutsummaryrefslogtreecommitdiffstats
path: root/apps/oauth2/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-01-07 13:51:59 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-01-07 13:51:59 +0100
commiteb407565b044857923ab989a218fc4e931fce2f6 (patch)
tree9fa41d7aab2f9d111a4ee04587b06cd3823bed45 /apps/oauth2/lib
parentbd697f63bde71ee84b591eaa4b54f128125f9f45 (diff)
downloadnextcloud-server-eb407565b044857923ab989a218fc4e931fce2f6.tar.gz
nextcloud-server-eb407565b044857923ab989a218fc4e931fce2f6.zip
OAuth2 client identifier must be unique
Fixes #12981 This is highly unlikely to happen. But better to enforce it on the DB level as well! Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/oauth2/lib')
-rw-r--r--apps/oauth2/lib/Migration/Version010402Date20190107124745.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/apps/oauth2/lib/Migration/Version010402Date20190107124745.php b/apps/oauth2/lib/Migration/Version010402Date20190107124745.php
new file mode 100644
index 00000000000..487eee49c44
--- /dev/null
+++ b/apps/oauth2/lib/Migration/Version010402Date20190107124745.php
@@ -0,0 +1,49 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\OAuth2\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\SimpleMigrationStep;
+use OCP\Migration\IOutput;
+
+class Version010402Date20190107124745 extends SimpleMigrationStep {
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $table = $schema->getTable('oauth2_clients');
+ $table->dropIndex('oauth2_client_id_idx');
+ $table->addUniqueIndex(['client_identifier'], 'oauth2_client_id_idx');
+ return $schema;
+ }
+}