Web: fix whitelabel tenants with no auth

In the case that no auth info is provided, we were relying on an
exception handler to catch errors and leave the 'info' field in
redux set to null.  We have such an exception handler for the
non-whitelable case, but we did not have one for whitelabeled
tenants.  Therefore, a whitelabel tenant with no auth info would
raise an exception which broke the app.

To correct this, add an exception handler to the whitelabel case
(configureAuthFromInfo).  Additionally, avoid raising that exception
in the first place (so that we always set auth_params), and then
update the login button accordingly.

Change-Id: I8023bdb0db085de7e5abc664ab1b2f67c0744be4
This commit is contained in:
James E. Blair 2021-12-02 07:21:33 -08:00
parent da9df89591
commit 58252504c7
2 changed files with 9 additions and 5 deletions

View File

@ -43,7 +43,7 @@ function createAuthParamsFromJson(json) {
}
const realm = auth_info.default_realm
const client_config = auth_info.realms[realm]
if (client_config.driver === 'OpenIDConnect') {
if (client_config && client_config.driver === 'OpenIDConnect') {
auth_params.client_id = client_config.client_id
auth_params.scope = client_config.scope
auth_params.authority = client_config.authority
@ -79,7 +79,11 @@ export const configureAuthFromTenant = (tenantName) => (dispatch) => {
}
export const configureAuthFromInfo = (info) => (dispatch) => {
dispatch(authConfigSuccess(
{info: info},
createAuthParamsFromJson({info: info})))
try {
dispatch(authConfigSuccess(
{info: info},
createAuthParamsFromJson({info: info})))
} catch(error) {
dispatch(authConfigFail(error))
}
}

View File

@ -264,7 +264,7 @@ class AuthContainer extends React.Component {
if (info.isFetching) {
return (<><div style={containerStyles}>Fetching auth info ...</div></>)
}
if (auth.info) {
if (auth.info && auth.info.default_realm) {
return this.renderButton(containerStyles)
} else {
return (<div style={containerStyles} title="Authentication disabled">-</div>)