Knowledge Base API Key Context (auth/KbApiKeyContext.java)

mateclaw · mateclaw-server/src/main/java/vip/mate/kbopen/auth/KbApiKeyContext.java · java · Apache-2.0
auth, security, lang:java, tag:context

Carries resolved API key identity and scopes for controller-level authorization without database queries. Reuse when securing custom API endpoints.

// Source: https://github.com/mateaix/mateclaw | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package vip.mate.kbopen.auth;

import java.util.Set;

/**
 * Authentication context injected by {@code KbOpenApiAuthFilter} into each
 * request's attributes. Carries the resolved API key identity (keyId,
 * workspace, bound KBs, scopes) so that Controller-layer authorization
 * (via {@code @RequireKbScope}) can check access without re-querying the DB.
 *
 * <p>This is intentionally <strong>not</strong> a Spring Security
 * {@code Authentication} — KB API Keys do not represent a user identity and
 * must not inherit user-level permissions. The filter writes to a request
 * attribute inst

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key