@acarmisc/backstage-plugin-litellm-backend 0.17.3 → 0.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugin.d.ts CHANGED
@@ -1 +1,7 @@
1
+ /**
2
+ * Bridge routes exempt from Backstage's default auth policy (they verify the
3
+ * Keycloak JWT themselves). Every route registered in routes/bridge.ts must be
4
+ * listed here, or the framework answers 401 before the bridge verifier runs.
5
+ */
6
+ export declare const BRIDGE_UNAUTHENTICATED_PATHS: string[];
1
7
  export declare const litellmPlugin: import("@backstage/backend-plugin-api").BackendFeature;
package/dist/plugin.js CHANGED
@@ -1,10 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.litellmPlugin = void 0;
3
+ exports.litellmPlugin = exports.BRIDGE_UNAUTHENTICATED_PATHS = void 0;
4
4
  const backend_plugin_api_1 = require("@backstage/backend-plugin-api");
5
5
  const router_1 = require("./router");
6
6
  const bridge_1 = require("./bridge");
7
7
  const backstage_plugin_litellm_common_1 = require("@acarmisc/backstage-plugin-litellm-common");
8
+ /**
9
+ * Bridge routes exempt from Backstage's default auth policy (they verify the
10
+ * Keycloak JWT themselves). Every route registered in routes/bridge.ts must be
11
+ * listed here, or the framework answers 401 before the bridge verifier runs.
12
+ */
13
+ exports.BRIDGE_UNAUTHENTICATED_PATHS = [
14
+ '/bridge/health',
15
+ '/bridge/keys',
16
+ '/bridge/models',
17
+ '/bridge/user/info',
18
+ ];
8
19
  exports.litellmPlugin = (0, backend_plugin_api_1.createBackendPlugin)({
9
20
  pluginId: 'litellm',
10
21
  register(reg) {
@@ -33,11 +44,7 @@ exports.litellmPlugin = (0, backend_plugin_api_1.createBackendPlugin)({
33
44
  // policy, otherwise the framework rejects the Keycloak Bearer with
34
45
  // "Illegal token" before the bridge verifier ever runs.
35
46
  if ((0, bridge_1.readBridgeConfig)(config).enabled) {
36
- for (const path of [
37
- '/bridge/health',
38
- '/bridge/keys',
39
- '/bridge/models',
40
- ]) {
47
+ for (const path of exports.BRIDGE_UNAUTHENTICATED_PATHS) {
41
48
  httpRouter.addAuthPolicy({ path, allow: 'unauthenticated' });
42
49
  }
43
50
  }
@@ -132,7 +132,24 @@ function registerBridgeRoutes(router, ctx, bridgeOpts) {
132
132
  try {
133
133
  const claims = await requireClaims(req);
134
134
  const user = await (0, bridge_1.getOrProvisionUserFromClaims)(client, claims, provisioningEnabled, provisioningDefaults, logger, bridgeIdentity);
135
- res.json({ user_id: user.user_id, teams: user.teams ?? [] });
135
+ // Enrich team list with metadata (display names, etc.)
136
+ const teamIds = user.teams ?? [];
137
+ const teamMetadata = [];
138
+ for (const teamId of teamIds) {
139
+ try {
140
+ const teamInfo = await client.getTeamInfo(teamId);
141
+ teamMetadata.push({
142
+ id: teamId,
143
+ name: teamInfo.team_alias || teamId, // Use alias as display name, fallback to ID
144
+ });
145
+ }
146
+ catch (e) {
147
+ // If we can't fetch team info, just use the ID
148
+ logger.debug(`Could not fetch team info for ${teamId}: ${e.message}`);
149
+ teamMetadata.push({ id: teamId });
150
+ }
151
+ }
152
+ res.json({ user_id: user.user_id, teams: teamMetadata });
136
153
  }
137
154
  catch (error) {
138
155
  handleBridgeError(error, res);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acarmisc/backstage-plugin-litellm-backend",
3
- "version": "0.17.3",
3
+ "version": "0.17.5",
4
4
  "description": "The Backstage backend plugin for LiteLLM governance",
5
5
  "backstage": {
6
6
  "role": "backend-plugin",