A demo application showcasing the Vortex Go SDK integration with a Gin web server.
- 🔐 Authentication System: Session-based auth with JWT tokens
- ⚡ Vortex Integration: Full Vortex API integration for invitation management
- 🎯 JWT Generation: Generate Vortex JWTs for authenticated users
- 📧 Invitation Management: Get, accept, revoke, and reinvite functionality
- 👥 Group Management: Handle invitations by group type and ID
- 🌐 Interactive Frontend: Complete HTML interface to test all features
- Go 1.19 or later
- The Vortex Go SDK (automatically linked via workspace)
-
Navigate to the demo directory:
cd apps/demo-go -
Download dependencies:
go mod download
-
Set your Vortex API key (optional - defaults to demo key):
export VORTEX_API_KEY=your-api-key-here -
Set the port (optional - defaults to 3000):
export PORT=3000 -
Run the server:
go run src/server.go src/auth.go
-
Open your browser and visit:
http://localhost:3000
The demo includes two test users using the new simplified JWT format:
| Password | Autojoin Admin | Legacy Role | |
|---|---|---|---|
| admin@example.com | password123 | Yes | admin |
| user@example.com | userpass | No | user |
The demo showcases both the new simplified format (IsAutojoinAdmin) and the legacy format (Role + Groups) for educational purposes. See server.go for implementation details.
This demo uses Vortex's new JWT format with User struct:
// Create a User with admin scopes
vortexUser := &vortex.User{
ID: user.ID,
Email: user.Email,
}
if user.IsAutojoinAdmin {
vortexUser.AdminScopes = []string{"autojoin"}
}
// Generate JWT
jwt, err := vortexClient.GenerateJWT(vortexUser, nil)
// Or with extra properties
extra := map[string]interface{}{
"role": "admin",
"department": "Engineering",
}
jwt, err := vortexClient.GenerateJWT(vortexUser, extra)The JWT payload includes:
userId: User's unique IDuserEmail: User's email addressuserIsAutojoinAdmin: Set totruewhenAdminScopescontains"autojoin"- Any additional properties from the extra parameter
This replaces the legacy format with identifiers, groups, and role fields.
The demo implementation can be found in server.go lines 143-152.
POST /api/auth/login- Login with email/passwordPOST /api/auth/logout- Logout (clears session cookie)GET /api/auth/me- Get current user info
GET /api/demo/users- Get all demo usersGET /api/demo/protected- Protected route (requires auth)
All Vortex routes require authentication:
POST /api/vortex/jwt- Generate Vortex JWTGET /api/vortex/invitations- Get invitations by targetGET /api/vortex/invitations/:id- Get specific invitationDELETE /api/vortex/invitations/:id- Revoke invitationPOST /api/vortex/invitations/accept- Accept invitationsGET /api/vortex/invitations/by-group/:type/:id- Get group invitationsDELETE /api/vortex/invitations/by-group/:type/:id- Delete group invitationsPOST /api/vortex/invitations/:id/reinvite- Reinvite user
GET /health- Server health status
The demo supports the following environment variables:
VORTEX_API_KEY: Your Vortex API key (defaults to "demo-api-key")PORT: Server port (defaults to 3000)VORTEX_API_BASE_URL: Vortex API base URL (uses SDK default)
apps/demo-go/
├── src/
│ ├── server.go # Main server with routes
│ └── auth.go # Authentication system
├── public/
│ └── index.html # Frontend interface
├── go.mod # Go module definition
└── README.md # This file
The demo uses the Gin web framework for HTTP handling and includes:
- Session-based authentication with HTTP-only cookies
- CORS support for development
- Static file serving
- JSON request/response handling
- Error handling and validation
- Login: Use one of the demo users to authenticate
- Generate JWT: Test Vortex JWT generation for the authenticated user
- Query Invitations: Test invitation queries by target (email, username, etc.)
- Group Operations: Test group-based invitation operations
- Health Check: Verify the server status and configuration
The frontend provides an interactive interface to test all functionality without needing external tools.
This demo shows how to integrate the Vortex Go SDK with:
- Web frameworks (Gin)
- Authentication systems (JWT-based sessions)
- Frontend applications (static HTML/JS)
- Environment-based configuration
The same patterns can be applied to other Go web frameworks like Echo, Fiber, or the standard library.
- Import errors: Make sure you're running from the project root or the Go module path is correct
- Port conflicts: Change the PORT environment variable if 3000 is in use
- API errors: Check the Vortex API key and network connectivity
- Authentication issues: Clear browser cookies and try logging in again