UNPKG

@shrinedev/loopback-keycloak-demo-app

Version:

Example Loopback App that integrates with Keycloak.

51 lines 2.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const boot_1 = require("@loopback/boot"); const rest_explorer_1 = require("@loopback/rest-explorer"); const repository_1 = require("@loopback/repository"); const rest_1 = require("@loopback/rest"); const service_proxy_1 = require("@loopback/service-proxy"); const path = require("path"); const sequence_1 = require("./sequence"); const loopback_gate_1 = require("@shrinedev/loopback-gate"); const loopback_gate_keycloak_1 = require("@shrinedev/loopback-gate-keycloak"); const team_gate_1 = require("./gates/team.gate"); const exportedKeycloakClientConfig = { realm: 'master', 'auth-server-url': 'http://127.0.0.1:8081/auth', 'ssl-required': 'external', resource: 'account', 'use-resource-role-mappings': true, 'confidential-port': 0, }; class ShrineApplication extends boot_1.BootMixin(service_proxy_1.ServiceMixin(repository_1.RepositoryMixin(rest_1.RestApplication))) { constructor(options = {}) { super(options); // Set up the custom sequence this.sequence(sequence_1.MySequence); // Set up default home page this.static('/', path.join(__dirname, '../public')); // Customize @loopback/rest-explorer configuration here this.bind(rest_explorer_1.RestExplorerBindings.CONFIG).to({ path: '/explorer', }); this.component(rest_explorer_1.RestExplorerComponent); this.component(loopback_gate_1.GateComponent); loopback_gate_1.GateComponent.createBindings(loopback_gate_keycloak_1.KeycloakGate, loopback_gate_1.LogGate, team_gate_1.TeamGate).forEach(binding => this.add(binding)); // For Keycloak Gate we need provide an instance of the client const keycloakClient = new loopback_gate_keycloak_1.KeycloakClient(exportedKeycloakClientConfig); this.bind(loopback_gate_keycloak_1.KeycloakBindings.KEYCLOAK_CLIENT).to(keycloakClient); this.projectRoot = __dirname; // Customize @loopback/boot Booter Conventions here this.bootOptions = { controllers: { // Customize ControllerBooter Conventions here dirs: ['controllers'], extensions: ['.controller.js'], nested: true, }, }; } } exports.ShrineApplication = ShrineApplication; //# sourceMappingURL=application.js.map