@@ -11,14 +11,14 @@ import {json} from "react-router-dom";
1111
1212const SearchApplicationSettings : React . FC = ( ) => {
1313 const dispatch = useDispatch ( ) ;
14- const { appName, apiKey , searchEndpoint, searchPersona} = useSelector ( ( state : RootState ) => state . searchApplicationSettings ) ;
14+ const { appName, appUser , appPassword , searchEndpoint, searchPersona} = useSelector ( ( state : RootState ) => state . searchApplicationSettings ) ;
1515 const { showToast} = useToast ( ) ;
1616
1717 const fetchPersonaOptions = async ( ) => {
1818 try {
1919 const identitiesIndex = ".search-acl-filter-search-sharepoint" //TODO fix hardcoded
2020 const identitiesPath = searchEndpoint + "/" + identitiesIndex + "/_search"
21- const response = await fetch ( identitiesPath , { headers : { "Authorization" : "ApiKey " + apiKey } } ) ;
21+ const response = await fetch ( identitiesPath , { headers : { "Authorization" : "Basic " + btoa ( appUser + ":" + appPassword ) } } ) ;
2222 const jsonData = await response . json ( ) ;
2323 const ids = jsonData . hits . hits . map ( ( hit ) => hit . _id )
2424 return ids
@@ -49,15 +49,19 @@ const SearchApplicationSettings: React.FC = () => {
4949 } ;
5050
5151 const handleSave = ( ) => {
52- dispatch ( updateSettings ( { appName, apiKey , searchEndpoint, searchPersona} ) ) ;
52+ dispatch ( updateSettings ( { appName, appUser , appPassword , searchEndpoint, searchPersona} ) ) ;
5353 showToast ( "Settings saved!" , MessageType . Info ) ;
5454 } ;
5555
56- const updateAppName = ( e ) => dispatch ( updateSettings ( { appName : e . target . value , apiKey, searchEndpoint, searchPersona} ) )
57- const updateApiKey = ( e ) => dispatch ( updateSettings ( { appName, apiKey : e . target . value , searchEndpoint, searchPersona} ) )
58- const updateSearchEndpoint = ( e ) => dispatch ( updateSettings ( { appName, apiKey, searchEndpoint : e . target . value , searchPersona} ) )
56+ const updateAppName = ( e ) => dispatch ( updateSettings ( { appName : e . target . value , appUser, appPassword, searchEndpoint, searchPersona} ) )
5957
60- const updateSearchPersona = ( e ) => dispatch ( updateSettings ( { appName, apiKey, searchEndpoint, searchPersona : e } ) )
58+ const updateAppUser = ( e ) => dispatch ( updateSettings ( { appName, appUser : e . target . value , appPassword, searchEndpoint, searchPersona} ) )
59+
60+ const updateAppPassword = ( e ) => dispatch ( updateSettings ( { appName, appUser, appPassword : e . target . value , searchEndpoint, searchPersona} ) )
61+
62+ const updateSearchEndpoint = ( e ) => dispatch ( updateSettings ( { appName, appUser, appPassword, searchEndpoint : e . target . value , searchPersona} ) )
63+
64+ const updateSearchPersona = ( e ) => dispatch ( updateSettings ( { appName, appUser, appPassword, searchEndpoint, searchPersona : e } ) )
6165
6266 return (
6367 < div className = "container mx-auto p-4 bg-white rounded shadow-md" >
@@ -91,17 +95,34 @@ const SearchApplicationSettings: React.FC = () => {
9195
9296 < div className = "text-left mb-6 p-4 border rounded bg-gray-50" >
9397 < label
94- htmlFor = "apiKey"
98+ htmlFor = "appUser"
99+ className = "block text-sm font-medium mb-1 text-gray-700"
100+ >
101+ Application Elasticsearch Username:
102+ </ label >
103+ < p className = "text-xs mb-2 text-gray-500" > The Elasticsearch username to use to establish a connection with.</ p >
104+ < input
105+ id = "appUser"
106+ type = "text"
107+ value = { appUser }
108+ onChange = { updateAppUser }
109+ className = "p-2 w-full border rounded focus:outline-none focus:shadow-outline"
110+ />
111+ </ div >
112+
113+ < div className = "text-left mb-6 p-4 border rounded bg-gray-50" >
114+ < label
115+ htmlFor = "appPassword"
95116 className = "block text-sm font-medium mb-1 text-gray-700"
96117 >
97- Application API Key :
118+ Application Elasticsearch Password :
98119 </ label >
99- < p className = "text-xs mb-2 text-gray-500" > Your application's unique API key used for looking up identities .</ p >
120+ < p className = "text-xs mb-2 text-gray-500" > The Elasticsearch password to use to establish a connection with .</ p >
100121 < input
101- id = "apiKey "
122+ id = "appPassword "
102123 type = "password"
103- value = { apiKey }
104- onChange = { updateApiKey }
124+ value = { appPassword }
125+ onChange = { updateAppPassword }
105126 className = "p-2 w-full border rounded focus:outline-none focus:shadow-outline"
106127 />
107128 </ div >
0 commit comments