Skip to content

Commit

Permalink
chore(docs): Add performance section
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraBeatris committed Apr 9, 2024
1 parent cfe61f0 commit e624809
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/pages/design/next/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ A live example can be found at **[m2m-auth.vercel.app](https://m2m-auth.vercel.a

Managing keys in the UI should be as easy as rendering a component. Eliminating the need for developers to directly interact with the auth provider to build the UI from scratch.

```tsx
import { ApiKeyManager } from '@clerk/nextjs';
```tsxs
import { ApiKeyManager } from '@clerk/react';
export default function Page() {
return <ApiKeyManager />;
Expand All @@ -46,15 +46,15 @@ Clerk could expose a similar (or even the same - dogfooding) UI component as in

Besides the UI component, some utilities could also be exposed to manage API keys from the client-side.

React Hooks, such as: `useApiKeys()`
React Hooks, such as: `useApiKeyManager()`

```tsx
"use client";

import { useApiKeys } from "@clerk/clerk-react";
import { useApiKeyManager } from "@clerk/clerk-react";

export default function Page() {
const { apiKeys, createApiKeys } = useApiKeys();
const { apiKeys, createApiKeys } = useApiKeyManager();

return (...);
}
Expand Down
7 changes: 7 additions & 0 deletions docs/pages/design/node/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Clerk is used as the auth provider for this example. Although Clerk doesn't expo
- [Keys revocation](#keys-revocation)
- [Identify external client within the request](#identify-external-client-within-the-request)
- [Security considerations](#security-considerations)
- [Performance](#performance)

### Creating keys

Expand Down Expand Up @@ -135,3 +136,9 @@ example_b7d9c32y98e5432abc5f6def0yyyy_4241314
The checksum `_4241314` allows to quickly validate keys in the request pipeline, rejecting invalid ones to reduce load on the API key store.
That checksum can also be a signed hash. The signing authority can be confident whether it was generated by system, and rejecting invalid keys without doing a database check.
### Performance
Requests to manage keys should be as fast as possible. A in-memory cache can be used to store keys in order to perform a database roundtrip on every single read.
For security, it's recommended to perform caching only hashed key versions and perform pre-hash collision checks during key creation to avoid collisions.

0 comments on commit e624809

Please sign in to comment.