add OAUth2.0

This commit is contained in:
2026-06-15 11:14:35 +02:00
parent 7973a94498
commit 69f4d6a602
32 changed files with 1126 additions and 51 deletions
+144
View File
@@ -0,0 +1,144 @@
# 🚀 Deploy & Aggiornamento — Glastree
## Generare il Pacchetto (Server di Sviluppo)
```bash
cd /var/www/html/glastree
# Installa dipendenze PHP production (esclude dev)
composer install --no-dev --optimize-autoloader
# Build asset Vite (se node_modules/ presente)
npm install && npm run build
# Genera archivio
bash build-dist.sh
```
L'archivio `glastree-YYYYMMDD_HHMM.tar.gz` viene creato nella directory corrente.
---
## 🆕 Installazione Fresca (Nuovo Server)
```bash
# 1. Estrai archivio
tar xzf glastree-YYYYMMDD_HHMM.tar.gz
cd glastree
# 2. Crea directory necessarie
mkdir -p storage/framework/cache/data \
storage/framework/sessions \
storage/framework/views \
storage/logs \
bootstrap/cache \
storage/app/public \
storage/app/public/logos \
storage/app/public/documenti/eventi \
storage/app/backups \
storage/app/documenti \
storage/app/private/avatars/gruppi
# 3. Permessi
chmod -R 775 storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache
# 4. Crea .gitignore in storage/app/public (serve a Laravel)
echo "*" > storage/app/public/.gitignore
echo "!.gitignore" >> storage/app/public/.gitignore
# 5. Configura ambiente
cp .env.example .env
# Modifica manualmente: DB, APP_URL, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
php artisan key:generate
# 6. Pulisci cache e ricrea symlink
rm -f public/storage
ln -sf ../storage/app/public public/storage
php artisan config:clear
php artisan route:clear
php artisan view:clear
# 7. Avvia installazione DB
php install.php
```
---
## 🔄 Aggiornamento (Server Esistente)
```bash
# 1. BACKUP
cp .env .env.backup.$(date +%Y%m%d_%H%M%S)
mysqldump -u USER -p DBNAME > backup_$(date +%Y%m%d_%H%M%S).sql
# 2. Estrai archivio
tar xzf glastree-YYYYMMDD_HHMM.tar.gz
# 3. Ripristina .env
cp .env.backup.* .env
# 4. Aggiungi nuove variabili d'ambiente
echo "GOOGLE_CLIENT_ID=" >> .env
echo "GOOGLE_CLIENT_SECRET=" >> .env
# 5. Permessi
chmod -R 775 storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache
# 6. Symlink storage
rm -f public/storage
ln -sf ../storage/app/public public/storage
# 7. Migration
php artisan migrate --force
# 8. Pulisci cache
php artisan config:clear
php artisan route:clear
php artisan view:clear
# 9. Asset Vite
npm install && npm run build
```
---
## 📦 Contenuto dell'Archivio
| Include | Esclude |
|---------|---------|
| Sorgenti PHP (`app/`, `config/`, `routes/`, `resources/`) | `.git/`, `node_modules/`, `tests/` |
| Vendor production | `.env`, `.env.example` |
| Asset Vite compilati (`public/build/`) | `storage/app/public/`, `storage/app/private/` |
| Migration e seeder | `storage/framework/cache/*`, `sessions/*`, `views/*` |
| | `storage/logs/*`, `storage/debugbar/*` |
| | `storage/app/backups/`, `storage/app/documenti/` |
| | `MEMORY.md`, `AGENTS.md`, `build-dist.sh`, Docker files |
---
## ⚙️ Variabili d'Ambiente Richieste
```env
APP_URL=https://tuodominio.it
APP_SUBFOLDER=/app
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=glastree
DB_USERNAME=glastree
DB_PASSWORD=...
GOOGLE_CLIENT_ID=....
GOOGLE_CLIENT_SECRET=....
```
## 🌐 Google OAuth 2.0 — Post-Deploy
1. [Google Cloud Console](https://console.cloud.google.com/) → Abilita Gmail API, Drive API, Calendar API
2. Credenziali → OAuth Client ID → Web Application
3. Redirect URI: `https://tuodominio.it/app/auth/google/callback`
4. Inserisci Client ID/Secret in `.env`
5. **Impostazioni → Google Services** → Connetti Gmail, Drive, Calendar
6. Per Gmail: **Impostazioni → Email → IMAP** → seleziona "OAuth 2.0"