fix(auth): memory leaks
alb-provider: JWT verification block was wrapped in generic error that turned 401 to 500 causing clients to retry the login cimd: cimd clients are not registered in oidc_clients table so inserting offline sessions for them violates the foreign key constraint. dropping the fk. offline: return access token even when refresh token issuing fails. if the refresh token issue fails for some reason, it will return 500 which will then cause client to retry even it can get valid access token without refresh token. closes #33329 Signed-off-by: Hellgren Heikki <heikki.hellgren@op.fi>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2026 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 offline_sessions.oidc_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('offline_sessions', table => {
|
||||
table.dropForeign(['oidc_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('offline_sessions')
|
||||
.whereNotNull('oidc_client_id')
|
||||
.whereNotIn('oidc_client_id', knex('oidc_clients').select('client_id'))
|
||||
.delete();
|
||||
|
||||
await knex.schema.alterTable('offline_sessions', table => {
|
||||
table
|
||||
.foreign('oidc_client_id')
|
||||
.references('client_id')
|
||||
.inTable('oidc_clients')
|
||||
.onDelete('CASCADE');
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user