A Hono-based implementation of the au3te-ts server for OAuth 2.0 and OpenID Connect operations.
Register your service and client (and organization if needed) on the Authlete console. Required configuration information:
- Service ID
- Service Access Token
- Client ID
- Redirect URL
For setup instructions, see here
git clone https://github.com/dentsusoken/au3te-ts-hono
cd au3te-ts-hononpm installCreate a .dev.vars file in the project root:
API_BASE_URL=https://jp.authlete.com
API_VERSION=V3
API_KEY=YOUR_SERVICE_ID
ACCESS_TOKEN=YOUR_ACCESS_TOKEN- Create KV namespaces for local development:
npx wrangler kv namespace create "SESSION_KV"
npx wrangler kv namespace create "USER_KV"
npx wrangler kv namespace create "MDOC_KV"- Find your KV namespace IDs:
npx wrangler kv namespace listThis will show output like:
[
{
"id": "8b4ec28a716544169c2814a6ca02cb76",
"title": "SESSION_KV",
"supports_url_encoding": true,
"beta": false
},
{
"id": "3ff4347455a94aea9507aba0881f2ec4",
"title": "USER_KV",
"supports_url_encoding": true,
"beta": false
},
{
"id": "2cf695d7db584e2b82f475a4f719787b",
"title": "MDOC_KV",
"supports_url_encoding": true,
"beta": false
}
]- Set environment variables with your KV IDs:
Create a .env.local file:
SESSION_KV_ID=8b4ec28a716544169c2814a6ca02cb76
USER_KV_ID=3ff4347455a94aea9507aba0881f2ec4
MDOC_KV_ID=2cf695d7db584e2b82f475a4f719787b- Ignore
wrangler.tomlchanges in git (recommended for local development):
git update-index --assume-unchanged wrangler.tomlThis prevents accidental commits of your local KV namespace IDs while allowing you to modify the file for local development.
- Update
wrangler.tomlwith your local KV namespace IDs:
# Use the provided script to automatically update wrangler.toml
./shell/update-wrangler-kv-ids.shThis script reads the KV namespace IDs from your .env.local file and updates the placeholders in wrangler.toml.
To commit changes to wrangler.toml when needed:
# Temporarily track the file
git update-index --no-assume-unchanged wrangler.toml
# Add and commit your changes
git add wrangler.toml
git commit -m "Update wrangler.toml configuration"
# Resume ignoring the file
git update-index --assume-unchanged wrangler.tomlOptional: Create aliases for easier management:
# Add these to your ~/.zshrc or ~/.bashrc
alias ignore-wrangler="git update-index --assume-unchanged wrangler.toml"
alias track-wrangler="git update-index --no-assume-unchanged wrangler.toml"
# Reload your shell configuration
source ~/.zshrc # or source ~/.bashrcThen you can use:
ignore-wranglerto ignore wrangler.toml changestrack-wranglerto track wrangler.toml changes
- (Optional) Add test data to your KV namespaces:
# Add user data to USER_KV
./shell/kv-put.sh USER_KV 1004 "$(cat data/user.json)"
# Add mdoc data to MDOC_KV
./shell/kv-put.sh MDOC_KV 1004 "$(cat data/mdoc.json)"
# Verify the data
./shell/kv-get.sh USER_KV 1004
./shell/kv-get.sh MDOC_KV 1004Note: The kv-put.sh and kv-get.sh scripts automatically read namespace IDs from your .env.local file.
The project includes helper scripts in the shell/ directory for easy KV operations:
# Update wrangler.toml with KV namespace IDs from .env.local
./shell/update-wrangler-kv-ids.shThis script automatically updates the KV namespace IDs in wrangler.toml using the values from your .env.local file.
# Put data to KV
./shell/kv-put.sh <namespace> <key> <value>
# Examples
./shell/kv-put.sh USER_KV 1004 '{"name":"test"}'
./shell/kv-put.sh USER_KV 1004 "$(cat data/user.json)"
./shell/kv-put.sh MDOC_KV 1004 "$(cat data/mdoc.json)"# Get data from KV
./shell/kv-get.sh <namespace> <key>
# Examples
./shell/kv-get.sh USER_KV 1004
./shell/kv-get.sh MDOC_KV 1004
./shell/kv-get.sh SESSION_KV session123Available namespaces: SESSION_KV, USER_KV, MDOC_KV
npm run devnpm run deployThis section describes the setup procedure for the au3te-ts-hono application in an AWS Lambda environment.
- Docker installed
- VSCode Dev Container available
Copy the .env.template file to create a .env file and configure your AWS credentials.
cp .env.template .envSet the following information in the .env file:
# AWS credentials
AWS_PROD_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY_ID
AWS_PROD_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY
AWS_PROD_REGION=YOUR_AWS_REGION
AWS_ECR_REPOSITORY=YOUR_ECR_REPOSITORY
# LocalStack configuration (for local development)
LOCALSTACK_ACCESS_KEY_ID=test
LOCALSTACK_SECRET_ACCESS_KEY=test
LOCALSTACK_ENDPOINT_URL=http://localstack:4566
LOCALSTACK_REGION=ap-northeast-1
LOCALSTACK_ECR_REPOSITORY=Start the Dev Container in VSCode:
- Open the project in VSCode
- Open the command palette (Ctrl+Shift+P)
- Select "Dev Containers: Reopen in Container"
- Wait for the container to start
When using LocalStack as a local development environment:
# Deploy to LocalStack
./shell/deployLocalStack.shAfter deployment, configure appropriate secret information in SecretsManager.
When deploying to AWS production environment:
# Deploy to AWS production environment
./shell/deployAws.shFor initial deployment or when cleanup is needed:
# Deploy with cleanup
./shell/deployAws.sh --cleanAfter deployment, configure appropriate secret information in AWS SecretsManager.
Script for deploying to LocalStack environment:
- Cleanup of S3 bucket and SAM stack
- Build SAM application
- Deploy to LocalStack
- Upload CSS files to S3
Script for deploying to AWS production environment:
--cleanoption for deployment with cleanup- Cleanup of S3 bucket and SAM stack
- Build SAM application
- Deploy to AWS production environment
- Upload CSS files to S3
This project is licensed under the Apache License, Version 2.0.