Add Magenta 2.0 (DE)

This commit is contained in:
Nirvana
2025-11-13 21:05:31 +01:00
parent 6db32c0e6d
commit 534c87289e
3 changed files with 61 additions and 4 deletions
@@ -463,7 +463,31 @@ class Magenta2Authenticator(BaseOAuth2Authenticator):
except Exception as e:
logger.warning(f"Failed to initialize SAM3/SSO clients: {e}")
def update_sam3_qr_code_url(self, qr_code_url: str) -> bool:
"""
Public method to update SAM3 client with QR code URL
Returns True if successful, False otherwise
"""
if not self._sam3_client:
logger.warning("Cannot update QR code URL - SAM3 client not initialized")
return False
# Use public method instead of direct assignment
self._sam3_client.set_qr_code_url(qr_code_url)
logger.info(f"✓ Updated SAM3 client with QR code URL: {qr_code_url}")
return True
def get_sam3_client_status(self) -> Dict[str, Any]:
"""
Public method to get SAM3 client status for debugging
"""
if not self._sam3_client:
return {'initialized': False}
# Use public method instead of accessing protected members
return self._sam3_client.get_client_status()
def can_use_line_auth(self) -> bool:
"""Check if line auth components are available"""
return (
@@ -211,11 +211,21 @@ class Magenta2Provider(StreamingProvider):
qr_url = self.endpoint_manager.get_endpoint('login_qr_code')
if qr_url:
logger.info(f"✓ QR code endpoint discovered in endpoint manager: {qr_url}")
# PROPER FIX: Use public method to update SAM3 client
if hasattr(self.authenticator, 'update_sam3_qr_code_url'):
success = self.authenticator.update_sam3_qr_code_url(qr_url)
if success:
logger.info("✓ Successfully updated SAM3 client with QR code URL")
else:
logger.warning("✗ Failed to update SAM3 client with QR code URL")
# Also debug the current status
if hasattr(self.authenticator, 'get_sam3_client_status'):
status = self.authenticator.get_sam3_client_status()
logger.debug(f"SAM3 client status after update: {status}")
else:
logger.warning("✗ QR code endpoint NOT found in endpoint manager")
# Show all available endpoints for debugging
all_endpoints = self.endpoint_manager.get_all_endpoints()
logger.debug(f"Available endpoints: {list(all_endpoints.keys())}")
if self.provider_config and self.provider_config.manifest:
device_token = self.provider_config.get_device_token()
@@ -485,6 +485,29 @@ class Sam3Client:
logger.warning(f"No access token available for scope {scope} - line auth may be needed")
return ""
def get_token_endpoint(self) -> str:
"""Public method to get token endpoint"""
return self._get_token_endpoint()
def get_client_status(self) -> Dict[str, Any]:
"""
Public method to get SAM3 client status for debugging
"""
return {
'initialized': True,
'has_backchannel_url': bool(self.backchannel_start_url),
'has_token_endpoint': bool(self._get_token_endpoint()),
'has_qr_code_url': bool(self.qr_code_url_template),
'backchannel_url': self.backchannel_start_url,
'token_endpoint': self._get_token_endpoint(),
'qr_code_url': self.qr_code_url_template
}
def set_qr_code_url(self, qr_code_url: str) -> None:
"""Public method to set QR code URL"""
self.qr_code_url_template = qr_code_url
logger.debug(f"QR code URL set: {qr_code_url}")
# ========================================================================
# HTML Form Parsing Helpers
# ========================================================================