(sm: Optional[SecurityManager])
| 236 | |
| 237 | |
| 238 | def is_auth_necessary(sm: Optional[SecurityManager]) -> bool: |
| 239 | intra_communication_base64 = os.getenv("INTRA_COMMUNICATION_BASE64") |
| 240 | |
| 241 | # If no security manager, no auth is necessary |
| 242 | if sm is None: |
| 243 | return False |
| 244 | |
| 245 | # If security manager exists but no user context, auth is necessary (security-first approach) |
| 246 | if sm.current_user is None: |
| 247 | return True |
| 248 | |
| 249 | # If user is intra-communication, no auth is necessary |
| 250 | if sm.current_user.username == intra_communication_base64: |
| 251 | return False |
| 252 | |
| 253 | # Otherwise, auth is necessary |
| 254 | return True |
no outgoing calls
no test coverage detected