- Updated webhook to capture SSO user details (email, name, user ID) - Added comprehensive metadata tracking for music generation - Enhanced webhook payload with generation mode and technical details - Created session management endpoints for SSO user data - Updated client identification to specify 'Music Generation' - Added IP address and user agent tracking for security/analytics - Documented enhanced webhook structure in README - Added session handling for user tracking across requests When SSO is enabled, webhooks will now include: - User email and name from SSO authentication - Generation mode (Simple vs Advanced with Composition Plan) - Enhanced technical metadata for better tracking - Proper client identification for music generation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
No EOL
1.1 KiB
PHP
46 lines
No EOL
1.1 KiB
PHP
<?php
|
|
// Store SSO user information in PHP session for webhook tracking
|
|
|
|
session_start();
|
|
|
|
// Only accept POST requests
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
http_response_code(405);
|
|
echo json_encode(['success' => false, 'error' => 'Method not allowed']);
|
|
exit;
|
|
}
|
|
|
|
// Get JSON input
|
|
$input = file_get_contents('php://input');
|
|
$userData = json_decode($input, true);
|
|
|
|
if (!$userData) {
|
|
http_response_code(400);
|
|
echo json_encode(['success' => false, 'error' => 'Invalid JSON data']);
|
|
exit;
|
|
}
|
|
|
|
// Store user information in session for webhook usage
|
|
if (isset($userData['email'])) {
|
|
$_SESSION['sso_user_email'] = $userData['email'];
|
|
}
|
|
|
|
if (isset($userData['name'])) {
|
|
$_SESSION['sso_user_name'] = $userData['name'];
|
|
}
|
|
|
|
if (isset($userData['userId'])) {
|
|
$_SESSION['sso_user_id'] = $userData['userId'];
|
|
}
|
|
|
|
// Store timestamp of login
|
|
$_SESSION['sso_login_timestamp'] = time();
|
|
|
|
// Log successful session storage
|
|
error_log("SSO user session stored: " . $userData['email'] ?? 'Unknown');
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'message' => 'User session stored successfully'
|
|
]);
|
|
?>
|