mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
[Refactor]: Changes to Github Authentication (#5371)
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com> Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
42
openhands/server/types.py
Normal file
42
openhands/server/types.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from enum import Enum
|
||||
from typing import ClassVar, Protocol
|
||||
|
||||
|
||||
class AppMode(Enum):
|
||||
OSS = 'oss'
|
||||
SAAS = 'saas'
|
||||
|
||||
|
||||
class SessionMiddlewareInterface(Protocol):
|
||||
"""Protocol for session middleware classes."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class OpenhandsConfigInterface(ABC):
|
||||
CONFIG_PATH: ClassVar[str | None]
|
||||
APP_MODE: ClassVar[AppMode]
|
||||
POSTHOG_CLIENT_KEY: ClassVar[str]
|
||||
GITHUB_CLIENT_ID: ClassVar[str]
|
||||
ATTACH_SESSION_MIDDLEWARE_PATH: ClassVar[str]
|
||||
|
||||
@abstractmethod
|
||||
def verify_config(self) -> None:
|
||||
"""Verify configuration settings."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def verify_github_repo_list(self, installation_id: int | None) -> None:
|
||||
"""Verify that repo list is being called via user's profile or Github App installations."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def get_config(self) -> dict[str, str]:
|
||||
"""Configure attributes for frontend"""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def github_auth(self, data: dict) -> None:
|
||||
"""Handle GitHub authentication."""
|
||||
raise NotImplementedError
|
||||
Reference in New Issue
Block a user