mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
refactor(core): Update auth related typings (no-changelog) (#8686)
This commit is contained in:
parent
9b0d98403a
commit
35fb7102cb
|
@ -17,6 +17,7 @@ import { InternalHooks } from '@/InternalHooks';
|
|||
import { License } from '@/License';
|
||||
import { UserRepository } from '@db/repositories/user.repository';
|
||||
import { UrlService } from '@/services/url.service';
|
||||
import type { AuthenticatedRequest } from '@/requests';
|
||||
|
||||
async function createApiRouter(
|
||||
version: string,
|
||||
|
@ -51,7 +52,7 @@ async function createApiRouter(
|
|||
);
|
||||
}
|
||||
|
||||
apiController.get(`/${publicApiEndpoint}/${version}/openapi.yml`, (req, res) => {
|
||||
apiController.get(`/${publicApiEndpoint}/${version}/openapi.yml`, (_, res) => {
|
||||
res.sendFile(openApiSpecPath);
|
||||
});
|
||||
|
||||
|
@ -91,7 +92,7 @@ async function createApiRouter(
|
|||
validateSecurity: {
|
||||
handlers: {
|
||||
ApiKeyAuth: async (
|
||||
req: express.Request,
|
||||
req: AuthenticatedRequest,
|
||||
_scopes: unknown,
|
||||
schema: OpenAPIV3.ApiKeySecurityScheme,
|
||||
): Promise<boolean> => {
|
||||
|
|
|
@ -1,32 +1,8 @@
|
|||
import type express from 'express';
|
||||
import type { IDataObject, ExecutionStatus } from 'n8n-workflow';
|
||||
|
||||
import type { User } from '@db/entities/User';
|
||||
|
||||
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
|
||||
import type { TagEntity } from '@db/entities/TagEntity';
|
||||
|
||||
import type { UserManagementMailer } from '@/UserManagement/email';
|
||||
|
||||
import type { Risk } from '@/security-audit/types';
|
||||
|
||||
export type AuthlessRequest<
|
||||
RouteParams = {},
|
||||
ResponseBody = {},
|
||||
RequestBody = {},
|
||||
RequestQuery = {},
|
||||
> = express.Request<RouteParams, ResponseBody, RequestBody, RequestQuery>;
|
||||
|
||||
export type AuthenticatedRequest<
|
||||
RouteParams = {},
|
||||
ResponseBody = {},
|
||||
RequestBody = {},
|
||||
RequestQuery = {},
|
||||
> = express.Request<RouteParams, ResponseBody, RequestBody, RequestQuery> & {
|
||||
user: User;
|
||||
mailer?: UserManagementMailer;
|
||||
};
|
||||
import type { AuthlessRequest, AuthenticatedRequest } from '@/requests';
|
||||
|
||||
export type PaginatedRequest = AuthenticatedRequest<
|
||||
{},
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/* eslint-disable @typescript-eslint/no-invalid-void-type */
|
||||
|
||||
import type express from 'express';
|
||||
import { Container } from 'typedi';
|
||||
|
||||
import type { AuthenticatedRequest, PaginatedRequest } from '../../../types';
|
||||
import { decodeCursor } from '../services/pagination.service';
|
||||
import { License } from '@/License';
|
||||
import type { GlobalRole } from '@db/entities/User';
|
||||
import type { AuthenticatedRequest } from '@/requests';
|
||||
|
||||
import type { PaginatedRequest } from '../../../types';
|
||||
import { decodeCursor } from '../services/pagination.service';
|
||||
|
||||
const UNLIMITED_USERS_QUOTA = -1;
|
||||
|
||||
|
@ -51,7 +52,7 @@ export const validCursor = (
|
|||
};
|
||||
|
||||
export const validLicenseWithUserQuota = (
|
||||
req: express.Request,
|
||||
_: express.Request,
|
||||
res: express.Response,
|
||||
next: express.NextFunction,
|
||||
): express.Response | void => {
|
||||
|
|
|
@ -15,7 +15,6 @@ import { IsBoolean, IsEmail, IsIn, IsOptional, IsString, Length } from 'class-va
|
|||
import { NoXss } from '@db/utils/customValidators';
|
||||
import type { PublicUser, SecretsProvider, SecretsProviderState } from '@/Interfaces';
|
||||
import { AssignableRole, type User } from '@db/entities/User';
|
||||
import type { UserManagementMailer } from '@/UserManagement/email';
|
||||
import type { Variables } from '@db/entities/Variables';
|
||||
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
import type { CredentialsEntity } from '@db/entities/CredentialsEntity';
|
||||
|
@ -65,7 +64,6 @@ export type AuthenticatedRequest<
|
|||
RequestQuery = {},
|
||||
> = Omit<express.Request<RouteParams, ResponseBody, RequestBody, RequestQuery>, 'user'> & {
|
||||
user: User;
|
||||
mailer?: UserManagementMailer;
|
||||
};
|
||||
|
||||
// ----------------------------------
|
||||
|
|
Loading…
Reference in a new issue