From a3c913e15c41de73c4342545b2becab84f49eb49 Mon Sep 17 00:00:00 2001 From: Alyssa Wang Date: Wed, 23 Oct 2024 10:43:58 -0400 Subject: [PATCH] FI-3285: Add fields to backend services access mode (#544) * show access fields for backend services access mode * simplify hide condition * rename token check * update to variable name --- .../components/InputsModal/AuthSettings.ts | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/client/src/components/InputsModal/AuthSettings.ts b/client/src/components/InputsModal/AuthSettings.ts index 9a331752e..3d3fbf1bc 100644 --- a/client/src/components/InputsModal/AuthSettings.ts +++ b/client/src/components/InputsModal/AuthSettings.ts @@ -234,6 +234,11 @@ export const getAccessFields = ( accessValues: Map, components: TestInput[], ): TestInput[] => { + const tokenDoesNotExist = + authType === 'backend_services' + ? !accessValues.get('access_token') + : !accessValues.get('refresh_token'); + const fields = [ { name: 'access_token', @@ -249,7 +254,7 @@ export const getAccessFields = ( title: 'Client ID', description: 'Client ID provided during registration of Inferno', optional: true, - hide: !accessValues.get('refresh_token'), + hide: tokenDoesNotExist, }, { name: 'client_secret', @@ -263,7 +268,7 @@ export const getAccessFields = ( title: 'Token URL', description: "URL of the authorization server's token endpoint", optional: true, - hide: !accessValues.get('refresh_token'), + hide: tokenDoesNotExist, }, { name: 'encryption_algorithm', @@ -282,9 +287,7 @@ export const getAccessFields = ( ], }, optional: true, - hide: - !accessValues.get('refresh_token') || - (authType === 'backend_services' && !accessValues.get('access_token')), + hide: tokenDoesNotExist, }, { name: 'kid', @@ -292,10 +295,7 @@ export const getAccessFields = ( description: 'Key ID of the JWKS private key used to sign the client assertion. If blank, the first key for the selected encryption algorithm will be used.', optional: true, - hide: - authType === 'backend_services' - ? !accessValues.get('access_token') - : !accessValues.get('refresh_token'), + hide: tokenDoesNotExist, }, { name: 'jwks', @@ -304,30 +304,21 @@ export const getAccessFields = ( description: "The JWKS (including private keys) which will be used to sign the client assertion. If blank, Inferno's default JWKS will be used.", optional: true, - hide: - authType === 'backend_services' - ? !accessValues.get('access_token') - : !accessValues.get('refresh_token'), + hide: tokenDoesNotExist, }, { name: 'issue_time', title: 'Access Token Issue Time', description: 'The time that the access token was issued in iso8601 format', optional: true, - hide: - authType === 'backend_services' - ? !accessValues.get('access_token') - : !accessValues.get('refresh_token'), + hide: tokenDoesNotExist, }, { name: 'expires_in', title: 'Token Lifetime', description: 'The lifetime of the access token in seconds', optional: true, - hide: - authType === 'backend_services' - ? !accessValues.get('access_token') - : !accessValues.get('refresh_token'), + hide: tokenDoesNotExist, }, ] as TestInput[];