feat(auth-backend): add experimental CIMD support (#32307)

Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
Ben Lambert
2026-02-17 17:00:49 +01:00
committed by GitHub
parent 29fc1f8f23
commit 31de2c9b3a
17 changed files with 1967 additions and 157 deletions
@@ -0,0 +1,44 @@
/*
* Copyright 2025 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-check
/**
* Drop the foreign key constraint on oauth_authorization_sessions.client_id
* to allow CIMD (Client ID Metadata Document) clients which are not stored
* in the oidc_clients table.
*
* @param {import('knex').Knex} knex
*/
exports.up = async function up(knex) {
await knex.schema.alterTable('oauth_authorization_sessions', table => {
table.dropForeign(['client_id']);
});
};
/**
* @param {import('knex').Knex} knex
*/
exports.down = async function down(knex) {
// Delete sessions with CIMD client_ids (not in oidc_clients) before re-adding FK
await knex('oauth_authorization_sessions')
.whereNotIn('client_id', knex('oidc_clients').select('client_id'))
.delete();
await knex.schema.alterTable('oauth_authorization_sessions', table => {
table.foreign('client_id').references('client_id').inTable('oidc_clients');
});
};