This repository has been archived on 2024-09-23. You can view files and clone it, but cannot push or open issues or pull requests.
rocketchat-scim/ScimApp.ts
2022-02-15 16:26:52 +01:00

79 lines
2.6 KiB
TypeScript

import {
IAppAccessors,
IConfigurationExtend,
ILogger,
} from "@rocket.chat/apps-engine/definition/accessors";
import {
ApiSecurity,
ApiVisibility,
} from "@rocket.chat/apps-engine/definition/api";
import { App } from "@rocket.chat/apps-engine/definition/App";
import { IAppInfo } from "@rocket.chat/apps-engine/definition/metadata";
import { SettingType } from "@rocket.chat/apps-engine/definition/settings";
import { GroupEndpoint } from "./src/endpoints/GroupEndpoint";
import { GroupsEndpoint } from "./src/endpoints/GroupsEndpoint";
import crypto = require("crypto");
import { UserEndpoint } from "./src/endpoints/UserEndpoint";
import { UsersEndpoint } from "./src/endpoints/UsersEndpoint";
export class ScimApp extends App {
constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) {
super(info, logger, accessors);
}
public async extendConfiguration(configuration: IConfigurationExtend) {
configuration.api.provideApi({
visibility: ApiVisibility.PUBLIC,
security: ApiSecurity.UNSECURE,
endpoints: [
new UsersEndpoint(this),
new UserEndpoint(this),
new GroupsEndpoint(this),
new GroupEndpoint(this),
],
});
configuration.settings.provideSetting({
id: "rc-user-id",
type: SettingType.STRING,
packageValue: "",
required: true,
public: false,
i18nLabel: "Rocket.Chat User ID",
});
configuration.settings.provideSetting({
id: "rc-token",
type: SettingType.STRING,
packageValue: "",
required: true,
public: false,
i18nLabel: "Rocket.Chat Token",
});
configuration.settings.provideSetting({
id: "auth-mode",
type: SettingType.SELECT,
packageValue: "",
required: true,
public: false,
i18nLabel: "Auth mode for the SCIM endpoints.",
value: "bearer",
values: [
{ key: "bearer", i18nLabel: "Bearer token" },
{ key: "none", i18nLabel: "None" },
],
});
configuration.settings.provideSetting({
id: "auth-bearer",
type: SettingType.STRING,
packageValue: "",
required: true,
public: false,
i18nLabel: "A bearer token to access the SCIM endpoints.",
value: crypto.randomBytes(128).toString("base64").slice(0, 128),
});
}
}