Skip to content

Commit 9e1485e

Browse files
committed
fix: Add comprehensive logout and cache clearing system v1.0.1
- Fix SAML authentication method mismatch (AADSTS75011) with requestedAuthnContext=false - Add smart logout options: local logout (preserves Azure AD) vs full SAML logout - Implement multi-tab session coordination to prevent 403 Forbidden errors - Add comprehensive cache clearing: localStorage, sessionStorage, IndexedDB, cookies - Create custom logout template with client-side cleanup and BroadcastChannel API - Enhance security with configurable SAML settings and session monitoring - Update documentation for logout configuration and troubleshooting Resolves: Multi-tab authentication errors, cache-related login issues
1 parent 2593315 commit 9e1485e

10 files changed

Lines changed: 710 additions & 19 deletions

File tree

.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ SAML_DEFAULT_ROLE=Gamma # Default role for new SAML users (Gamm
1919
SAML_STRICT=true # Enable strict SAML validation (recommended for production)
2020
SAML_DEBUG=false # Enable debug logging (set to 'true' for troubleshooting)
2121

22+
# Logout Behavior Configuration
23+
SAML_FORCE_LOCAL_LOGOUT=true # true = Logout from Superset only (preserves Azure AD session)
24+
# false = Full SAML logout (logs out from both Superset and Azure AD)
25+
26+
# Advanced SAML Security Options (Optional)
27+
SAML_WANT_ASSERTIONS_SIGNED=true # Require signed assertions (recommended for production)
28+
SAML_WANT_NAMEID_ENCRYPTED=false # Encrypt NameID (optional, may cause compatibility issues)
29+
SAML_WANT_ASSERTIONS_ENCRYPTED=false # Encrypt assertions (optional, may cause compatibility issues)
30+
SAML_SIGN_REQUESTS=false # Sign outgoing SAML requests (optional)
31+
SAML_SIGN_LOGOUT=false # Sign logout requests/responses (optional)
32+
SAML_SIGN_METADATA=false # Sign SAML metadata (optional)
33+
2234
# =============================================================================
2335
# Service Provider (SP) Configuration - Your Superset Instance
2436
# =============================================================================

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,4 @@ components/
192192

193193
# Readme files
194194
DOCKER_HUB_README.md
195+
DOCKER_HUB_OLD_README.md

README.md

Lines changed: 131 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
11
# Apache Superset with SAML Authentication 🚀
22

3-
**Version 1.0.0** - Enhanced Apache Superset setup with dual authentication support (SAML + Database) and complete enterprise integration.
3+
<!-- Version Management: Update version file and docker-compose.yml image tag when releasing -->
4+
**Current Version: 1.0.1** - Enhanced Apache Superset setup with dual authentication support (SAML + Database) and complete enterprise integration.
5+
6+
> 📝 **Version Management**: The current version is dynamically managed through the [`version`](version) file. Update this file and corresponding Docker image tags when releasing new versions.
47
58
![Docker Pulls](https://img.shields.io/docker/pulls/jawadrafique/superset?style=flat-square)
6-
![Docker Image Version](https://img.shields.io/docker/v/jawadrafique/superset/latest?style=flat-square)
7-
![Docker Image Size](https://img.shields.io/docker/image-size/jawadrafique/superset/latest?style=flat-square)
9+
![Docker Image Version](https://img.shields.io/docker/v/jawadrafique/superset/1.0.1?style=flat-square)
10+
![Docker Image Size](https://img.shields.io/docker/image-size/jawadrafique/superset/1.0.1?style=flat-square)
811
![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)
912

10-
## ✨ Features (v1.0.0)
13+
## ✨ Features (Latest Version)
1114

1215
### 🔐 Dual Authentication System
1316
- **SAML SSO Integration** with Azure AD/ADFS
1417
- **Database Authentication** fallback
1518
- **Seamless user experience** with unified login page
1619
- **Enterprise-ready security** with X.509 certificates
20+
- **Smart Logout Management** with cache clearing and multi-tab coordination
1721

1822
### 🎯 Core Capabilities
1923
- **Auto-initialization** with admin user creation
2024
- **MySQL database integration** with optimized connection pooling
2125
- **Environment-based configuration** for easy deployment
2226
- **Custom Docker image** with pre-installed SAML libraries
2327
- **Helm chart support** for Kubernetes deployment
28+
- **Advanced session management** with comprehensive cache clearing
29+
30+
## 🆕 What's New in v1.0.1
2431

25-
## 🆕 What's New in v1.0.0
32+
### 🚪 Enhanced Logout & Session Management (v1.0.1)
33+
- **Smart logout options** with local vs full SAML logout
34+
- **Multi-tab coordination** prevents 403 Forbidden errors
35+
- **Comprehensive cache clearing** eliminates manual site data clearing
36+
- **Real-time session monitoring** across browser tabs
37+
- **SAML authentication fix** for Azure AD method conflicts (AADSTS75011)
2638

27-
### 🎥 SAML Authentication Demo
39+
### 🎥 SAML Authentication Demo (v1.0.0)
2840
**[Watch the SAML Demo Video](https://youtu.be/eUC1EElVgTo)** - See complete SAML authentication flow with Azure AD integration!
2941

3042
### Production-Ready SAML Support
@@ -46,6 +58,15 @@
4658
- **Configurable SAML validation** (strict/relaxed modes)
4759
- **Debug mode** for troubleshooting SAML issues
4860
- **Secure environment variable** configuration
61+
- **Advanced logout management** with comprehensive cache clearing
62+
- **Multi-tab session coordination** to prevent authentication errors
63+
64+
### 🚪 Advanced Logout & Session Management
65+
- **Smart logout options** - Local logout (preserves Azure AD) or Full SAML logout
66+
- **Comprehensive cache clearing** - localStorage, sessionStorage, IndexedDB, cookies
67+
- **Multi-tab coordination** - Automatic logout across all browser tabs
68+
- **Session monitoring** - Prevents 403 Forbidden errors in multiple tabs
69+
- **Client-side cleanup** - Removes all cached authentication data
4970

5071
## 🚀 Quick Start
5172

@@ -144,7 +165,7 @@ SAML_SP_PRIVATE_KEY="$(cat saml_sp.key | tr -d '\n')"
144165
### 4. Build Custom Image
145166

146167
```bash
147-
docker build . -t superset:1.0.0
168+
docker build . -t superset:1.0.1
148169
```
149170

150171
### 5. Start Superset
@@ -191,28 +212,91 @@ Check logs for SAML authentication issues:
191212
docker-compose logs superset | grep -i saml
192213
```
193214

194-
## 📁 Project Structure
215+
## � Logout & Session Management
216+
217+
### Smart Logout Options
218+
219+
The enhanced logout system provides two modes to handle different security requirements:
220+
221+
#### **Local Logout (Default - Recommended)**
222+
```bash
223+
SAML_FORCE_LOCAL_LOGOUT=true # Default setting
224+
```
225+
- **Logs out from Superset only** - preserves Azure AD session
226+
- **Ideal for shared workstations** - users remain logged in to Office 365, Teams, etc.
227+
- **Convenient re-login** - quick SAML authentication without re-entering credentials
228+
- **Enhanced security** - comprehensive client-side cache clearing
229+
230+
#### **Full SAML Logout (Optional)**
231+
```bash
232+
SAML_FORCE_LOCAL_LOGOUT=false # For high-security environments
233+
```
234+
- **Global logout** - logs out from both Superset AND Azure AD
235+
- **Complete session termination** - ends all SAML-connected applications
236+
- **Maximum security** - ensures no residual sessions
237+
238+
### Multi-Tab Session Coordination
239+
240+
**Problem Solved**: No more "403 Forbidden" errors when logging out with multiple Superset tabs open.
241+
242+
**Features**:
243+
- **Automatic coordination** across all browser tabs
244+
- **Real-time notifications** using BroadcastChannel API
245+
- **Comprehensive cache clearing** - localStorage, sessionStorage, IndexedDB, cookies
246+
- **Session monitoring** - detects expired sessions and auto-redirects
247+
- **Fallback mechanisms** - localStorage events for older browsers
248+
249+
**User Experience**:
250+
1. User logs out from any Superset tab
251+
2. **All other tabs automatically redirect** to login page
252+
3. **No manual cache clearing** required
253+
4. **Seamless experience** across all browser tabs
254+
255+
### Cache & Storage Clearing
256+
257+
The logout process comprehensively clears:
258+
- **Server-side**: Flask sessions, authentication cookies, SAML session data
259+
- **Client-side**: localStorage, sessionStorage, IndexedDB, browser cache
260+
- **Cross-tab**: Notifications to all open tabs via BroadcastChannel
261+
- **Security headers**: No-cache directives to prevent authentication caching
262+
263+
## �📁 Project Structure
195264

196265
```
197-
├── docker-compose.yml # Service orchestration (v1.0.0)
266+
├── docker-compose.yml # Service orchestration (current version)
198267
├── Dockerfile # Custom image with SAML + MySQL support
199268
├── entrypoint.sh # Auto-initialization script
200269
├── superset_config.py # Configuration with SAML integration
201-
├── auth_saml.py # Custom SAML security manager (v1.0.0)
270+
├── auth_saml.py # Custom SAML security manager (v1.0.0+)
202271
├── templates/ # Custom templates for dual authentication
203272
│ └── appbuilder/general/security/
204-
│ └── login_db.html # Dual authentication login page
205-
├── helm/ # Kubernetes deployment (v1.0.0)
206-
│ ├── microservice-superset.yaml # Helm template with SAML support
273+
│ ├── login_db.html # Dual authentication login page
274+
│ └── logout.html # Enhanced logout with cache clearing (v1.0.1+)
275+
├── helm/ # Kubernetes deployment (v1.0.0+)
276+
├── microservice-superset.yaml # Helm template with SAML support
207277
│ └── values.yaml # Configuration values
208278
├── .env.example # Environment variables template
209279
├── .env # Your local configuration (git-ignored)
210-
├── version # Version 1.0.0
280+
├── version # Current Version: 1.0.1
211281
├── volumes/ # Persistent data storage
212282
│ └── superset/ # Superset application data
213283
└── README.md # This documentation
214284
```
215285

286+
## 🏷️ Version Management
287+
288+
This project uses semantic versioning managed through the [`version`](version) file:
289+
290+
- **Current Version**: `1.0.1`
291+
- **Docker Image Tag**: `superset:1.0.1` (in docker-compose.yml)
292+
- **Release Notes**: See [What's New](#-whats-new-in-v101) sections for version history
293+
294+
**To release a new version:**
295+
1. Update the [`version`](version) file
296+
2. Update image tag in [`docker-compose.yml`](docker-compose.yml)
297+
3. Update any version references in documentation
298+
4. Build and tag Docker image: `docker build -t superset:$(cat version) .`
299+
216300
## 🔧 Configuration Files
217301

218302
### Key Files (v1.0.0)
@@ -261,7 +345,7 @@ The enhanced entrypoint script automatically:
261345

262346
```bash
263347
# Rebuild with SAML support
264-
docker build --no-cache . -t superset:1.0.0
348+
docker build --no-cache . -t superset:1.0.1
265349
docker-compose up -d
266350

267351
# View logs with SAML debug info
@@ -280,7 +364,7 @@ Update `docker-compose.yml` with production settings:
280364
version: '3.8'
281365
services:
282366
superset:
283-
image: superset:1.0.0
367+
image: superset:1.0.1
284368
environment:
285369
- ENABLE_SAML_AUTH=true
286370
- SAML_SP_ENTITY_ID=https://superset.yourcompany.com
@@ -292,7 +376,7 @@ Use the included Helm templates in the `k8s/` directory:
292376

293377
```bash
294378
helm install superset ./k8s/superset-helm \
295-
--set image.tag=1.0.0 \
379+
--set image.tag=1.0.1 \
296380
--set saml.enabled=true \
297381
--set saml.idpEntityId=https://sts.windows.net/your-tenant/
298382
```
@@ -339,6 +423,36 @@ docker-compose logs superset | grep -i saml
339423
docker exec superset cat /app/superset_config.py | grep -A 20 "SAML"
340424
```
341425

426+
### Logout & Session Issues
427+
428+
**403 Forbidden Errors in Multiple Tabs (SOLVED):**
429+
- ✅ **Fixed in v1.0.1** - Enhanced logout automatically coordinates all tabs
430+
- ✅ **No manual cache clearing** required anymore
431+
- ✅ **All tabs redirect automatically** when user logs out
432+
433+
**Logout Not Working Properly:**
434+
1. Check logout configuration: `SAML_FORCE_LOCAL_LOGOUT=true` (recommended)
435+
2. Verify browser supports BroadcastChannel (modern browsers do)
436+
3. Check browser console for logout coordination logs
437+
4. Test with different logout modes:
438+
```bash
439+
# Local logout (preserves Azure AD session)
440+
SAML_FORCE_LOCAL_LOGOUT=true
441+
442+
# Full SAML logout (logs out from Azure AD too)
443+
SAML_FORCE_LOCAL_LOGOUT=false
444+
```
445+
446+
**Cache/Session Issues:**
447+
```bash
448+
# Check if comprehensive cache clearing is working
449+
# 1. Login to Superset
450+
# 2. Open browser DevTools > Application > Storage
451+
# 3. Note localStorage, sessionStorage, cookies
452+
# 4. Logout from Superset
453+
# 5. Check that all auth-related storage is cleared
454+
```
455+
342456
**User Provisioning Issues:**
343457
- Check `SAML_DEFAULT_ROLE` setting
344458
- Verify user email format from Azure AD

SAML_CONFIG.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,102 @@ SAML_IDP_X509_CERT=YOUR_AZURE_ADFS_CERTIFICATE
9292

9393
#### General SAML Settings
9494

95+
#### Security SAML Settings
96+
97+
The SAML configuration includes comprehensive security settings with environment variable control:
98+
99+
**Authentication Security:**
100+
- `requestedAuthnContext: false` - Accepts ANY authentication method from Azure AD (fixes AADSTS75011 error)
101+
- `wantNameId: true` - Always requires NameID for secure user identification
102+
103+
**Signature & Encryption (Configurable):**
104+
```bash
105+
# Enhanced security options (optional environment variables)
106+
SAML_WANT_ASSERTIONS_SIGNED=true # Require signed assertions (recommended for production)
107+
SAML_WANT_NAMEID_ENCRYPTED=false # Encrypt NameID (optional, may cause compatibility issues)
108+
SAML_WANT_ASSERTIONS_ENCRYPTED=false # Encrypt assertions (optional, may cause compatibility issues)
109+
SAML_SIGN_REQUESTS=false # Sign outgoing SAML requests (optional)
110+
SAML_SIGN_LOGOUT=false # Sign logout requests/responses (optional)
111+
SAML_SIGN_METADATA=false # Sign SAML metadata (optional)
112+
113+
# Logout Behavior Control
114+
SAML_FORCE_LOCAL_LOGOUT=true # Force local logout only (preserves Azure AD session)
115+
```
116+
117+
**Logout Options:**
118+
- `SAML_FORCE_LOCAL_LOGOUT=true` (default): Logout from Superset only, keep Azure AD session
119+
- `SAML_FORCE_LOCAL_LOGOUT=false`: Full SAML logout (logs out from both Superset and Azure AD)
120+
121+
## Logout & Session Management
122+
123+
### Smart Logout Configuration
124+
125+
The SAML integration provides intelligent logout handling to solve common multi-tab and cache issues:
126+
127+
#### Local Logout (Recommended)
128+
```bash
129+
SAML_FORCE_LOCAL_LOGOUT=true # Default setting
130+
```
131+
**Benefits:**
132+
- Logs out from Superset only (preserves Azure AD session)
133+
- Users remain logged in to Office 365, Teams, other Azure apps
134+
- Quick re-login via SAML without re-entering credentials
135+
- Ideal for shared workstations and productivity workflows
136+
137+
#### Full SAML Logout
138+
```bash
139+
SAML_FORCE_LOCAL_LOGOUT=false
140+
```
141+
**Benefits:**
142+
- Complete logout from both Superset AND Azure AD
143+
- Maximum security for sensitive environments
144+
- Terminates all SAML-connected application sessions
145+
146+
### Multi-Tab Coordination
147+
148+
**Problem Solved**: Eliminates "403 Forbidden" errors when multiple Superset tabs are open and user logs out.
149+
150+
**How it works:**
151+
1. User logs out from any Superset tab
152+
2. Logout process clears all authentication data
153+
3. **BroadcastChannel API** notifies all other open tabs
154+
4. Other tabs automatically redirect to login page
155+
5. **No manual cache clearing** required by users
156+
157+
### Comprehensive Cache Clearing
158+
159+
The logout process automatically clears:
160+
161+
**Server-side:**
162+
- Flask session data (`_user_id`, `_fresh`, SAML session)
163+
- Authentication cookies (`session`, `remember_token`, `csrf_token`)
164+
- SAML-specific data (`samlUserdata`, `samlNameId`, etc.)
165+
166+
**Client-side:**
167+
- `localStorage` - All stored authentication data
168+
- `sessionStorage` - Temporary session data
169+
- `IndexedDB` - Any cached Superset data
170+
- `Browser Cache` - Cached authentication responses
171+
- `Service Workers` - Unregistered to prevent cached auth
172+
173+
**Cross-tab Communication:**
174+
- `BroadcastChannel` - Real-time tab coordination
175+
- `localStorage events` - Fallback for older browsers
176+
- Cache control headers - Prevents authentication caching
177+
178+
**Attack Prevention:**
179+
- `rejectUnsolicitedResponsesWithInResponseTo: true` - Prevents SAML replay attacks
180+
- `allowRepeatAttributeName: false` - Prevents attribute injection attacks
181+
- `wantXMLValidation: true` - Validates XML structure against attacks
182+
- `clockSkew: 30` - 30-second tolerance for server time differences
183+
184+
**Security Recommendations:**
185+
1. **Production**: Set `SAML_WANT_ASSERTIONS_SIGNED=true` for signed assertions
186+
2. **Network**: Always use HTTPS in production (required for SAML)
187+
3. **Certificates**: Keep Azure AD and SP certificates updated
188+
4. **Monitoring**: Enable SAML debug logging to monitor authentication attempts
189+
5. **Testing**: Test security settings in staging before production deployment
190+
95191
```bash
96192
# SAML Settings
97193
SAML_STRICT=true
@@ -172,6 +268,11 @@ AUTH_USER_REGISTRATION_ROLE = "Gamma" # Change to "Alpha" or "Admin" if needed
172268
1. **Certificate Issues**: Ensure the certificate is copied correctly without headers and line breaks
173269
2. **URL Mismatches**: Verify all URLs in Azure and saml_settings.json match exactly
174270
3. **Attribute Mapping**: Check Azure AD user attributes if user creation fails
271+
4. **Authentication Method Mismatch (AADSTS75011)**:
272+
- **Error**: "Authentication method 'X509, MultiFactor, X509Device' by which the user authenticated with the service doesn't match requested authentication method 'Password, ProtectedTransport'"
273+
- **Cause**: Users with existing Azure sessions (MFA, FIDO keys) conflict with Superset's default authentication method requirements
274+
- **Solution**: The `requestedAuthnContext: false` setting is now automatically included in the SAML security configuration to accept any authentication method from Azure AD
275+
- **Test**: Try logging in with a normal browser (not incognito) after deploying the updated configuration
175276

176277
### Debug Mode
177278

0 commit comments

Comments
 (0)