pub struct ApiKeyPlugin { /* private fields */ }Expand description
API Key management plugin.
Implementations§
Source§impl ApiKeyPlugin
impl ApiKeyPlugin
Sourcepub async fn create_key(
&self,
ctx: &AuthContext<impl AuthSchema>,
body: &CreateKeyRequest,
) -> AuthResult<CreateKeyResponse>
pub async fn create_key( &self, ctx: &AuthContext<impl AuthSchema>, body: &CreateKeyRequest, ) -> AuthResult<CreateKeyResponse>
Create a key on behalf of body.user_id from trusted server code.
Organization configurations still require the user’s organization permission.
Sourcepub async fn update_key(
&self,
ctx: &AuthContext<impl AuthSchema>,
body: &UpdateKeyRequest,
) -> AuthResult<ApiKeyView>
pub async fn update_key( &self, ctx: &AuthContext<impl AuthSchema>, body: &UpdateKeyRequest, ) -> AuthResult<ApiKeyView>
Update a key on behalf of body.user_id from trusted server code.
The caller must authorize access before invoking this server-only method.
Source§impl ApiKeyPlugin
impl ApiKeyPlugin
Sourcepub async fn verify_api_key(
&self,
input: &VerifyApiKey<'_>,
ctx: &AuthContext<impl AuthSchema>,
) -> Result<ApiKeyView, ApiKeyVerificationError>
pub async fn verify_api_key( &self, input: &VerifyApiKey<'_>, ctx: &AuthContext<impl AuthSchema>, ) -> Result<ApiKeyView, ApiKeyVerificationError>
Verify a machine credential without a user session or public HTTP endpoint.
A successful verification consumes quota and a rate-limit slot. Permissions and configuration mismatches do not consume usage. The returned key omits the plaintext credential and stored hash.
Without config_id, lookup uses the default configuration’s hashing
setting. Validation then uses the configuration that issued the key.
Source§impl ApiKeyPlugin
impl ApiKeyPlugin
Sourcepub fn configuration(self, config: ApiKeyConfig) -> Self
pub fn configuration(self, config: ApiKeyConfig) -> Self
Register an additional named configuration.
Upstream allows several api-key configurations side by side, each with
its own config_id, ownership model and limits.
Source§impl ApiKeyPlugin
Builder for ApiKeyPlugin powered by the bon crate.
impl ApiKeyPlugin
Builder for ApiKeyPlugin powered by the bon crate.
Usage:
let plugin = ApiKeyPlugin::builder()
.key_length(48)
.prefix("ba_".to_string())
.enable_metadata(true)
.rate_limit(RateLimitDefaults { enabled: true, time_window: 60_000.0, max_requests: 5.0 })
.build();