Skip to content

Commit ddee95b

Browse files
committed
[PLAT-15464]Turn ON/OFF the runtime configs as per the LDAP Configure membership lookup settings
Summary: Refactor LDAPConstants and LDAPUtils Update the LDAPUseQuery enum values in LDAPConstants.ts to reflect the correct configuration for user attributes and group search filters. Also remove the unnecessary transformation of ldap_group_use_role_mapping in LDAPUtils.ts. Backend will handle this Added 'ldap_group_use_role_mapping' toggle. Test Plan: Tested manually {F302751} Reviewers: lsangappa Reviewed By: lsangappa Subscribers: yugaware Differential Revision: https://phorge.dev.yugabyte.com/D39288
1 parent 6f10787 commit ddee95b

File tree

5 files changed

+44
-35
lines changed

5 files changed

+44
-35
lines changed

managed/ui/src/redesign/features/rbac/RBACContainer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const RBACComponent = (props: WithRouterProps) => {
5353
eventKey="user-auth-new"
5454
title={
5555
<span>
56-
<KeyIcon />
5756
User Authentication New
5857
</span>
5958
}

managed/ui/src/redesign/features/userAuth/ldap/LDAPAuthRedesigned.tsx

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* http://github.com/YugaByte/yugabyte-db/blob/master/licenses/POLYFORM-FREE-TRIAL-LICENSE-1.0.0.txt
88
*/
99

10-
import { useState } from 'react';
10+
import { useEffect, useState } from 'react';
1111
import { find, isString } from 'lodash';
1212
import { useForm } from 'react-hook-form';
1313
import { useMutation, useQuery, useQueryClient } from 'react-query';
@@ -158,7 +158,7 @@ const useStyles = makeStyles((theme) => ({
158158
borderRight: 'none',
159159
justifyContent: 'center',
160160
'& .MuiAccordionSummary-root': {
161-
height: '86px',
161+
height: '120px',
162162
padding: '16px 24px'
163163
},
164164
'& .MuiAccordionSummary-content': {
@@ -171,10 +171,6 @@ const useStyles = makeStyles((theme) => ({
171171
alignItems: 'center',
172172
marginBottom: '8px'
173173
},
174-
groupsIcon: {
175-
width: '24px',
176-
height: '24px'
177-
},
178174
accordionDetails: {
179175
flexDirection: 'column',
180176
gap: '24px',
@@ -183,6 +179,9 @@ const useStyles = makeStyles((theme) => ({
183179
},
184180
scope: {
185181
width: '308px'
182+
},
183+
ldapUseRoleMapping: {
184+
marginTop: '16px'
186185
}
187186
}));
188187

@@ -212,8 +211,8 @@ const initializeFormValues = (configEntries: RunTimeConfigEntry[]) => {
212211
enable_ldaps === 'true'
213212
? SecurityOption.ENABLE_LDAPS
214213
: enable_ldap_start_tls === 'true'
215-
? SecurityOption.ENABLE_LDAP_START_TLS
216-
: SecurityOption.UNSECURE;
214+
? SecurityOption.ENABLE_LDAP_START_TLS
215+
: SecurityOption.UNSECURE;
217216
finalFormData = { ...finalFormData, ldap_security };
218217

219218
return finalFormData;
@@ -304,6 +303,12 @@ export const LDAPAuthNew = () => {
304303
return promiseArray;
305304
};
306305

306+
const ldapUseGroupMapping = watch('ldap_group_use_role_mapping');
307+
308+
useEffect(()=> {
309+
setGroupSettingsExpanded(ldapUseGroupMapping);
310+
}, [ldapUseGroupMapping]);
311+
307312
if (isLoading) return <YBLoadingCircleIcon />;
308313
if (isError) return <YBErrorIndicator />;
309314

@@ -322,7 +327,7 @@ export const LDAPAuthNew = () => {
322327
const securityProtocol = watch('ldap_security');
323328
const useSearchAndBind = watch('use_search_and_bind');
324329
const ldapUseQuery = watch('ldap_group_use_query');
325-
330+
326331
const toolTip = (content: string) => {
327332
return (
328333
<YBTooltip title={content} placement="top">
@@ -393,21 +398,21 @@ export const LDAPAuthNew = () => {
393398
/>
394399
{(securityProtocol === SecurityOption.ENABLE_LDAPS ||
395400
securityProtocol === SecurityOption.ENABLE_LDAP_START_TLS) && (
396-
<YBRadioGroupField
397-
label={
398-
<>
399-
{t('tlsProtocol')}
400-
{toolTip(t('infos.tlsProtocol'))}
401-
</>
402-
}
403-
name="ldap_tls_protocol"
404-
options={TLSVersions}
405-
control={control}
406-
orientation="horizontal"
407-
isDisabled={!ldapEnabled}
408-
data-testid="tls-protocol"
409-
/>
410-
)}
401+
<YBRadioGroupField
402+
label={
403+
<>
404+
{t('tlsProtocol')}
405+
{toolTip(t('infos.tlsProtocol'))}
406+
</>
407+
}
408+
name="ldap_tls_protocol"
409+
options={TLSVersions}
410+
control={control}
411+
orientation="horizontal"
412+
isDisabled={!ldapEnabled}
413+
data-testid="tls-protocol"
414+
/>
415+
)}
411416
<YBInputField
412417
control={control}
413418
name="ldap_basedn"
@@ -548,16 +553,21 @@ export const LDAPAuthNew = () => {
548553
</div>
549554
<Accordion
550555
expanded={groupSettingsExpanded}
551-
onChange={() => setGroupSettingsExpanded(!groupSettingsExpanded)}
552556
className={classes.groupSettings}
553557
data-testid="group-settings-tab"
554558
>
555-
<AccordionSummary expandIcon={<ArrowDropDown className={classes.groupsIcon} />}>
559+
<AccordionSummary>
556560
<div className={classes.groupHeader}>
557-
<UserGroupsIcon className={classes.groupsIcon} />
558561
<Typography variant="body1">{t('group.title')}</Typography>
559562
</div>
560563
{t('group.helpText')}
564+
<div className={classes.ldapUseRoleMapping}>
565+
<YBToggleField
566+
name="ldap_group_use_role_mapping"
567+
control={control}
568+
label={t('ldapUseRoleMapping')}
569+
/>
570+
</div>
561571
</AccordionSummary>
562572
<AccordionDetails className={classes.accordionDetails}>
563573
<YBRadioGroupField

managed/ui/src/redesign/features/userAuth/ldap/LDAPConstants.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ export const AuthModes = [
8181
];
8282

8383
export enum LDAPUseQuery {
84-
USER_ATTRIBUTE = 'true',
85-
GROUP_SEARCH_FILTER = 'false'
84+
USER_ATTRIBUTE = 'false',
85+
GROUP_SEARCH_FILTER = 'true'
8686
}
8787

8888
export const LDAPUseQueryOptions = [
8989
{
9090
label: 'User Attribute',
91-
value: 'true'
91+
value: 'false'
9292
},
9393
{
9494
label: 'Group Search Filter',
95-
value: 'false'
95+
value: 'true'
9696
}
9797
];
9898

managed/ui/src/redesign/features/userAuth/ldap/LDAPUtils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export const transformData = (values: LDAPFormProps): Record<string, any> => {
2424
ldap_port: ldap_port ?? '',
2525
ldap_basedn: ldap_basedn ?? '',
2626
enable_ldaps: `${security === 'enable_ldaps'}`,
27-
enable_ldap_start_tls: `${security === 'enable_ldap_start_tls'}`
27+
enable_ldap_start_tls: `${security === 'enable_ldap_start_tls'}`,
28+
ldap_group_use_role_mapping: `${values.ldap_group_use_role_mapping}`
2829
} as Record<keyof LDAPFormProps, any>;
2930

3031
if (String(use_search_and_bind) === 'false') {
@@ -40,7 +41,5 @@ export const transformData = (values: LDAPFormProps): Record<string, any> => {
4041
transformedData.ldap_service_account_password = '';
4142
}
4243

43-
transformedData['ldap_group_use_role_mapping'] = String(String(values.ldap_group_use_query) === 'false');
44-
4544
return omit(transformedData, 'ldap_security', 'use_service_account');
4645
};

managed/ui/src/translations/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,7 @@
25472547
"groupSearchBaseDN": "Group Search Base DN",
25482548
"ldapGroupSearchScope": "Select Scope",
25492549
"addServiceAccountDetails": "Add Service Account Details",
2550+
"ldapUseRoleMapping": "Map YugabyteDB Anywhere built-in roles to your existing LDAP groups",
25502551
"infos": {
25512552
"ldapEnabled": "Enable or Disable LDAP Authentication",
25522553
"ldapURL": "LDAP URL must be a valid URL with port number, Ex:- 0.0.0.0:0000",

0 commit comments

Comments
 (0)