Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/serkodev/cloudflare-kv-server
Cloudflare KV Server with JWT auth (Cloudflare Workers® ready)
https://github.com/serkodev/cloudflare-kv-server
cloudflare cloudflare-workers jwt jwt-authentication kv proxy worker workers workers-kv
Last synced: 3 months ago
JSON representation
Cloudflare KV Server with JWT auth (Cloudflare Workers® ready)
- Host: GitHub
- URL: https://github.com/serkodev/cloudflare-kv-server
- Owner: serkodev
- License: mit
- Created: 2022-10-07T08:46:01.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-05T08:47:42.000Z (about 1 year ago)
- Last Synced: 2024-01-05T09:41:57.554Z (about 1 year ago)
- Topics: cloudflare, cloudflare-workers, jwt, jwt-authentication, kv, proxy, worker, workers, workers-kv
- Language: TypeScript
- Homepage:
- Size: 848 KB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cloudflare-kv-server
One-click deploy a KV server to Cloudflare Workers. It is similar to [Cloudflare API for KV](https://api.cloudflare.com/#workers-kv-namespace-list-a-namespace-s-keys) but you just need a self-generate JWT token instead of using Cloudflare auth key and email. You can also customize each JWT token with expiry date, action permissions or whitelist key patterns.
## Deploy to Cloudflare Workers
1. Clone this repo
2. Config `wrangler.toml` and set `name`, `kv_namespaces`
4. Run `wrangler login` and `wrangler publish`### Auth Token
Its optional but recommend to set a Secret to protect your endpoint. You can either set `AUTH_SECRET` in `wrangler.toml` or set a secret binding in Cloudflare Workers dashboard to increase security.
After setting a Secret, you can use [Online Token Generator](https://cf-kv-server-token-gen.pages.dev/) to generate token or build it yourself (`./packages/auth-token-gen`).
Please make sure you use the same Secret to match the token generator.
## Client API
### Auth header
If you setup an auth secret and generated a token please include it in `Authorization` HTTP header field with `Bearer ` value. For example:```
Authorization: Bearer xxxxxx.xxxxxxxxxxx.xxxxxxxxxxxxxx
```### End points
List keys
> Permission: List
```
GET :namespace_identifier/keysURL Query Params:
limit, cursor, prefix
```Get value
> Permission: Get
```
GET :namespace_identifier/values/:key_nameURL Query Params:
cache_ttl
```Get value metadata
> Permission: GetWithMetaData
```
GET :namespace_identifier/values_metadata/:key_nameURL Query Params:
cache_ttl
```Put value to key
> Permission: Put
```
PUT :namespace_identifier/values/:key_nameURL Query Params:
expiration, expiration_ttl, metadata
```Delete key
> Permission: Delete
```
DELETE :namespace_identifier/values/:key_name
```