From 9250ed720f521dc089f16d8df2c19a3418a8c848 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 5 Jul 2022 17:42:21 +0200 Subject: [PATCH 1/5] (bug) Gender, Address and Birthday are not mapped properly from SSO (#365) --- CHANGELOG.md | 2 ++ .../authentication-provider/type-mapping-modal.tsx | 5 +++++ .../src/javascript/models/authentication-provider.ts | 10 ++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 902c3eb60..a9a837e7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## next deploy +- Fix a bug: Gender, Address and Birthday are not mapped properly from SSO (#365) + ## v5.4.10 2022 July 05 - Increased About page title's size diff --git a/app/frontend/src/javascript/components/authentication-provider/type-mapping-modal.tsx b/app/frontend/src/javascript/components/authentication-provider/type-mapping-modal.tsx index 6b3e19d76..e2fc0539a 100644 --- a/app/frontend/src/javascript/components/authentication-provider/type-mapping-modal.tsx +++ b/app/frontend/src/javascript/components/authentication-provider/type-mapping-modal.tsx @@ -9,6 +9,7 @@ import { mappingType } from '../../models/authentication-provider'; import { BooleanMappingForm } from './boolean-mapping-form'; import { DateMappingForm } from './date-mapping-form'; import { StringMappingForm } from './string-mapping-form'; +import { FormInput } from '../form/form-input'; interface TypeMappingModalProps { model: string, @@ -38,6 +39,10 @@ export const TypeMappingModal = } onConfirm={toggleModal}> {model} > {field} ({t('app.admin.authentication.type_mapping_modal.TYPE_expected', { TYPE: t(`app.admin.authentication.type_mapping_modal.types.${type}`) })}) + {type === 'integer' && } {type === 'boolean' && } {type === 'date' && } diff --git a/app/frontend/src/javascript/models/authentication-provider.ts b/app/frontend/src/javascript/models/authentication-provider.ts index 40ed22c4a..6cfebd092 100644 --- a/app/frontend/src/javascript/models/authentication-provider.ts +++ b/app/frontend/src/javascript/models/authentication-provider.ts @@ -25,10 +25,12 @@ export interface AuthenticationProviderMapping { format: 'iso8601' | 'rfc2822' | 'rfc3339' | 'timestamp-s' | 'timestamp-ms', true_value: string, false_value: string, - mapping: { - from: string, - to: number|string - } + mapping: [ + { + from: string, + to: number|string + } + ] } } From cc1cf38d696af5cbf4f840b1cf65f426e34afe57 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 6 Jul 2022 12:59:45 +0200 Subject: [PATCH 2/5] (bug) OIDC scopes are not shown in the configuration form select --- CHANGELOG.md | 1 + .../authentication-provider/openid-connect-form.tsx | 8 ++++++++ .../src/javascript/components/form/form-multi-select.tsx | 8 +++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9a837e7b..d5e41299a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## next deploy - Fix a bug: Gender, Address and Birthday are not mapped properly from SSO (#365) +- Fix a bug: OIDC scopes are not shown in the configuration form select ## v5.4.10 2022 July 05 diff --git a/app/frontend/src/javascript/components/authentication-provider/openid-connect-form.tsx b/app/frontend/src/javascript/components/authentication-provider/openid-connect-form.tsx index 23b71169b..0aa816334 100644 --- a/app/frontend/src/javascript/components/authentication-provider/openid-connect-form.tsx +++ b/app/frontend/src/javascript/components/authentication-provider/openid-connect-form.tsx @@ -29,6 +29,8 @@ export const OpenidConnectForm = (false); const [scopesAvailable, setScopesAvailable] = useState(null); + // this is a workaround for https://github.com/JedWatson/react-select/issues/1879 + const [selectKey, setSelectKey] = useState(0); // when we have detected a discovery endpoint, we mark it as available useEffect(() => { @@ -38,6 +40,11 @@ export const OpenidConnectForm = { + setSelectKey(selectKey + 1); + }, [scopesAvailable]); + // when the component is mounted, we try to discover the discovery endpoint for the current configuration (if any) useEffect(() => { checkForDiscoveryEndpoint({ target: { value: currentFormValues?.issuer } } as React.ChangeEvent); @@ -125,6 +132,7 @@ export const OpenidConnectForm = } loadOptions={loadScopes} + selectKey={selectKey.toString()} creatable control={control} /> exten onChange?: (values: Array) => void, placeholder?: string, creatable?: boolean, + selectKey?: string, } // we should provide either an array of options or a function that returns a promise, but not both @@ -35,7 +36,7 @@ type selectOption = { value: TOptionValue, label: string, select?: * This component is a wrapper around react-select to use with react-hook-form. * It is a multi-select component. */ -export const FormMultiSelect = ({ id, label, tooltip, className, control, placeholder, options, valuesDefault, error, rules, disabled, onChange, formState, warning, loadOptions, creatable }: FormSelectProps) => { +export const FormMultiSelect = ({ id, label, tooltip, className, control, placeholder, options, valuesDefault, error, rules, disabled, onChange, formState, warning, loadOptions, creatable, selectKey }: FormSelectProps) => { const { t } = useTranslation('shared'); const [isDisabled, setIsDisabled] = React.useState(false); @@ -52,7 +53,7 @@ export const FormMultiSelect = { if (typeof loadOptions === 'function') { loadOptions('', options => { - setAllOptions(options); + setTimeout(() => setAllOptions(options), 1); }); } }, [loadOptions]); @@ -73,7 +74,7 @@ export const FormMultiSelect = ): Array> => { - return allOptions.filter(c => value?.includes(c.value)); + return allOptions?.filter(c => value?.includes(c.value)); }; /** @@ -119,6 +120,7 @@ export const FormMultiSelect = Date: Wed, 6 Jul 2022 13:16:09 +0200 Subject: [PATCH 3/5] (bug) OIDC scopes are not saved --- CHANGELOG.md | 1 + app/controllers/api/auth_providers_controller.rb | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5e41299a..5a141094f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix a bug: Gender, Address and Birthday are not mapped properly from SSO (#365) - Fix a bug: OIDC scopes are not shown in the configuration form select +- Fix a bug: OIDC scopes are not saved ## v5.4.10 2022 July 05 diff --git a/app/controllers/api/auth_providers_controller.rb b/app/controllers/api/auth_providers_controller.rb index b1cde1a6d..0db2c76f7 100644 --- a/app/controllers/api/auth_providers_controller.rb +++ b/app/controllers/api/auth_providers_controller.rb @@ -85,10 +85,10 @@ class API::AuthProvidersController < API::ApiController def provider_params if params['auth_provider']['providable_type'] == DatabaseProvider.name - params.require(:auth_provider).permit(:name, :providable_type, providable_attributes: [:id]) + params.require(:auth_provider).permit(:id, :name, :providable_type, providable_attributes: [:id]) elsif params['auth_provider']['providable_type'] == OAuth2Provider.name params.require(:auth_provider) - .permit(:name, :providable_type, + .permit(:id, :name, :providable_type, providable_attributes: %i[id base_url token_endpoint authorization_endpoint profile_url client_id client_secret scopes], auth_provider_mappings_attributes: [:id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type, @@ -96,10 +96,11 @@ class API::AuthProvidersController < API::ApiController mapping: %i[from to]]]) elsif params['auth_provider']['providable_type'] == OpenIdConnectProvider.name params.require(:auth_provider) - .permit(:name, :providable_type, - providable_attributes: %i[id issuer discovery client_auth_method scope prompt send_scope_to_token_endpoint - client__identifier client__secret client__authorization_endpoint client__token_endpoint - client__userinfo_endpoint client__jwks_uri client__end_session_endpoint profile_url], + .permit(:id, :name, :providable_type, + providable_attributes: [:id, :issuer, :discovery, :client_auth_method, :prompt, :send_scope_to_token_endpoint, + :client__identifier, :client__secret, :client__authorization_endpoint, :client__token_endpoint, + :client__userinfo_endpoint, :client__jwks_uri, :client__end_session_endpoint, :profile_url, + scope: []], auth_provider_mappings_attributes: [:id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type, :_destroy, transformation: [:type, :format, :true_value, :false_value, mapping: %i[from to]]]) From 9c72da8e6f7546217e24749155809276f87bb92a Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 6 Jul 2022 14:19:36 +0200 Subject: [PATCH 4/5] (bug) social networks icons not shown in firefox --- CHANGELOG.md | 1 + .../src/javascript/components/socials/edit-socials.tsx | 6 ++++-- .../src/javascript/components/socials/fab-socials.tsx | 8 +++++--- app/frontend/src/stylesheets/app.layout.scss | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a141094f..9ce56027a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## next deploy +- Fix a bug: social networks icons not shown in firefox - Fix a bug: Gender, Address and Birthday are not mapped properly from SSO (#365) - Fix a bug: OIDC scopes are not shown in the configuration form select - Fix a bug: OIDC scopes are not saved diff --git a/app/frontend/src/javascript/components/socials/edit-socials.tsx b/app/frontend/src/javascript/components/socials/edit-socials.tsx index 0164890fc..0c965040b 100644 --- a/app/frontend/src/javascript/components/socials/edit-socials.tsx +++ b/app/frontend/src/javascript/components/socials/edit-socials.tsx @@ -59,7 +59,9 @@ export const EditSocials = ({ register, setVal <>
{userNetworks.map((network, index) => - !selectedNetworks.includes(network) && selectNetwork(network)}> + !selectedNetworks.includes(network) && selectNetwork(network)} viewBox="0 0 24 24" > + + )}
{selectNetwork.length &&
@@ -79,7 +81,7 @@ export const EditSocials = ({ register, setVal label={network.name} disabled={disabled} placeholder={t('app.shared.edit_socials.url_placeholder')} - icon={} + icon={} addOn={} addOnAction={() => dispatch({ type: 'delete', payload: { network, field: `profile_attributes.${network.name}` } })} /> )} diff --git a/app/frontend/src/javascript/components/socials/fab-socials.tsx b/app/frontend/src/javascript/components/socials/fab-socials.tsx index 9db551532..f962bf100 100644 --- a/app/frontend/src/javascript/components/socials/fab-socials.tsx +++ b/app/frontend/src/javascript/components/socials/fab-socials.tsx @@ -85,7 +85,7 @@ export const FabSocials: React.FC = ({ show = false, onError, o {fabNetworks.map((network, index) => selectedNetworks.includes(network) && - + )}
@@ -95,7 +95,9 @@ export const FabSocials: React.FC = ({ show = false, onError, o
{fabNetworks.map((network, index) => !selectedNetworks.includes(network) && - selectNetwork(network)}> + selectNetwork(network)}> + + )}
{selectNetwork.length &&
@@ -114,7 +116,7 @@ export const FabSocials: React.FC = ({ show = false, onError, o defaultValue={network.url} label={network.name} placeholder={t('app.shared.fab_socials.url_placeholder')} - icon={} + icon={} addOn={} addOnAction={() => remove(network)} /> )} diff --git a/app/frontend/src/stylesheets/app.layout.scss b/app/frontend/src/stylesheets/app.layout.scss index 00ccea00d..938c4bfc7 100644 --- a/app/frontend/src/stylesheets/app.layout.scss +++ b/app/frontend/src/stylesheets/app.layout.scss @@ -581,7 +581,7 @@ body.container { border-radius: 3px; overflow: hidden; } - & > img { + & > svg { border: 1px solid var(--gray-soft-dark); background-color: var(--gray-soft-lightest); &:hover { opacity: 0.65; } @@ -589,7 +589,7 @@ body.container { & > a { transition: transform 200ms ease-in-out; &:hover { transform: translateY(-4px); } - img { + svg { max-width: 100%; height: inherit; } From 23702a6048bbf8a37d8e5c03e3a643aba5114cab Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 6 Jul 2022 14:37:34 +0200 Subject: [PATCH 5/5] Version 5.4.11 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ce56027a..75fb23d04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## next deploy +## v5.4.11 2022 July 06 + - Fix a bug: social networks icons not shown in firefox - Fix a bug: Gender, Address and Birthday are not mapped properly from SSO (#365) - Fix a bug: OIDC scopes are not shown in the configuration form select diff --git a/package.json b/package.json index cc3f309e9..e9f863b84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fab-manager", - "version": "5.4.10", + "version": "5.4.11", "description": "Fab-manager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.", "keywords": [ "fablab",