-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9e29bf4
Add token generation tutorial
9b0ed9b
Remove references to API token
58d25a9
Add warning
40f7086
Fix typos and add sections
fefcb6a
Update indentation
b82016c
Merge branch 'docs' into tutorial/dev-token
HeinrichvonStein 5f56e0a
Merge branch 'docs' into tutorial/dev-token
michaelbarnes 59217d6
Merge branch 'docs' into tutorial/dev-token
michaelbarnes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
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)." | ||
--- | ||
|
||
# Introduction | ||
|
||
Development tokens are useful for: | ||
- getting started quickly without implementing full auth config | ||
- sanity checking your sync rules config (were they applied correctly) | ||
- temporarily impersonating a specific user to debug specific issues | ||
|
||
# Use Case | ||
|
||
Development tokens can be used either with the | ||
- [test-client](https://github.com/powersync-ja/powersync-service/tree/main/test-client), or | ||
- [the diagnostics app](/resources/troubleshooting#diagnostics-app) | ||
|
||
# Generate a Development Token | ||
Development tokens can be generated via either | ||
- [PowerSync Cloud](/installation/authentication-setup/development-tokens/#PowerSync-Cloud-Dashboard), or | ||
- locally with a self-hosted setup (described in this tutorial) | ||
|
||
<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 to obtain the generated `SharedSecret` value. | ||
</Note> | ||
- Click `Generate JWS Keys` | ||
- Copy the `SharedSecret` value | ||
<Warning> | ||
Using an online key generator for secrets in a production environment is not recommended. | ||
</Warning> | ||
</Step> | ||
|
||
<Step title={"Update powersync.yaml"}> | ||
Update the `k` value in the jwks keys in your `powersync.yaml` config file with the `SharedSecret` value copied in the previous step: | ||
```yaml powersync.yaml {8} | ||
# 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' | ||
alg: 'HS256' | ||
``` | ||
</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) | ||
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> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.