- {identityProvider.name}
+ {identityProvider.title}
({identityProvider.type})
diff --git a/web/src/grpcweb.ts b/web/src/grpcweb.ts
index 28370cde..0b63bccd 100644
--- a/web/src/grpcweb.ts
+++ b/web/src/grpcweb.ts
@@ -1,6 +1,7 @@
import { createChannel, createClientFactory, FetchTransport } from "nice-grpc-web";
import { ActivityServiceDefinition } from "./types/proto/api/v2/activity_service";
import { AuthServiceDefinition } from "./types/proto/api/v2/auth_service";
+import { IdentityProviderServiceDefinition } from "./types/proto/api/v2/idp_service";
import { InboxServiceDefinition } from "./types/proto/api/v2/inbox_service";
import { LinkServiceDefinition } from "./types/proto/api/v2/link_service";
import { MemoServiceDefinition } from "./types/proto/api/v2/memo_service";
@@ -44,3 +45,5 @@ export const webhookServiceClient = clientFactory.create(WebhookServiceDefinitio
export const linkServiceClient = clientFactory.create(LinkServiceDefinition, channel);
export const storageServiceClient = clientFactory.create(StorageServiceDefinition, channel);
+
+export const identityProviderServiceClient = clientFactory.create(IdentityProviderServiceDefinition, channel);
diff --git a/web/src/helpers/api.ts b/web/src/helpers/api.ts
deleted file mode 100644
index 649043a8..00000000
--- a/web/src/helpers/api.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import axios from "axios";
-
-axios.defaults.baseURL = import.meta.env.VITE_API_BASE_URL || "";
-axios.defaults.withCredentials = true;
-
-export function getIdentityProviderList() {
- return axios.get
(`/api/v1/idp`);
-}
-
-export function createIdentityProvider(identityProviderCreate: IdentityProviderCreate) {
- return axios.post(`/api/v1/idp`, identityProviderCreate);
-}
-
-export function patchIdentityProvider(identityProviderPatch: IdentityProviderPatch) {
- return axios.patch(`/api/v1/idp/${identityProviderPatch.id}`, identityProviderPatch);
-}
-
-export function deleteIdentityProvider(id: IdentityProviderId) {
- return axios.delete(`/api/v1/idp/${id}`);
-}
diff --git a/web/src/pages/SignIn.tsx b/web/src/pages/SignIn.tsx
index 286b6466..f5a2b025 100644
--- a/web/src/pages/SignIn.tsx
+++ b/web/src/pages/SignIn.tsx
@@ -5,13 +5,13 @@ import { toast } from "react-hot-toast";
import { Link } from "react-router-dom";
import AppearanceSelect from "@/components/AppearanceSelect";
import LocaleSelect from "@/components/LocaleSelect";
-import { authServiceClient } from "@/grpcweb";
-import * as api from "@/helpers/api";
+import { authServiceClient, identityProviderServiceClient } from "@/grpcweb";
import { absolutifyLink } from "@/helpers/utils";
import useLoading from "@/hooks/useLoading";
import useNavigateTo from "@/hooks/useNavigateTo";
import { useCommonContext } from "@/layouts/CommonContextProvider";
-import { useUserStore, useWorkspaceSettingStore } from "@/store/v1";
+import { extractIdentityProviderIdFromName, useUserStore, useWorkspaceSettingStore } from "@/store/v1";
+import { IdentityProvider, IdentityProvider_Type } from "@/types/proto/api/v2/idp_service";
import { WorkspaceGeneralSetting } from "@/types/proto/api/v2/workspace_setting_service";
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
import { useTranslate } from "@/utils/i18n";
@@ -33,8 +33,8 @@ const SignIn = () => {
useEffect(() => {
const fetchIdentityProviderList = async () => {
- const { data: identityProviderList } = await api.getIdentityProviderList();
- setIdentityProviderList(identityProviderList);
+ const { identityProviders } = await identityProviderServiceClient.listIdentityProviders({});
+ setIdentityProviderList(identityProviders);
};
fetchIdentityProviderList();
}, []);
@@ -95,10 +95,14 @@ const SignIn = () => {
};
const handleSignInWithIdentityProvider = async (identityProvider: IdentityProvider) => {
- const stateQueryParameter = `auth.signin.${identityProvider.name}-${identityProvider.id}`;
- if (identityProvider.type === "OAUTH2") {
+ const stateQueryParameter = `auth.signin.${identityProvider.title}-${extractIdentityProviderIdFromName(identityProvider.name)}`;
+ if (identityProvider.type === IdentityProvider_Type.OAUTH2) {
const redirectUri = absolutifyLink("/auth/callback");
- const oauth2Config = identityProvider.config.oauth2Config;
+ const oauth2Config = identityProvider.config?.oauth2Config;
+ if (!oauth2Config) {
+ toast.error("Identity provider configuration is invalid.");
+ return;
+ }
const authUrl = `${oauth2Config.authUrl}?client_id=${
oauth2Config.clientId
}&redirect_uri=${redirectUri}&state=${stateQueryParameter}&response_type=code&scope=${encodeURIComponent(
@@ -185,7 +189,7 @@ const SignIn = () => {
{identityProviderList.map((identityProvider) => (