nextcloud/apps/cloud_federation_api/lib/Migration/Version1017Date20260306120000.php
Enrique Pérez Arnaud 789ff6a8a3
feat(cloud_federation_api): add token exchange endpoint issuing JWT access tokens
Co-authored-by: Micke Nordin <kano@sunet.se>
Signed-off-by: Micke Nordin <kano@sunet.se>
Signed-off-by: Enrique Pérez Arnaud <enrique@cazalla.net>
2026-06-17 11:01:11 +02:00

54 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\CloudFederationAPI\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\Attributes\CreateTable;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
#[CreateTable(table: 'ocm_token_map', description: 'Maps OCM access tokens to their originating refresh tokens')]
class Version1017Date20260306120000 extends SimpleMigrationStep {
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('ocm_token_map')) {
return null;
}
$table = $schema->createTable('ocm_token_map');
$table->addColumn('id', Types::INTEGER, [
'autoincrement' => true,
'notnull' => true,
'unsigned' => true,
]);
$table->addColumn('access_token_id', Types::INTEGER, [
'notnull' => true,
'unsigned' => true,
]);
$table->addColumn('refresh_token', Types::STRING, [
'notnull' => true,
'length' => 512,
]);
$table->addColumn('expires', Types::INTEGER, [
'notnull' => true,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['access_token_id'], 'ocm_tkmap_atid');
$table->addIndex(['expires'], 'ocm_tkmap_exp');
return $schema;
}
}