Files
medusa-store/packages/medusa/src/api/auth/middlewares.ts
Harminder Virk 48e00169d2 breaking: move shared HTTP utils to the framework (#9402)
Fixes: FRMW-2728, FRMW-2729

After this PR gets merged the following middleware will be exported from the `@medusajs/framework/http` import path.

- applyParamsAsFilters
- clearFiltersByKey
- applyDefaultFilters
- setContext
- getQueryConfig
- httpCompression
- maybeApplyLinkFilter
- refetchEntities
- unlessPath
- validateBody
- validateQuery

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-10-03 09:42:00 +00:00

60 lines
1.6 KiB
TypeScript

import {
authenticate,
MiddlewareRoute,
validateAndTransformBody,
} from "@medusajs/framework/http"
import { validateScopeProviderAssociation } from "./utils/validate-scope-provider-association"
import { validateToken } from "./utils/validate-token"
import { ResetPasswordRequest } from "./validators"
export const authRoutesMiddlewares: MiddlewareRoute[] = [
{
method: ["POST"],
matcher: "/auth/session",
middlewares: [authenticate("*", "bearer")],
},
{
method: ["DELETE"],
matcher: "/auth/session",
middlewares: [authenticate("*", ["session"])],
},
{
method: ["POST"],
matcher: "/auth/token/refresh",
middlewares: [authenticate("*", "bearer", { allowUnregistered: true })],
},
{
method: ["POST"],
matcher: "/auth/:actor_type/:auth_provider/callback",
middlewares: [validateScopeProviderAssociation()],
},
{
method: ["POST"],
matcher: "/auth/:actor_type/:auth_provider/register",
middlewares: [validateScopeProviderAssociation()],
},
{
method: ["POST"],
matcher: "/auth/:actor_type/:auth_provider",
middlewares: [validateScopeProviderAssociation()],
},
{
method: ["GET"],
matcher: "/auth/:actor_type/:auth_provider",
middlewares: [validateScopeProviderAssociation()],
},
{
method: ["POST"],
matcher: "/auth/:actor_type/:auth_provider/reset-password",
middlewares: [
validateScopeProviderAssociation(),
validateAndTransformBody(ResetPasswordRequest),
],
},
{
method: ["POST"],
matcher: "/auth/:actor_type/:auth_provider/update",
middlewares: [validateScopeProviderAssociation(), validateToken()],
},
]