arcade-mcp/libs/arcade-core/arcade_core/auth.py
jottakka 178c194ef2
[TOO-192] Update tdk to add figma typed oauth (#711)
Closes TOO-192

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds a Figma OAuth2 auth provider and wires it through TDK and MCP
server, with tests updated and package versions bumped.
> 
> - **Auth**:
> - Add `Figma` OAuth2 provider in
`libs/arcade-core/arcade_core/auth.py`.
> - **Exports**:
> - Expose `Figma` in
`libs/arcade-mcp-server/arcade_mcp_server/auth/__init__.py` and
`libs/arcade-tdk/arcade_tdk/auth/__init__.py` (`__all__`).
> - **Tests**:
> - Add Figma auth requirement test case in
`libs/tests/tool/test_create_tool_definition.py` and import `Figma`.
> - **Versioning**:
>   - Bump `arcade-mcp-server` to `1.10.2` and `arcade-tdk` to `3.2.0`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2bacfdc5695b3e7fc5e4532dbd360c3b2263130e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Francisco Liberal <francisco@arcade.dev>
2025-12-05 16:38:12 -03:00

204 lines
6 KiB
Python

from enum import Enum
from typing import Optional
from pydantic import BaseModel, ConfigDict
class AuthProviderType(str, Enum):
oauth2 = "oauth2"
class ToolAuthorization(BaseModel):
"""Marks a tool as requiring authorization."""
model_config = ConfigDict(frozen=True)
provider_id: Optional[str] = None
"""The provider ID configured in Arcade that acts as an alias to well-known configuration."""
provider_type: AuthProviderType
"""The type of the authorization provider."""
id: Optional[str] = None
"""A provider's unique identifier, allowing the tool to specify a specific authorization provider. Recommended for private tools only."""
scopes: Optional[list[str]] = None
"""The scope(s) needed for the authorized action."""
class OAuth2(ToolAuthorization):
"""Marks a tool as requiring OAuth 2.0 authorization."""
def __init__(self, *, id: str | None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes, provider_type=AuthProviderType.oauth2)
class Asana(OAuth2):
"""Marks a tool as requiring Asana authorization."""
provider_id: str = "asana"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Atlassian(OAuth2):
"""Marks a tool as requiring Atlassian authorization."""
provider_id: str = "atlassian"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class ClickUp(OAuth2):
"""Marks a tool as requiring ClickUp authorization."""
provider_id: str = "clickup"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Discord(OAuth2):
"""Marks a tool as requiring Discord authorization."""
provider_id: str = "discord"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Dropbox(OAuth2):
"""Marks a tool as requiring Dropbox authorization."""
provider_id: str = "dropbox"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Figma(OAuth2):
"""Marks a tool as requiring Figma authorization."""
provider_id: str = "figma"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class GitHub(OAuth2):
"""Marks a tool as requiring GitHub App authorization."""
provider_id: str = "github"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Google(OAuth2):
"""Marks a tool as requiring Google authorization."""
provider_id: str = "google"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Hubspot(OAuth2):
"""Marks a tool as requiring Hubspot authorization."""
provider_id: str = "hubspot"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Linear(OAuth2):
"""Marks a tool as requiring Linear authorization."""
provider_id: str = "linear"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class LinkedIn(OAuth2):
"""Marks a tool as requiring LinkedIn authorization."""
provider_id: str = "linkedin"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Microsoft(OAuth2):
"""Marks a tool as requiring Microsoft authorization."""
provider_id: str = "microsoft"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Notion(OAuth2):
"""Marks a tool as requiring Notion authorization."""
provider_id: str = "notion"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Reddit(OAuth2):
"""Marks a tool as requiring Reddit authorization."""
provider_id: str = "reddit"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Slack(OAuth2):
"""Marks a tool as requiring Slack (user token) authorization."""
provider_id: str = "slack"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Spotify(OAuth2):
"""Marks a tool as requiring Spotify authorization."""
provider_id: str = "spotify"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Twitch(OAuth2):
"""Marks a tool as requiring Twitch authorization."""
provider_id: str = "twitch"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class X(OAuth2):
"""Marks a tool as requiring X (Twitter) authorization."""
provider_id: str = "x"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)
class Zoom(OAuth2):
"""Marks a tool as requiring Zoom authorization."""
provider_id: str = "zoom"
def __init__(self, *, id: Optional[str] = None, scopes: Optional[list[str]] = None): # noqa: A002
super().__init__(id=id, scopes=scopes)