You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RFC-0005 (Perfetto UI Server Extensions) defines a system where users can
configure HTTP(S) endpoints to serve Perfetto UI extensions (macros, SQL
modules, proto descriptors). These extension servers may require authentication
to access:
Stores credentials per-server - Each server has independent credentials
Auto-refreshes OAuth tokens - No manual token management required
Design
Authentication Flow
High-level flow for all servers:
User adds extension server URL in Settings
UI attempts to fetch /manifest.json without credentials
If 200 OK → Server is public, proceed
If 401/403 → Prompt user for credentials via provider-specific flow
Store credentials in localStorage (separate from settings)
Retry request with credentials
On subsequent requests, include stored credentials automatically
Auto-refresh OAuth tokens when they expire
Storage Schema
Extension Server configuration (in Perfetto settings localStorage):
interfaceServerSettings{servers: {[server_key: string]: {// Normalized server key (see RFC-0005 Appendix A)enabled: boolean;selected_modules: string[];// Display name from manifestdisplay_name?: string;};};}
To authorize Perfetto to access GitHub:
1. Visit: github.com/login/device
2. Enter code: ABCD-1234
[Copy Code] [Open GitHub]
Waiting for authorization...
User opens GitHub in separate tab/window and enters code
UI polls token endpoint every 5 seconds:
POST https://github.com/login/oauth/access_token
{
"client_id": "PERFETTO_GITHUB_CLIENT_ID",
"device_code": "3584d83...",
"grant_type": "urn:ietf:params:oauth:grant-type:device_code"
}
Retry original request with Authorization: Bearer {access_token}
Token Refresh:
Access tokens expire after 8 hours. When a request returns 401:
POST https://github.com/login/oauth/access_token
{
"client_id": "PERFETTO_GITHUB_CLIENT_ID",
"grant_type": "refresh_token",
"refresh_token": "ghr_..."
}
GitHub returns new access token and refresh token. Update stored credentials.
Note: GitHub Device Flow refresh tokens do NOT require client secret.
Per-Server Authentication:
Each github:// URL gets independent credentials. This supports multiple
accounts (e.g., personal github://user1/repo and work github://org/repo with
different auth).
Requires Perfetto backend (violates "no backend" principle)
Users must create Perfetto accounts
Doesn't work for corporate internal servers
Hard Rejected - Fundamentally incompatible with architecture
Open Questions
Q1: Should we support OAuth client secrets for GitHub?
Context: GitHub Device Flow doesn't require client secrets, but traditional
OAuth flows do.
Current Decision: No. Device Flow is sufficient and simpler.
Rationale: Client secrets can't be kept secret in client-side JavaScript
anyway. Device Flow is the recommended approach for native/mobile apps and works
well here.
Q2: Should we support multiple GitHub accounts per server?
Context: User might want to access same repo with different GitHub accounts
depending on context.
Current Decision: No for MVP. Each server URL gets one credential set.
Workaround: Add the same repo twice with different URL paths (e.g., github://org/repo/main and github://org/repo/main/ with trailing slash maps
to different server key).
Future: Could add "account switcher" in Settings if users request it.
Q3: Should credentials have expiration/TTL beyond OAuth token expiration?
Context: Security best practice is to expire credentials periodically.
Current Decision: No explicit TTL beyond OAuth token expiration.
Rationale:
OAuth tokens already expire (8 hours for GitHub)
Users can delete credentials manually
Adding TTL adds complexity without clear benefit
If users want to rotate, they can delete and re-add
Q4: How to handle credential conflicts when adding same server twice?
Context: User adds github://org/repo/main twice (maybe deleted and
re-added).
Current Decision: Overwrite existing credentials for the same server key.
UI Flow:
Detect server key already exists
Show warning: "This server already exists. Re-authenticate to update
credentials?"
On confirm → Delete old credentials → Run auth flow → Store new credentials
Q5: Should we support password managers (autofill)?
Context: Browser password managers can autofill username/password for Basic
auth.
Current Decision: Yes, use standard HTML input elements with appropriate autocomplete attributes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
📄 RFC Doc: 0006-extension-server-authentication.md
Extension Server Authentication
Authors: @LalitMaganti
Status: Draft
Problem
RFC-0005 (Perfetto UI Server Extensions) defines a system where users can
configure HTTP(S) endpoints to serve Perfetto UI extensions (macros, SQL
modules, proto descriptors). These extension servers may require authentication
to access:
restricted access
The authentication system needs to:
Decision
Implement a flexible authentication system that:
Basic auth
Design
Authentication Flow
High-level flow for all servers:
/manifest.json
without credentialsStorage Schema
Extension Server configuration (in Perfetto settings localStorage):
Credentials (separate localStorage key
perfetto_server_credentials
):GitHub OAuth (Device Flow)
Why Device Flow?
Prerequisites:
Flow:
User adds
github://owner/repo/ref
server in SettingsUI attempts fetch without auth → receives 401/403
UI requests device code:
GitHub returns:
UI shows modal with instructions:
User opens GitHub in separate tab/window and enters code
UI polls token endpoint every 5 seconds:
On success, GitHub returns:
Store both tokens in
perfetto_server_credentials
Retry original request with
Authorization: Bearer {access_token}
Token Refresh:
Access tokens expire after 8 hours. When a request returns 401:
GitHub returns new access token and refresh token. Update stored credentials.
Note: GitHub Device Flow refresh tokens do NOT require client secret.
Per-Server Authentication:
Each
github://
URL gets independent credentials. This supports multipleaccounts (e.g., personal
github://user1/repo
and workgithub://org/repo
withdifferent auth).
URL Resolution:
github://owner/repo/ref
→https://raw.githubusercontent.com/owner/repo/ref
raw-githubusercontent-com-owner-repo-ref
)Google Cloud Storage (GCS)
Flow:
gs://bucket/path
serverauth.currentUser.get().getAuthResponse().access_token
perfetto_server_credentials
Authorization: Bearer {token}
Token Refresh:
Use Google Identity Services library to handle automatic token refresh:
URL Resolution:
gs://bucket/path
→https://storage.googleapis.com/bucket/path
AWS S3
Flow:
User adds
s3://bucket/path
serverUI attempts fetch without auth → receives 401/403
UI shows credential input dialog:
User enters credentials
Store credentials in
perfetto_server_credentials
Sign requests using AWS Signature Version 4 (SigV4)
Retry request with signed headers
SigV4 Signing:
Use aws4fetch library for client-side SigV4 signing:
URL Resolution:
s3://bucket/path
→https://bucket.s3.amazonaws.com/path
HTTP/HTTPS (Generic)
Flow:
https://server.example.com
serverWWW-Authenticate
response header:Bearer realm="..."
→ Prompt for Bearer tokenBasic realm="..."
→ Prompt for username/passwordperfetto_server_credentials
Authorization
headerBearer Token:
Basic Auth:
Server Addition Flow (Settings UI)
Step-by-step:
github://
,gs://
,s3://
)/manifest.json
:form)
Credential Management UI
Settings → Extension Servers → [Server] → Credentials:
gho_••••••••••••••••
••••••••••
Credential List:
Server Removal
When user removes a server from Settings:
perfetto_server_credentials
Error Handling
Common error scenarios:
Expired token (401):
re-authenticate."
Invalid credentials (401/403):
Network error:
CORS error:
Security Considerations
Credential Storage:
Browser's same-origin protection is the security boundary.
No credential encryption because:
User controls:
OAuth security:
CORS requirements:
All HTTPS servers must set CORS headers:
Implementation Timeline
Phase 1: Core Auth Infrastructure
Phase 2: GitHub OAuth
Phase 3: Cloud Storage
Phase 4: Generic HTTPS
Phase 5: Polish
Alternatives Considered
Alternative 1: Proxy Server for Auth
Approach: Run a Perfetto-managed proxy server that handles auth and forwards
requests.
Pros:
Cons:
Alternative 2: Browser Extension for Credentials
Approach: Build a browser extension to manage credentials with OS keychain
integration.
Pros:
Cons:
Alternative 3: Service Worker as Credential Manager
Approach: Use service worker to intercept requests and inject credentials.
Pros:
Cons:
Alternative 4: Server-Side Session Tokens
Approach: Perfetto backend issues session tokens, stores credentials
server-side.
Pros:
Cons:
Open Questions
Q1: Should we support OAuth client secrets for GitHub?
Context: GitHub Device Flow doesn't require client secrets, but traditional
OAuth flows do.
Current Decision: No. Device Flow is sufficient and simpler.
Rationale: Client secrets can't be kept secret in client-side JavaScript
anyway. Device Flow is the recommended approach for native/mobile apps and works
well here.
Q2: Should we support multiple GitHub accounts per server?
Context: User might want to access same repo with different GitHub accounts
depending on context.
Current Decision: No for MVP. Each server URL gets one credential set.
Workaround: Add the same repo twice with different URL paths (e.g.,
github://org/repo/main
andgithub://org/repo/main/
with trailing slash mapsto different server key).
Future: Could add "account switcher" in Settings if users request it.
Q3: Should credentials have expiration/TTL beyond OAuth token expiration?
Context: Security best practice is to expire credentials periodically.
Current Decision: No explicit TTL beyond OAuth token expiration.
Rationale:
Q4: How to handle credential conflicts when adding same server twice?
Context: User adds
github://org/repo/main
twice (maybe deleted andre-added).
Current Decision: Overwrite existing credentials for the same server key.
UI Flow:
credentials?"
Q5: Should we support password managers (autofill)?
Context: Browser password managers can autofill username/password for Basic
auth.
Current Decision: Yes, use standard HTML input elements with appropriate
autocomplete
attributes.Implementation:
This allows password managers to recognize and autofill credentials.
Appendix A: GitHub App Registration
Settings for Perfetto GitHub App:
After registration:
Appendix B: Testing Strategy
Unit Tests:
Integration Tests:
E2E Tests:
Manual Testing:
Appendix C: Libraries and Dependencies
GitHub OAuth:
GCS OAuth:
https://accounts.google.com/gsi/client
S3 Signing:
aws4fetch
Basic Auth:
btoa()
for Base64 encodingTypeScript Types:
💬 Discussion Guidelines:
Beta Was this translation helpful? Give feedback.
All reactions