Skip to content

Add Google Identity-Aware Proxy (IAP) support - #293

Open
sharoonthomas wants to merge 2 commits into
szabodanika:masterfrom
sharoonthomas:google-iap
Open

Add Google Identity-Aware Proxy (IAP) support#293
sharoonthomas wants to merge 2 commits into
szabodanika:masterfrom
sharoonthomas:google-iap

Conversation

@sharoonthomas

@sharoonthomas sharoonthomas commented Jul 15, 2025

Copy link
Copy Markdown

Add support for Google Cloud Identity-Aware Proxy to automatically identify and track users creating pastas when deployed behind Google IAP.

Changes

  • Add MICROBIN_ENABLE_GOOGLE_IAP environment variable to enable/disable IAP support
  • Add author field to Pasta struct to store user identification
  • Implement extract_google_iap_user() function to parse IAP headers
  • Update create endpoint to extract and store author information from request headers
  • Update database schemas (SQLite and JSON) to include author field
  • Add author display in pasta view and list templates
  • Maintain backward compatibility - existing pastas without author info work normally

Technical Details

Google IAP sends user information in HTTP headers:

  • X-Goog-Authenticated-User-Email: "accounts.google.com:user@example.com"
  • X-Goog-Authenticated-User-Id: "accounts.google.com:123456789"

The implementation prioritizes email addresses over user IDs for better
user experience. When IAP is disabled, the feature is completely inactive.

Usage

Local Development

# Test with simulated IAP headers
MICROBIN_ENABLE_GOOGLE_IAP=true cargo run

# Test with curl
curl -X POST http://localhost:8080/upload \
  -H "X-Goog-Authenticated-User-Email: accounts.google.com:test@example.com" \
  -F "content=Hello World"

Production Deployment

  1. Deploy to Google Cloud Run (or other services) with Identity-Aware Proxy enabled
  2. Set environment variable: MICROBIN_ENABLE_GOOGLE_IAP=true
  3. Users will be automatically identified and their email/ID stored with each pasta

Benefits

  • User Accountability: Track who created each pasta for audit purposes
  • Enterprise Ready: Integrates with Google Workspace authentication
  • Zero Configuration: Works automatically when IAP is enabled
  • Backward Compatible: Existing installations continue to work unchanged
  • Privacy Conscious: Only stores user info when explicitly enabled

Database Migration

Existing databases will automatically handle the new author field:

  • SQLite: New column added as nullable TEXT
  • JSON: Existing entries will have author: null

No manual migration required for existing installations.

Add support for Google Cloud Identity-Aware Proxy to automatically identify
and track users creating pastas when deployed behind Google IAP.
@sharoonthomas

Copy link
Copy Markdown
Author

@szabodanika Would love some feedback on the implementation and if this makes sense?

I could not find where the docs are either.

@szabodanika szabodanika added the enhancement New feature or request label Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants