69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import {
|
|
IAppAccessors,
|
|
IConfigurationExtend,
|
|
IConfigurationModify,
|
|
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 {
|
|
ISetting,
|
|
SettingType,
|
|
} from "@rocket.chat/apps-engine/definition/settings";
|
|
import { GroupEndpoint } from "./src/endpoints/GroupEndpoint";
|
|
import { GroupsEndpoint } from "./src/endpoints/GroupsEndpoint";
|
|
|
|
import { UserEndpoint } from "./src/endpoints/UserEndpoint";
|
|
import { UsersEndpoint } from "./src/endpoints/UsersEndpoint";
|
|
import crypto = require("crypto");
|
|
|
|
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-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),
|
|
});
|
|
}
|
|
}
|