-
Notifications
You must be signed in to change notification settings - Fork 9
Add token generation tutorial #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9e29bf4
9b0ed9b
58d25a9
40f7086
fefcb6a
b82016c
5f56e0a
59217d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: "Generate a Development Token" | ||
description: "In this tutorial we will show you how to generate a development token for the self-hosted [PowerSync Service](https://powersync.mintlify.app/architecture/powersync-service#powersync-service)." | ||
--- | ||
|
||
<Steps> | ||
<Step title={"Generate a SharedSecret"}> | ||
To generate a SharedSecret, you can use this [Online JWS key generator](https://8gwifi.org/jwsgen.jsp) | ||
<Note> | ||
kobiebotha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
You don't need to edit the default payload in the [Online JWS key generator](https://8gwifi.org/jwsgen.jsp). | ||
You simply need a valid `SharedSecret` value. | ||
kobiebotha marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
</Note> | ||
- Click `Generate JWS Keys` | ||
- Copy the `SharedSecret` value | ||
|
||
</Step> | ||
|
||
<Step title={"Update powersync.yaml"}> | ||
Update the following in your `powersync.yaml` config file with the `SharedSecret` value copied in the previous step: | ||
- `k` value in your jwks keys, and | ||
- api token | ||
|
||
```yaml powersync.yaml {8, 16} | ||
# Client (application end user) authentication settings | ||
client_auth: | ||
# JWKS URIs can be specified here | ||
jwks_uri: !env PS_JWKS_URL | ||
jwks: | ||
keys: | ||
- kty: 'oct' | ||
k: 'YOUR_GENERATED_SHARED_SECRET' | ||
michaelbarnes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
alg: 'HS256' | ||
|
||
audience: ["powersync-dev", "powersync", "http://localhost:8080"] | ||
|
||
api: | ||
|
||
tokens: | ||
# These tokens are used for local admin API route authentication | ||
- YOUR_GENERATED_SHARED_SECRET | ||
``` | ||
</Step> | ||
|
||
<Step title={"Generate a development token"}> | ||
1. If you have not done so already, clone the [powersync-service repo](https://github.com/powersync-ja/powersync-service/tree/main) repo | ||
kobiebotha marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
2. Install the dependencies | ||
- In the project root, run the following commands: | ||
```bash | ||
pnpm install | ||
pnpm build:packages | ||
``` | ||
- In the `test-client` directory, run the following commands: | ||
```bash | ||
pnpm build | ||
``` | ||
3. Generate a new token by running the following command in the `test-client` directory with your updated `powersync.yaml` config file: | ||
```bash | ||
node dist/bin.js generate-token --config path/to/powersync.yaml --sub test-user | ||
``` | ||
You should see an output similar to the following: | ||
<Frame> | ||
<img src="/images/tutorials/self-host/token.png" /> | ||
</Frame> | ||
</Step> | ||
</Steps> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
--- | ||
title: "Coming Soon..." | ||
--- | ||
title: "Overview" | ||
description: "A collection of tutorials related to self-hosting." | ||
--- | ||
|
||
<CardGroup> | ||
<Card title="Generate a development token" icon="server" href="/tutorials/self-host/generate-dev-token" horizontal/> | ||
</CardGroup> |
Uh oh!
There was an error while loading. Please reload this page.