Skip to content

Commit

Permalink
fix: trim sso URL fields (#7301) (#7303)
Browse files Browse the repository at this point in the history
What the title says. There are input values that are whitespace
sensitive, so this will trim clientId and entity field, preventing the
form from sending leading or trailing whitespace. Will make a PR on
enterprise as well to trim on the backend as well.
  • Loading branch information
chriswk authored Jun 6, 2024
1 parent e23c28a commit f245e55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions frontend/src/component/admin/auth/OidcAuth/OidcAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export const OidcAuth = () => {
setValue(event.target.name, event.target.value);
};

const trimAndUpdateField = (event: React.ChangeEvent<HTMLInputElement>) => {
setValue(event.target.name, event.target.value.trim());
};

const updateEnabled = () => {
setData({ ...data, enabled: !data.enabled });
};
Expand Down Expand Up @@ -146,7 +150,7 @@ export const OidcAuth = () => {
</Grid>
<Grid item md={6}>
<TextField
onChange={updateField}
onChange={trimAndUpdateField}
label='Discover URL'
name='discoverUrl'
value={data.discoverUrl}
Expand All @@ -164,7 +168,7 @@ export const OidcAuth = () => {
</Grid>
<Grid item md={6}>
<TextField
onChange={updateField}
onChange={trimAndUpdateField}
label='Client ID'
name='clientId'
value={data.clientId}
Expand All @@ -185,7 +189,7 @@ export const OidcAuth = () => {
</Grid>
<Grid item md={6}>
<TextField
onChange={updateField}
onChange={trimAndUpdateField}
label='Client Secret'
name='secret'
value={data.secret}
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/component/admin/auth/SamlAuth/SamlAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export const SamlAuth = () => {
setValue(event.target.name, event.target.value);
};

const trimAndUpdateField = (event: React.ChangeEvent<HTMLInputElement>) => {
setValue(event.target.name, event.target.value.trim());
};

const updateEnabled = () => {
setData({ ...data, enabled: !data.enabled });
};
Expand Down Expand Up @@ -137,7 +141,7 @@ export const SamlAuth = () => {
</Grid>
<Grid item md={6}>
<TextField
onChange={updateField}
onChange={trimAndUpdateField}
label='Entity ID'
name='entityId'
value={data.entityId}
Expand All @@ -159,7 +163,7 @@ export const SamlAuth = () => {
</Grid>
<Grid item md={6}>
<TextField
onChange={updateField}
onChange={trimAndUpdateField}
label='Single Sign-On URL'
name='signOnUrl'
value={data.signOnUrl}
Expand Down Expand Up @@ -213,7 +217,7 @@ export const SamlAuth = () => {
</Grid>
<Grid item md={6}>
<TextField
onChange={updateField}
onChange={trimAndUpdateField}
label='Single Sign-out URL'
name='signOutUrl'
value={data.signOutUrl}
Expand Down

0 comments on commit f245e55

Please sign in to comment.