Ghost
Ghost ๐ป: A headless identity and OTP authentication engine for Frappe. Centralizes Guest Sessions, Secure Login, and seamless Ghost-to-Real User conversion for building modern Web & Mobile apps.
- Author: muneeb141
- Repository: https://github.com/muneeb141/ghost
- GitHub stars: 19
- Forks: 5
- License: MIT
- Category: Other
- Maintenance: Actively Maintained
- Frappe versions: develop
Install Ghost
bench get-app https://github.com/muneeb141/ghost
Add the Frappe Gems badge to your README
Maintain Ghost? Paste this into your README:
[](https://frappegems.com/gems/apps/muneeb141/ghost)
About Ghost
๐ป Ghost
Let users browse anonymously, convert them when they're ready.
Stop losing customers at the signup wall. Ghost turns anonymous visitors into authenticated users without breaking their flow.
# Install
bench get-app https://github.com/muneeb141/ghost
bench --site your-site install-app ghost
โก Quick Start (3 minutes)
- Create OAuth Client โ Setup > Integrations > OAuth Client
- Enable Ghost โ Setup > Ghost Settings โ Paste Client ID
- Done! Test with curl:
curl -X POST http://your-site:8000/api/method/ghost.api.ghost.create_ghost_session
What you get back:
{
"user": "ghost_abc123@guest.local",
"access_token": "...", // Use this to make authenticated requests
"refresh_token": "...", // Use this to get new access tokens
"expires_in": 3600 // Token valid for 1 hour
}
๐ฏ What Problem Does This Solve?
Before Ghost: - User visits your site โ Signup wall โ 70% bounce - Mobile app โ Complex login flow โ User drops off - E-commerce โ "Add to cart" requires account โ Lost sale
After Ghost: 1. User arrives โ Gets temporary "ghost" identity instantly 2. Browses, adds to cart, saves favorites โ All tracked 3. Ready to checkout โ Quick OTP โ Becomes real user 4. All data preserved! Cart, favorites, browsing history
Perfect for: - ๐ E-commerce (browse โ cart โ checkout โ sign up) - ๐ฑ Mobile apps (explore โ authenticate when needed) - ๐ฐ Content platforms (read โ save โ register) - ๐ผ SaaS (try features โ upgrade โ convert)
๐ How It Works
Anonymous User
โ
Create Ghost Session โ Get Bearer Token
โ
Browse, Add to Cart โ Authenticated as ghost_abc123@guest.local
โ
Ready to Convert โ Send OTP to email
โ
Enter OTP โ Convert to user@example.com
โ
All cart data stays! โ New tokens for real user
Under the hood:
- OAuth2 bearer tokens (industry standard, super secure)
- No cookies needed (perfect for mobile/SPAs)
- Tokens expire & refresh automatically
- Fast split conversion path:
- Rename path when real_email does not exist (ghost user is renamed)
- Manual migration path when real_email already exists (app-owned ghost data is reassigned, no heavy framework User merge)
๐ฑ Frontend Integration (Copy-Paste Ready)
JavaScript/React/Vue
// 1. Create ghost on page load
const response = await fetch('/api/method/ghost.api.ghost.create_ghost_session', {
method: 'POST'
});
const { access_token, refresh_token } = await response.json().message;
sessionStorage.setItem('token', access_token);
// 2. Make authenticated requests
fetch('/api/resource/Item', {
headers: { 'Authorization': `Bearer ${sessionStorage.getItem('token')}` }
});
// 3. Convert when ready
// Send OTP
await fetch('/api/method/ghost.api.otp.send_otp', {
method: 'POST',
body: JSON.stringify({ email: 'user@example.com', purpose: 'Conversion' })
});
// Convert with OTP
await fetch('/api/method/ghost.api.ghost.convert_to_real_user', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
ghost_email: 'ghost_xxx@guest.local',
real_email: 'user@example.com',
otp_code: '123456'
})
});
// โจ User converted! All data preserved!
๐ฎ Test It Out
We've included a Bruno collection with ready-to-run API tests:
# Open apps/ghost/bruno/ in Bruno
# Run tests in order:
1. Create Ghost Session โ
2. Refresh Token โ
3. Send OTP โ
4. Convert to Real User โ
โ๏ธ Configuration (The Important Bits)
Ghost Settings (Setup > Ghost Settings):
| Setting | What It Does | Default |
|---|---|---|
| Client ID | OAuth client (required!) | - |
| Access Token Expiry | How long before re-auth | 1 hour |
| Invalidate on Conversion | Revoke ghost tokens when converting | โ |
| Verify OTP on Conversion | Require email verification | โ |
That's it! Everything else has smart defaults.
๐ Security (Yes, It's Production-Ready)
โ
OAuth2 bearer tokens (same as Google/Facebook)
โ
Short-lived access tokens (1 hour, configurable)
โ
Token refresh without re-login
โ
Automatic token revocation on conversion
โ
Rate limiting on all endpoints
โ
HTTPS support (required in production)
Mobile apps? Works perfectly (no cookies needed).
๐ Full Documentation
Too much info above? โ Full README โ
Need API reference? โ Bruno tests โ
Want examples? โ See Frontend Integration above โ
๐ค Common Questions
Q: Do I need to handle token refresh myself?
A: Yes, but it's one API call. Just call /refresh_bearer_token before expiry.
Q: What happens to ghost user's cart when they convert?
A: Conversion preserves app-owned ghost data. New emails use rename conversion; existing emails use explicit app-level migration without generic User merge.
Q: Can I use this in production?
A: Yes! OAuth2 tokens are industry-standard. Used in real ecommerce sites.
Q: Mobile app support?
A: Perfect for mobile. No cookies, just tokens. Works on iOS/Android.
Q: Is it GDPR compliant?
A: Yes. Ghost users auto-delete after expiry. Full data control.
๐ ๏ธ Troubleshooting
"OAuth Client ID is required"
โ Create OAuth Client (Setup > Integrations), copy ID to Ghost Settings
"Invalid token"
โ Token expired (1 hour). Call /refresh_bearer_token with refresh token.
"OTP Code required"
โ Send OTP first: /send_otp, then include code in conversion request.
๐ What You Get
โ
Instant anonymous user sessions
โ
OAuth2 bearer token authentication
โ
OTP verification (email/SMS)
โ
Seamless ghost โ real user conversion
โ
All data preserved on conversion
โ
Token refresh for seamless UX
โ
Auto-cleanup of expired ghosts
โ
Rate limiting & security
โ
Mobile-friendly (no cookies)
โ
Production-ready
๐ค Contributing
PRs welcome!
Quick start:
git clone https://github.com/muneeb141/ghost
cd ghost
# Make changes, run tests
bench --site dev run-tests --app ghost
๐ License
MIT License - Use it however you want!
๐ฌ Support
- ๐ Report Issues
- ๐ก Request Features
- ๐ Full Docs
Made with โค๏ธ for the Frappe community
Stop losing users at the signup wall. Try Ghost today!
Related Other apps for Frappe & ERPNext
- Erpnext โ Free and Open Source Enterprise Resource Planning (ERP)
- Helpdesk โ Modern, Streamlined, Free and Open Source Customer Service Software
- Print Designer โ Visual print designer for Frappe / ERPNext
- Ctr โ CTRๆจกๅไปฃ็ ๅๅญฆไน ็ฌ่ฎฐๆป็ป
- Whitelabel โ Whitelabel ERPNext
- Fossunited โ fossunited.org
- Helm โ Helm Chart Repository for Frappe/ERPNext
- Frappe Attachments S3 โ A frappe app to upload file attachments in doctypes to s3.