|
29 | 29 |
|
30 | 30 | from config.agent_config import AgentConfig |
31 | 31 | from services.rag_service import RAGService |
32 | | -from services.auth_service import AuthService |
| 32 | +from services.auth_service import AuthService, UserClaims |
33 | 33 | from handlers.message_handler import MessageHandler |
34 | 34 | from handlers.teams_handler import TeamsHandler |
35 | 35 | from adapters.response_adapter import ResponseAdapter |
@@ -99,8 +99,33 @@ async def on_message_activity(self, turn_context: TurnContext) -> None: |
99 | 99 | conversation_data.message_count += 1 |
100 | 100 | conversation_data.last_activity = turn_context.activity.text |
101 | 101 |
|
102 | | - # Get user authentication claims |
103 | | - auth_claims = await self.auth_service.get_user_claims(turn_context) |
| 102 | + # Get enhanced user authentication claims |
| 103 | + user_claims = await self.auth_service.get_enhanced_user_claims(turn_context) |
| 104 | + auth_claims = { |
| 105 | + "oid": user_claims.user_id, |
| 106 | + "name": user_claims.user_name, |
| 107 | + "email": user_claims.email, |
| 108 | + "tenant_id": user_claims.tenant_id, |
| 109 | + "groups": user_claims.groups, |
| 110 | + "roles": user_claims.roles, |
| 111 | + "is_authenticated": user_claims.is_authenticated, |
| 112 | + "additional_claims": user_claims.additional_claims |
| 113 | + } |
| 114 | + |
| 115 | + # Check user permissions |
| 116 | + if not user_claims.is_authenticated: |
| 117 | + await turn_context.send_activity( |
| 118 | + MessageFactory.text("I'm sorry, I need to verify your identity before I can help you. Please ensure you're properly authenticated.") |
| 119 | + ) |
| 120 | + return |
| 121 | + |
| 122 | + # Check if user has basic read permission |
| 123 | + has_read_permission = await self.auth_service.check_user_permission(user_claims, "read_documents") |
| 124 | + if not has_read_permission: |
| 125 | + await turn_context.send_activity( |
| 126 | + MessageFactory.text("I'm sorry, you don't have permission to access the document search functionality. Please contact your administrator.") |
| 127 | + ) |
| 128 | + return |
104 | 129 |
|
105 | 130 | # Process the message based on channel |
106 | 131 | if turn_context.activity.channel_id == "msteams": |
|
0 commit comments