Skip to content

Commit

Permalink
Update Keycloak plugin for dynamic backend
Browse files Browse the repository at this point in the history
Add dynamic backend module capabilities for the Keycloak backend plugin.

Signed-off-by: Craig Tracey <[email protected]>
  • Loading branch information
craigtracey committed Oct 23, 2023
1 parent bf05ae8 commit cb1a7ef
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
17 changes: 16 additions & 1 deletion plugins/keycloak-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,22 @@
"types": "dist/index.d.ts"
},
"backstage": {
"role": "backend-plugin"
"role": "backend-plugin-module"
},
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha.ts",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha.ts"
],
"package.json": [
"package.json"
]
}
},
"scripts": {
"start": "opener http://localhost:8080/admin/master/console/#/janus-realm && opener http://localhost:7007/catalog/entities && turbo run start:plugin start:keycloak",
Expand Down
24 changes: 24 additions & 0 deletions plugins/keycloak-backend/src/alpha.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2023 The Janus IDP 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.
*/

/**
* The Keycloak backend plugin integrates Keycloak into Backstage
*
* @packageDocumentation
*/

export * from './module';
export { default } from './module';
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 The Janus IDP 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.
*/

import {
createBackendModule,
coreServices,
} from '@backstage/backend-plugin-api';
import { loggerToWinstonLogger } from '@backstage/backend-common';
import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';
import { KeycloakOrgEntityProvider } from '../providers';

/**
* Registers the `KeycloakEntityProvider` with the catalog processing extension point.
*
* @alpha
*/
export const catalogModuleKeycloakEntityProvider = createBackendModule({
pluginId: 'catalog',
moduleId: 'keycloakEntityProvider',
register(env) {
env.registerInit({
deps: {
catalog: catalogProcessingExtensionPoint,
config: coreServices.rootConfig,
logger: coreServices.logger,
scheduler: coreServices.scheduler,
},
async init({ catalog, config, logger, scheduler }) {
catalog.addEntityProvider(
KeycloakOrgEntityProvider.fromConfig(config, {
id: 'development',
logger: loggerToWinstonLogger(logger),
scheduler,
}),
);
},
});
},
});
17 changes: 17 additions & 0 deletions plugins/keycloak-backend/src/module/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2023 The Janus IDP 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.
*/

export { catalogModuleKeycloakEntityProvider as default } from './catalogModuleKeycloakEntityProvider';

0 comments on commit cb1a7ef

Please sign in to comment.