🔒✉️ feat: allow only certain domain (#1562)

* feat: allow only certain domain

* Update dotenv.md

* refactor( registrationController) & handle ALLOWED_REGISTRATION_DOMAINS not specified

* cleanup and moved to AuthService for better  error handling

* refactor: replace environment variable with librechat config item, add typedef for custom config, update docs for new registration object and allowedDomains values

* ci(AuthService): test for `isDomainAllowed`

---------

Co-authored-by: Danny Avila <messagedaniel@protonmail.com>
This commit is contained in:
Marco Beretta 2024-02-05 08:14:52 +01:00 committed by GitHub
parent b5c2fb93c1
commit 25da90657d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 136 additions and 21 deletions

View file

@ -30,6 +30,11 @@ export const configSchema = z.object({
version: z.string(),
cache: z.boolean(),
fileStrategy: fileSourceSchema.optional(),
registration: z
.object({
allowedDomains: z.array(z.string()).optional(),
})
.optional(),
endpoints: z
.object({
custom: z.array(endpointSchema.partial()),
@ -37,6 +42,8 @@ export const configSchema = z.object({
.strict(),
});
export type TCustomConfig = z.infer<typeof configSchema>;
export enum KnownEndpoints {
mistral = 'mistral',
openrouter = 'openrouter',