auth select mode
This commit is contained in:
parent
67718df65d
commit
3470a4ce60
4 changed files with 26 additions and 18 deletions
22
ScimApp.ts
22
ScimApp.ts
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
IAppAccessors,
|
||||
IConfigurationExtend,
|
||||
IConfigurationModify,
|
||||
ILogger,
|
||||
} from "@rocket.chat/apps-engine/definition/accessors";
|
||||
import {
|
||||
|
@ -10,16 +9,13 @@ import {
|
|||
} 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 { 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";
|
||||
import crypto = require("crypto");
|
||||
|
||||
export class ScimApp extends App {
|
||||
constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) {
|
||||
|
@ -56,6 +52,20 @@ export class ScimApp extends App {
|
|||
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,
|
||||
|
|
|
@ -55,12 +55,18 @@ export class Context {
|
|||
}
|
||||
|
||||
public async checkAuth() {
|
||||
const token = await this.read
|
||||
const authMode = await this.read
|
||||
.getEnvironmentReader()
|
||||
.getSettings()
|
||||
.getValueById("auth-bearer");
|
||||
if (this.request.headers.authorization !== `Bearer ${token}`) {
|
||||
throw new UnauthorizedError();
|
||||
.getValueById("auth-mode");
|
||||
if (authMode === "bearer") {
|
||||
const token = await this.read
|
||||
.getEnvironmentReader()
|
||||
.getSettings()
|
||||
.getValueById("auth-bearer");
|
||||
if (this.request.headers.authorization !== `Bearer ${token}`) {
|
||||
throw new UnauthorizedError();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import { HttpStatusCode } from "@rocket.chat/apps-engine/definition/accessors";
|
||||
import { IApiResponse } from "@rocket.chat/apps-engine/definition/api";
|
||||
import {
|
||||
RocketChatAssociationModel,
|
||||
RocketChatAssociationRecord,
|
||||
} from "@rocket.chat/apps-engine/definition/metadata";
|
||||
import { SCIMUser } from "../scim/User";
|
||||
import { Context } from "./Context";
|
||||
import { IScimEndpoint, ScimEndpoint } from "./ScimEndpoint";
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import { HttpStatusCode } from "@rocket.chat/apps-engine/definition/accessors";
|
||||
import { IApiResponse } from "@rocket.chat/apps-engine/definition/api";
|
||||
import {
|
||||
RocketChatAssociationModel,
|
||||
RocketChatAssociationRecord,
|
||||
} from "@rocket.chat/apps-engine/definition/metadata";
|
||||
import crypto = require("crypto");
|
||||
import { SCIMListResponse } from "../scim/ListResponse";
|
||||
import { SCIMUser } from "../scim/User";
|
||||
|
|
Reference in a new issue