Many identity providers (AWS Cognito, Okta, Azure AD) reject or mishandle colons in OAuth scope names. This migrates all custom scopes from `resource:action` to `resource.action` format (e.g., `notes:read` → `notes.read`), which is universally accepted and aligns with industry conventions (Microsoft, Google). Includes Alembic migration 004 for stored scope strings and ADR-024 documenting the rationale and RFC references. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
81 lines
2.5 KiB
Python
81 lines
2.5 KiB
Python
"""Pydantic response models for Login Flow v2 auth tools."""
|
|
|
|
from pydantic import Field
|
|
|
|
from nextcloud_mcp_server.models.base import BaseResponse
|
|
|
|
|
|
class ProvisionAccessResponse(BaseResponse):
|
|
"""Response from nc_auth_provision_access tool."""
|
|
|
|
status: str = Field(
|
|
description="Provisioning status: 'login_required', 'already_provisioned', 'declined', 'cancelled', 'error'"
|
|
)
|
|
login_url: str | None = Field(
|
|
None, description="URL to open in browser for Nextcloud login"
|
|
)
|
|
message: str = Field(description="Human-readable status message")
|
|
user_id: str | None = Field(None, description="MCP user ID")
|
|
requested_scopes: list[str] | None = Field(
|
|
None, description="Scopes requested in this provisioning flow"
|
|
)
|
|
|
|
|
|
class ProvisionStatusResponse(BaseResponse):
|
|
"""Response from nc_auth_check_status tool."""
|
|
|
|
status: str = Field(
|
|
description="Status: 'provisioned', 'pending', 'not_initiated', 'error'"
|
|
)
|
|
message: str = Field(description="Human-readable status message")
|
|
user_id: str | None = Field(None, description="MCP user ID")
|
|
scopes: list[str] | None = Field(
|
|
None, description="Granted scopes (None = all scopes)"
|
|
)
|
|
username: str | None = Field(None, description="Nextcloud username (loginName)")
|
|
|
|
|
|
class UpdateScopesResponse(BaseResponse):
|
|
"""Response from nc_auth_update_scopes tool."""
|
|
|
|
status: str = Field(
|
|
description="Status: 'login_required', 'unchanged', 'declined', 'cancelled', 'error'"
|
|
)
|
|
login_url: str | None = Field(
|
|
None, description="URL for re-provisioning with new scopes"
|
|
)
|
|
message: str = Field(description="Human-readable status message")
|
|
previous_scopes: list[str] | None = Field(
|
|
None, description="Previously granted scopes"
|
|
)
|
|
new_scopes: list[str] | None = Field(None, description="Updated scope set")
|
|
|
|
|
|
# All supported application-level scopes (frozenset for O(1) membership tests)
|
|
ALL_SUPPORTED_SCOPES: frozenset[str] = frozenset(
|
|
{
|
|
"notes.read",
|
|
"notes.write",
|
|
"calendar.read",
|
|
"calendar.write",
|
|
"todo.read",
|
|
"todo.write",
|
|
"contacts.read",
|
|
"contacts.write",
|
|
"files.read",
|
|
"files.write",
|
|
"tables.read",
|
|
"tables.write",
|
|
"deck.read",
|
|
"deck.write",
|
|
"cookbook.read",
|
|
"cookbook.write",
|
|
"sharing.read",
|
|
"sharing.write",
|
|
"news.read",
|
|
"news.write",
|
|
"collectives.read",
|
|
"collectives.write",
|
|
}
|
|
)
|