Skip to content

Commit

Permalink
fix auth when there are no allow lists (#4707)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren authored Nov 2, 2024
1 parent 8857f02 commit 7b8241e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions openhands/server/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ def _init_sheets_client(self) -> None:
self.sheets_client = GoogleSheetsClient()
self.spreadsheet_id = sheet_id

def is_active(self) -> bool:
return bool(self.file_users or (self.sheets_client and self.spreadsheet_id))

def is_user_allowed(self, username: str) -> bool:
"""Check if user is allowed based on file and/or sheet configuration"""
if not self.file_users and not self.sheets_client:
logger.debug('No verification sources configured - allowing all users')
if not self.is_active():
return True
logger.info(f'Checking if GitHub user {username} is allowed')

logger.info(f'Checking if GitHub user {username} is allowed')
if self.file_users:
if username in self.file_users:
logger.info(f'User {username} found in text file allowlist')
Expand All @@ -79,6 +81,10 @@ def is_user_allowed(self, username: str) -> bool:
async def authenticate_github_user(auth_token) -> bool:
user_verifier = UserVerifier()

if not user_verifier.is_active():
logger.info('No user verification sources configured - allowing all users')
return True

logger.info('Checking GitHub token')

if not auth_token:
Expand Down

0 comments on commit 7b8241e

Please sign in to comment.