Spaces:
Running
Running
apple muncy
commited on
Commit
·
2017445
1
Parent(s):
7fd9eb2
Add AS_HOST_NAME EV
Browse filesSigned-off-by: apple muncy <[email protected]>
- auth_server.py +6 -4
- simple_auth_provider.py +3 -0
auth_server.py
CHANGED
|
@@ -26,18 +26,20 @@ from mcp.server.auth.routes import cors_middleware, create_auth_routes
|
|
| 26 |
from mcp.server.auth.settings import AuthSettings, ClientRegistrationOptions
|
| 27 |
|
| 28 |
from simple_auth_provider import SimpleAuthSettings, SimpleOAuthProvider
|
|
|
|
| 29 |
|
| 30 |
logger = logging.getLogger(__name__)
|
| 31 |
|
|
|
|
| 32 |
|
| 33 |
class AuthServerSettings(BaseModel):
|
| 34 |
"""Settings for the Authorization Server."""
|
| 35 |
|
| 36 |
# Server settings
|
| 37 |
-
host: str = "
|
| 38 |
port: int = 7860
|
| 39 |
-
server_url: AnyHttpUrl = AnyHttpUrl("https://
|
| 40 |
-
auth_callback_path: str = "https://
|
| 41 |
|
| 42 |
|
| 43 |
class SimpleAuthProvider(SimpleOAuthProvider):
|
|
@@ -173,7 +175,7 @@ def main(port: int) -> int:
|
|
| 173 |
auth_settings = SimpleAuthSettings()
|
| 174 |
|
| 175 |
# Create server settings
|
| 176 |
-
host = "
|
| 177 |
server_url = f"https://{host}" #:{port}"
|
| 178 |
server_settings = AuthServerSettings(
|
| 179 |
host=host,
|
|
|
|
| 26 |
from mcp.server.auth.settings import AuthSettings, ClientRegistrationOptions
|
| 27 |
|
| 28 |
from simple_auth_provider import SimpleAuthSettings, SimpleOAuthProvider
|
| 29 |
+
import os
|
| 30 |
|
| 31 |
logger = logging.getLogger(__name__)
|
| 32 |
|
| 33 |
+
as_host_name = os.getenv(AS_HOST_NAME, 'localhost')
|
| 34 |
|
| 35 |
class AuthServerSettings(BaseModel):
|
| 36 |
"""Settings for the Authorization Server."""
|
| 37 |
|
| 38 |
# Server settings
|
| 39 |
+
host: str = F"{as_host_name}.hf.space"
|
| 40 |
port: int = 7860
|
| 41 |
+
server_url: AnyHttpUrl = AnyHttpUrl(F"https://{as_host_name}.hf.space")
|
| 42 |
+
auth_callback_path: str = F"https://{as_host_name}.hf.space/login/callback"
|
| 43 |
|
| 44 |
|
| 45 |
class SimpleAuthProvider(SimpleOAuthProvider):
|
|
|
|
| 175 |
auth_settings = SimpleAuthSettings()
|
| 176 |
|
| 177 |
# Create server settings
|
| 178 |
+
host = F"{as_host_name}.hf.space"
|
| 179 |
server_url = f"https://{host}" #:{port}"
|
| 180 |
server_settings = AuthServerSettings(
|
| 181 |
host=host,
|
simple_auth_provider.py
CHANGED
|
@@ -39,6 +39,9 @@ class SimpleAuthSettings(BaseSettings):
|
|
| 39 |
model_config = SettingsConfigDict(env_prefix="MCP_")
|
| 40 |
|
| 41 |
# Demo user credentials
|
|
|
|
|
|
|
|
|
|
| 42 |
demo_username: str = os.getenv('DEMO_USER',"demo_user")
|
| 43 |
demo_password: str = os.getenv('DEMO_PASSWORD',"demo_password")
|
| 44 |
|
|
|
|
| 39 |
model_config = SettingsConfigDict(env_prefix="MCP_")
|
| 40 |
|
| 41 |
# Demo user credentials
|
| 42 |
+
# To over write default user and password set up enviromental
|
| 43 |
+
# variables for DEMO_USER and DEMO_PASSWORD to force use of
|
| 44 |
+
# user name and password
|
| 45 |
demo_username: str = os.getenv('DEMO_USER',"demo_user")
|
| 46 |
demo_password: str = os.getenv('DEMO_PASSWORD',"demo_password")
|
| 47 |
|