@shrinedev/loopback-keycloak-demo-app
Version:
Example Loopback App that integrates with Keycloak.
63 lines • 2.5 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
const rest_1 = require("@loopback/rest");
const context_1 = require("@loopback/context");
const loopback_gate_keycloak_1 = require("@shrinedev/loopback-gate-keycloak");
const loopback_gate_1 = require("@shrinedev/loopback-gate");
const team_gate_1 = require("../gates/team.gate");
/**
* OpenAPI response for me()
*/
const TEAM_RESPONSE = {
description: '/teams View Team Response',
parameters: [{ name: 'id', in: 'path', schema: { type: 'string' } }],
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: { type: 'string' },
},
},
},
},
};
/**
* A controller to demonstrate a LoopBack Keycloak Gate
*/
class TeamController {
constructor() { }
// Map to `GET /me`
me(team) {
// Reply with a current team *if* authorized by Keycloak
return {
name: team && team.name,
};
}
}
__decorate([
loopback_gate_1.gateWith(loopback_gate_keycloak_1.KeycloakGate, team_gate_1.TeamGate),
rest_1.get('/teams/{id}', {
responses: {
'200': TEAM_RESPONSE,
},
}),
__param(0, context_1.inject(team_gate_1.CURRENT_TEAM)),
__metadata("design:type", Function),
__metadata("design:paramtypes", [team_gate_1.TeamProfile]),
__metadata("design:returntype", Object)
], TeamController.prototype, "me", null);
exports.TeamController = TeamController;
//# sourceMappingURL=team.controller.js.map