This guide explains how to set up GitHub OAuth authentication for FDS Agent to enable automatic deployment of builds to GitHub repositories.
The FDS Agent now supports GitHub OAuth authentication, allowing users to:
https://your-domain.com)https://your-domain.com/auth/github/callbackImportant: Keep your Client Secret secure and never commit it to version control.
Set the following environment variables in your FDS Agent deployment:
# Required
GITHUB_APP_CLIENT_ID=your_client_id_here
GITHUB_APP_CLIENT_SECRET=your_client_secret_here
# Optional
JWT_SECRET=your_random_secret_for_jwt_signing # Defaults to "change-me-in-production"
BASE_URL=https://your-domain.com # Defaults to http://localhost:4000
Update your deployment YAML file (e.g., staging.yml, production.yml):
env:
- name: GITHUB_APP_CLIENT_ID
value: 'your_client_id'
- name: GITHUB_APP_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: github-oauth-secret
key: client_secret
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: jwt-secret
key: secret
- name: BASE_URL
value: 'https://your-domain.com'
Create Kubernetes secrets:
kubectl create secret generic github-oauth-secret \
--from-literal=client_secret='your_client_secret' \
-n your-namespace
kubectl create secret generic jwt-secret \
--from-literal=secret='your_random_jwt_secret' \
-n your-namespace
cd /path/to/fds-agent
npm install
This will install the new jsonwebtoken dependency.
# If running locally
node agent.js
# If using Docker
docker-compose restart fds-agent
# If using Kubernetes
kubectl rollout restart deployment/base-layouts-production -n your-namespace
Navigate to the Auth Page:
https://your-fds-agent-url/auth/index.htmlAuthorize with GitHub:
Generate JWT Token:
Use the Token:
/process API calls:POST /process
{
"projectName": "my-project",
"target": "www",
"githubJwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"recipe": { ... }
}
branch, license, and gqlSchemaMinVersion are filled by the agent automatically (branch from build-info, license always FREE).
GET /auth/github/start
Response:
{
"redirectUrl": "https://github.com/login/oauth/authorize?client_id=...",
"state": "random_state_token"
}
GET /auth/github/callback?code=xxx&state=xxx
Redirects to /auth/success.html?session=xxx
GET /auth/session/:sessionId
Response:
{
"user": {
"login": "username",
"id": 12345,
"name": "User Name"
},
"orgs": [
{ "login": "org-name", "id": 67890 }
],
"repos": [
{
"full_name": "username/repo",
"default_branch": "main",
"permissions": { "admin": true, "push": true },
"owner": { "login": "username", "type": "User" }
}
]
}
POST /auth/create-repo
Content-Type: application/json
{
"sessionToken": "session_token_from_callback",
"owner": "org-or-user-login",
"name": "new-repo-name",
"private": false
}
Response:
{
"repo": {
"full_name": "org-or-user-login/new-repo-name",
"default_branch": "main",
"owner": { "login": "org-or-user-login", "type": "Organization" },
"permissions": { "admin": true, "push": true },
"private": false
},
"sessionToken": "updated_session_token_with_new_repo"
}
POST /auth/generate-jwt
Content-Type: application/json
{
"sessionToken": "session_token_from_callback",
"repo": "username/repository",
"branch": "main",
"path": "dist"
}
Response:
{
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"payload": {
"repo": "username/repository",
"branch": "main",
"path": "dist",
"user": "username",
"iat": 1234567890
},
"note": "Use this JWT in the 'githubJwt' field when calling /process endpoint. The GitHub OAuth access token is encrypted inside the JWT data field."
}
JWT Secret: Always use a strong, random JWT secret in production. Generate one using:
openssl rand -base64 32
HTTPS: Always use HTTPS in production to protect OAuth tokens in transit.
Session Storage: Session details (including the GitHub OAuth access token) are encrypted into the JWT; the server does not persist session data in memory.
Token Expiration: JWT tokens expire after 30 days by default. Users will need to regenerate tokens after expiration.
Permissions: The OAuth flow requests the repo and workflow scopes. The repo scope gives full repository access, and the workflow scope allows creating/updating GitHub Actions workflow files. Users should only authorize repositories they want the agent to access.
GITHUB_APP_CLIENT_ID and GITHUB_APP_CLIENT_SECRET are set in environment variables/auth/index.html to obtain a fresh tokenhttps://your-domain.com/auth/github/callbackBASE_URL environment variable is set correctlyFor local testing, use a tool like ngrok to expose your local server:
ngrok http 4000
Use the ngrok URL in your GitHub OAuth App settings:
https://your-ngrok-url.ngrok.iohttps://your-ngrok-url.ngrok.io/auth/github/callbackSet environment variables:
export GITHUB_APP_CLIENT_ID=your_client_id
export GITHUB_APP_CLIENT_SECRET=your_client_secret
export BASE_URL=https://your-ngrok-url.ngrok.io
node agent.js
Navigate to https://your-ngrok-url.ngrok.io/auth/index.html
Environment GitHub tokens are no longer used for publishing. OAuth-issued access tokens are now encrypted inside the generated JWT and are required for git push operations. Ensure users complete the OAuth flow and use the generated JWT from /auth/generate-jwt in /process calls.
For issues or questions:
kubectl logs -f deployment/base-layouts-production -n your-namespace