中文版本: README_cn.md
This is a DID WBA method example implemented using FastAPI and Agent_Connect library, supporting both client and server functionality.
For detailed technical documentation, please refer to Technical Documentation
- Supports DID WBA authentication protocol
- Implements two types of authentication:
- DID WBA initial authentication
- Bearer Token authentication
- Provides ad.json endpoint with authentication
- Automatically generates DID documents and private keys, or loads existing DIDs
- Initiates DID WBA authentication requests to the server
- Receives and processes access tokens
- Uses tokens for subsequent requests
- Clone the project
- Create environment configuration file
cp .env.example .env
- Edit the .env file and set necessary configuration items
# Create virtual environment and install dependencies with Poetry
poetry install
# Activate virtual environment
poetry shell
# Or activate virtual environment this way (if it already exists)
source .venv/bin/activate
To see the complete interaction, you must first start a server mode, then start the client mode. This is because the client needs to connect to a running server for authentication and interaction.
# Ensure virtual environment is activated
source .venv/bin/activate
# Start server in the first terminal window
python did_server.py
# Start client in the second terminal window, specifying a different port
python did_server.py --client --port 8001
# Run server on specific port
python did_server.py --port 8001
# Run client with specific id
python did_server.py --client --unique-id your_unique_id
The server will start on the specified port (default 8000), and you can access the API documentation at http://localhost:8000/docs
.
GET /agents/example/ad.json
: Get agent description informationGET /ad.json
: Get advertisement JSON data, requires authenticationPOST /auth/did-wba
: DID WBA initial authenticationGET /auth/verify
: Verify Bearer TokenGET /wba/test
: Test DID WBA authenticationGET /wba/user/{user_id}/did.json
: Get user DID documentPUT /wba/user/{user_id}/did.json
: Save user DID document
- Start server and listen for requests
- Receive DID WBA authentication requests and verify signatures
- Generate and return access tokens
- Handle subsequent requests using tokens
- Generate or load DID documents and private keys
- Send requests with DID WBA signature headers to the server
- Receive and save tokens
- Use tokens for subsequent requests
The example implements two authentication methods:
- Initial DID WBA Authentication: Signature verification according to DID WBA specification
- Bearer Token Authentication: Subsequent request authentication through JWT tokens
For detailed authentication flow, please refer to the code implementation and DID WBA Specification