Effect CommunityEC
Effect Community8mo ago
2 replies
amg

How to Process and Validate a Token in Authorization Middleware

Hi, I was trying to put an Authorization middleware
// Create the Authorization middleware
export class Authorization extends HttpApiMiddleware.Tag<Authorization>()(
  "Authorization",
  {
    // Define the error schema for unauthorized access
    failure: Unauthorized,
    // Specify the resource this middleware will provide
    // provides: CurrentUser,
    // Add security definitions
    security: {
      // ┌─── Custom name for the security definition
      // ▼
      token: HttpApiSecurity.apiKey({
        in: "header",
        key: "hi",
      }),
      // Additional security definitions can be added here.
      // They will attempt to be resolved in the order they are defined.
    },
  },
) {}


I want to process the token that the user is sending in orther to validate it but I see that the key is mandatory and should be string. How it is possible to achieve this?
Was this page helpful?