diff --git a/apiclient/types/oauthapp.go b/apiclient/types/oauthapp.go index ebdab3715..60f8b355f 100644 --- a/apiclient/types/oauthapp.go +++ b/apiclient/types/oauthapp.go @@ -9,6 +9,7 @@ const ( OAuthAppTypeGitHub OAuthAppType = "github" OAuthAppTypeGoogle OAuthAppType = "google" OAuthAppTypeSalesforce OAuthAppType = "salesforce" + OAuthAppTypeWordPress OAuthAppType = "wordpress" OAuthAppTypeZoom OAuthAppType = "zoom" OAuthAppTypeCustom OAuthAppType = "custom" ) diff --git a/pkg/gateway/types/oauth_apps.go b/pkg/gateway/types/oauth_apps.go index 3842f7e0f..a665ab3a9 100644 --- a/pkg/gateway/types/oauth_apps.go +++ b/pkg/gateway/types/oauth_apps.go @@ -28,6 +28,9 @@ const ( GitHubAuthorizeURL = "https://github.com/login/oauth/authorize" + WordPressAuthorizeURL = "https://public-api.wordpress.com/oauth2/authorize" + WordPressTokenURL = "https://public-api.wordpress.com/oauth2/token" + ZoomAuthorizeURL = "https://zoom.us/oauth/authorize" ZoomTokenURL = "https://zoom.us/oauth/token" ) @@ -71,6 +74,9 @@ func ValidateAndSetDefaultsOAuthAppManifest(r *types.OAuthAppManifest, create bo case types.OAuthAppTypeGitHub: r.AuthURL = GitHubAuthorizeURL r.TokenURL = GitHubTokenURL + case types.OAuthAppTypeWordPress: + r.AuthURL = WordPressAuthorizeURL + r.TokenURL = WordPressTokenURL case types.OAuthAppTypeZoom: r.AuthURL = ZoomAuthorizeURL r.TokenURL = ZoomTokenURL diff --git a/ui/admin/app/components/oauth-apps/OAuthAppTypeIcon.tsx b/ui/admin/app/components/oauth-apps/OAuthAppTypeIcon.tsx index bbc515b1a..b9bc1b0bc 100644 --- a/ui/admin/app/components/oauth-apps/OAuthAppTypeIcon.tsx +++ b/ui/admin/app/components/oauth-apps/OAuthAppTypeIcon.tsx @@ -8,6 +8,7 @@ import { FaMicrosoft, FaSalesforce, FaSlack, + FaWordpress, } from "react-icons/fa"; import { OAuthProvider } from "~/lib/model/oauthApps/oauth-helpers"; @@ -21,6 +22,7 @@ const IconMap = { [OAuthProvider.Google]: FaGoogle, [OAuthProvider.Microsoft365]: FaMicrosoft, [OAuthProvider.Notion]: NotionLogoIcon, + [OAuthProvider.WordPress]: FaWordpress, [OAuthProvider.Zoom]: BiLogoZoom, [OAuthProvider.Custom]: KeyIcon, }; diff --git a/ui/admin/app/lib/model/oauthApps/index.ts b/ui/admin/app/lib/model/oauthApps/index.ts index c1edfe18b..8e7912dee 100644 --- a/ui/admin/app/lib/model/oauthApps/index.ts +++ b/ui/admin/app/lib/model/oauthApps/index.ts @@ -11,6 +11,7 @@ import { Microsoft365OAuthApp } from "~/lib/model/oauthApps/providers/microsoft3 import { NotionOAuthApp } from "~/lib/model/oauthApps/providers/notion"; import { SalesforceOAuthApp } from "~/lib/model/oauthApps/providers/salesforce"; import { SlackOAuthApp } from "~/lib/model/oauthApps/providers/slack"; +import { WordPressOAuthApp } from "~/lib/model/oauthApps/providers/wordpress"; import { ZoomOAuthApp } from "~/lib/model/oauthApps/providers/zoom"; import { EntityMeta } from "~/lib/model/primitives"; @@ -22,6 +23,7 @@ export const OAuthAppSpecMap = { [OAuthProvider.Slack]: SlackOAuthApp, [OAuthProvider.Salesforce]: SalesforceOAuthApp, [OAuthProvider.Notion]: NotionOAuthApp, + [OAuthProvider.WordPress]: WordPressOAuthApp, [OAuthProvider.Zoom]: ZoomOAuthApp, // Custom OAuth apps are intentionally omitted from the map. // They are handled separately diff --git a/ui/admin/app/lib/model/oauthApps/oauth-helpers.ts b/ui/admin/app/lib/model/oauthApps/oauth-helpers.ts index 2b8cd06a0..2207fc587 100644 --- a/ui/admin/app/lib/model/oauthApps/oauth-helpers.ts +++ b/ui/admin/app/lib/model/oauthApps/oauth-helpers.ts @@ -10,6 +10,7 @@ export const OAuthProvider = { Slack: "slack", Salesforce: "salesforce", Notion: "notion", + WordPress: "wordpress", Zoom: "zoom", Custom: "custom", } as const; diff --git a/ui/admin/app/lib/model/oauthApps/providers/wordpress.ts b/ui/admin/app/lib/model/oauthApps/providers/wordpress.ts new file mode 100644 index 000000000..f10f2fbd0 --- /dev/null +++ b/ui/admin/app/lib/model/oauthApps/providers/wordpress.ts @@ -0,0 +1,71 @@ +import { z } from "zod"; + +import { + OAuthAppSpec, + OAuthFormStep, + getOAuthLinks, +} from "~/lib/model/oauthApps/oauth-helpers"; +import { assetUrl } from "~/lib/utils"; + +const schema = z.object({ + clientID: z.string().min(1, "Client ID is required"), + clientSecret: z.string().min(1, "Client Secret is required"), +}); + +const steps: OAuthFormStep>[] = [ + { + type: "markdown", + text: + "### Step 1: Create a New Application at Developer.wordpress.com:\n" + + "If you already have an app, you can skip to Step 2.\n\n" + + "- Ensure you are logged into your preferred Wordpress.com account.\n" + + "- You can create and manage your apps at the [Apps](https://developer.wordpress.com/apps/) page.\n" + + "- Click **Create New Application** on the top right corner.\n" + + "- Enter a **Name**, **Description**, and **Website** for your application.\n" + + "- Copy the url below and paste it into the **Redirect URL** field.\n", + }, + { + type: "copy", + text: getOAuthLinks("wordpress").redirectURL, + }, + { + type: "markdown", + text: + "- Leave **Javascript Origins** blank for now, but you can update it later.\n" + + "- For **Type**, select **Web**.\n" + + "- Click **Create**.\n" + + "- You will be redirected to the **Manage Application** page of the app you just created.\n", + }, + { + type: "markdown", + text: + "### Step 2: Register your App with Obot\n" + + "- In the **Manage Application** page, you can find the **Client ID** and **Client Secret** in the **OAuth Information** section.\n" + + "- Copy and paste them into the respective fields below.\n", + }, + { type: "input", input: "clientID", label: "Client ID" }, + { + type: "input", + input: "clientSecret", + label: "Client Secret", + inputType: "password", + }, + { + type: "markdown", + text: + "### (Optional) Create a New Site\n" + + "If you don't have a site yet, you can create one by following these steps:\n" + + "- Visit [WordPress Sites](https://wordpress.com/sites).\n" + + "- Click **Add New Site** in the top-right corner, and follow the instructions to create a new site.\n", + }, +]; + +export const WordPressOAuthApp = { + schema, + alias: "wordpress", + type: "wordpress", + displayName: "WordPress", + logo: assetUrl("/assets/wordpress-logo.png"), + steps: steps, + noGatewayIntegration: true, +} satisfies OAuthAppSpec; diff --git a/ui/admin/public/assets/wordpress-logo.png b/ui/admin/public/assets/wordpress-logo.png new file mode 100644 index 000000000..448064778 Binary files /dev/null and b/ui/admin/public/assets/wordpress-logo.png differ