Skip to content

Commit a5290f7

Browse files
authored
Merge pull request #860 from raheeliftikhar5/generic-oauth-updates
Generic oauth fixes/updates
2 parents 643e844 + dff4713 commit a5290f7

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

client/packages/lowcoder/src/pages/editor/right/uiCompPanel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const UICompPanel = () => {
145145
const compList = useMemo(
146146
() =>
147147
Object.entries(categories)
148-
.filter(([key]) => !(!isEmpty(searchValue) && (key as UICompCategory) === "dashboards"))
148+
// .filter(([key]) => !(!isEmpty(searchValue) && (key as UICompCategory) === "dashboards"))
149149
.map(([key, value], index) => {
150150
let infos = value;
151151
if (!isEmpty(searchValue)) {

client/packages/lowcoder/src/pages/setting/idSource/OAuthForms/GenericOAuthForm.tsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from "react";
2-
import { messageInstance, CloseEyeIcon } from "lowcoder-design";
2+
import { messageInstance, CloseEyeIcon, CustomSelect } from "lowcoder-design";
33
import { i18nObjs, trans } from "i18n";
44
import {
55
FormStyled,
@@ -107,7 +107,7 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
107107
setSaveLoading(true);
108108
const { issuer } = values;
109109
try {
110-
const res = await axios.get<OpenIdProvider>(`${issuer}/.well-known/openid-configuration`);
110+
const res = await axios.get<OpenIdProvider>(issuer);
111111
setIssuerDetails(() => {
112112
const issuer = {
113113
authType: AuthType.Generic,
@@ -155,7 +155,6 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
155155
}
156156
};
157157
saveAuthProvider(updatedDetails);
158-
console.log('save details', updatedDetails);
159158
return updatedDetails;
160159
});
161160
})
@@ -189,6 +188,7 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
189188
current={currentStep}
190189
items={steps}
191190
style={{marginBottom: '16px'}}
191+
onChange={(current) => setCurrentStep(current)}
192192
/>
193193

194194
<FormStyled
@@ -213,11 +213,13 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
213213
)}
214214
{currentStep === 1 && Object.entries(authConfigForm).map(([key, value]) => {
215215
const valueObject = _.isObject(value) ? (value as ItemType) : false;
216-
const required = true;
216+
let required = (key === "clientId" || key === "clientSecret" || key === "scope");
217+
required = valueObject ? valueObject.isRequire ?? required : required;
217218
const label = valueObject ? valueObject.label : value as string;
218219
const tip = valueObject && valueObject.tip;
219220
const isPassword = valueObject && valueObject.isPassword;
220221
const isIcon = valueObject && valueObject.isIcon;
222+
const isList = valueObject && valueObject.isList;
221223
return (
222224
<div key={key}>
223225
<Form.Item
@@ -250,12 +252,19 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
250252
placeholder={trans("idSource.encryptedServer")}
251253
autoComplete={"one-time-code"}
252254
/>
253-
) : isIcon ? (
255+
) : !isPassword && !isList && isIcon ? (
254256
<IconPicker
255257
onChange={(value) => form1.setFieldValue("sourceIcon", value)}
256258
label={'Source Icon'}
257259
value={form1.getFieldValue('sourceIcon')}
258260
/>
261+
) : !isPassword && isList && !isIcon ? (
262+
<CustomSelect
263+
options={(value as ItemType).options}
264+
placeholder={trans("idSource.formSelectPlaceholder", {
265+
label,
266+
})}
267+
/>
259268
) : (
260269
<Input
261270
placeholder={trans("idSource.formPlaceholder", {

client/packages/lowcoder/src/pages/setting/idSource/idSourceConstants.ts

+28-8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ export const IdSource = [
1919
AuthType.Generic,
2020
];
2121

22+
export enum AuthCategoriesEnum {
23+
ENTERPISE_ENTITY = "Enterprise Identity",
24+
CLOUD_SERVICES = "Cloud Services",
25+
SOCIAL_MEDIA = "Social Media",
26+
DEVELOPMENT = "Development",
27+
TOOLS_AND_PRODUCTIVITY = "Tools & Productivity",
28+
}
29+
30+
type AuthCategoriesEnumKey = keyof typeof AuthCategoriesEnum;
31+
const AuthCategories = Object.keys(AuthCategoriesEnum).map(
32+
(cat) => {
33+
const value = AuthCategoriesEnum[cat as AuthCategoriesEnumKey];
34+
return {
35+
label: value,
36+
value: cat
37+
}
38+
}
39+
);
40+
41+
2242
export const validatorOptions = [];
2343

2444
export const clientIdandSecretConfig = {
@@ -70,15 +90,15 @@ export const authConfig = {
7090
form: {
7191
source: { label: "Source", isRequire: true },
7292
sourceName: { label: "Source Name", isRequire: true },
73-
sourceDescription: { label: "Source Description" },
74-
sourceIcon: { label: "Source Icon", isIcon: true },
75-
sourceCategory: { label: "Source Category" },
93+
sourceDescription: { label: "Source Description", isRequire: false },
94+
sourceIcon: { label: "Source Icon", isIcon: true, isRequire: true, },
95+
sourceCategory: { label: "Source Category", isRequire: true, isList: true, options: AuthCategories },
7696
...clientIdandSecretConfig,
77-
issuer: { label: 'Issuer URI', isRequired: true },
78-
authorizationEndpoint: { label: 'Authorization Endpoint', isRequired: true },
79-
tokenEndpoint: { label: 'Token Endpoint', isRequired: true },
80-
userInfoEndpoint: { label: 'UserInfo Endpoint', isRequired: true },
81-
// jwks: { label: 'Authorize URL', isRequired: true },
97+
issuer: { label: 'Issuer URI', isRequire: true },
98+
authorizationEndpoint: { label: 'Authorization Endpoint', isRequire: true },
99+
tokenEndpoint: { label: 'Token Endpoint', isRequire: true },
100+
userInfoEndpoint: { label: 'UserInfo Endpoint', isRequire: true },
101+
// jwks: { label: 'Authorize URL', isRequire: true },
82102
scope: "Scope",
83103
// baseUrl: "Base URL",
84104
// realm: "Realm",

0 commit comments

Comments
 (0)