Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STCOR-868 backport idle-session timeout and fixed-length-session timeout #1507

Merged
merged 17 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
## [10.1.1](https://github.com/folio-org/stripes-core/tree/v10.1.1) (2024-03-25)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.1.0...v10.1.1)

* Utilize the `tenant` procured through the SSO login process. Refs STCOR-769.
* Use keycloak URLs in place of users-bl for tenant-switch. Refs US1153537.
* Idle-session timeout and "Keep working?" modal. Refs STCOR-776.
* Always retrieve `clientId` and `tenant` values from `config.tenantOptions` in stripes.config.js. Retires `okapi.tenant`, `okapi.clientId`, and `config.isSingleTenant`. Refs STCOR-787.
* Correctly evaluate `stripes.okapi` before rendering `<RootWithIntl>`. Refs STCOR-864.
* `/users-keycloak/_self` is an authentication request. Refs STCOR-866.
* Terminate the session when the fixed-length session expires. Refs STCOR-862.

## [10.1.0](https://github.com/folio-org/stripes-core/tree/v10.1.0) (2024-03-12)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.0.0...v10.1.0)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"localforage": "^1.5.6",
"lodash": "^4.17.21",
"moment-timezone": "^0.5.14",
"ms": "^2.1.3",
"prop-types": "^15.5.10",
"query-string": "^7.1.2",
"react-cookie": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class StripesCore extends Component {
const parsedTenant = storedTenant ? JSON.parse(storedTenant) : undefined;

const okapi = (typeof okapiConfig === 'object' && Object.keys(okapiConfig).length > 0)
? { ...okapiConfig, tenant: parsedTenant?.tenantName || okapiConfig.tenant, clientId: parsedTenant?.clientId || okapiConfig.clientId } : { withoutOkapi: true };
? { ...okapiConfig, tenant: parsedTenant?.tenantName || okapiConfig.tenant, clientId: parsedTenant?.clientId } : { withoutOkapi: true };

const initialState = merge({}, { okapi }, props.initialState);

Expand Down
305 changes: 149 additions & 156 deletions src/RootWithIntl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react';
import { useState } from 'react';
import PropTypes from 'prop-types';
import {
Router,
Switch,
Redirect as InternalRedirect

Check warning on line 6 in src/RootWithIntl.js

View workflow job for this annotation

GitHub Actions / build-npm

'InternalRedirect' is defined but never used. Allowed unused vars must match /React/u

Check warning on line 6 in src/RootWithIntl.js

View workflow job for this annotation

GitHub Actions / build-npm

'InternalRedirect' is defined but never used. Allowed unused vars must match /React/u
} from 'react-router-dom';

import { Provider } from 'react-redux';
import { CookiesProvider } from 'react-cookie';

Expand All @@ -29,175 +28,169 @@
Settings,
HandlerManager,
TitleManager,
Logout,
LogoutTimeout,
OverlayContainer,
CreateResetPassword,
CheckEmailStatusPage,
ForgotPasswordCtrl,
ForgotUserNameCtrl,
AppCtxMenuProvider,
SessionEventContainer,
} from './components';
import StaleBundleWarning from './components/StaleBundleWarning';
import { StripesContext } from './StripesContext';
import { CalloutContext } from './CalloutContext';
import AuthnLogin from './components/AuthnLogin';

export const renderLogoutComponent = () => {
return <InternalRedirect to="/" />;
};
const RootWithIntl = ({ stripes, token = '', isAuthenticated = false, disableAuth, history = {} }) => {
const connect = connectFor('@folio/core', stripes.epics, stripes.logger);
const connectedStripes = stripes.clone({ connect });

class RootWithIntl extends React.Component {
static propTypes = {
stripes: PropTypes.shape({
clone: PropTypes.func.isRequired,
config: PropTypes.object,
epics: PropTypes.object,
logger: PropTypes.object.isRequired,
okapi: PropTypes.object.isRequired,
store: PropTypes.object.isRequired
}).isRequired,
token: PropTypes.string,
isAuthenticated: PropTypes.bool,
disableAuth: PropTypes.bool.isRequired,
history: PropTypes.shape({}),
const [callout, setCallout] = useState(null);
const setCalloutDomRef = (ref) => {
setCallout(ref);
};

static defaultProps = {
token: '',
isAuthenticated: false,
history: {},
};

state = { callout: null };

setCalloutRef = (ref) => {
this.setState({
callout: ref,
});
}

render() {
const {
token,
isAuthenticated,
disableAuth,
history,
} = this.props;

const connect = connectFor('@folio/core', this.props.stripes.epics, this.props.stripes.logger);
const stripes = this.props.stripes.clone({ connect });
return (
<StripesContext.Provider value={connectedStripes}>
<CalloutContext.Provider value={callout}>
<ModuleTranslator>
<TitleManager>
<HotKeys
keyMap={connectedStripes.bindings}
noWrapper
>
<Provider store={connectedStripes.store}>
<Router history={history}>
{ isAuthenticated || token || disableAuth ?
<>
<MainContainer>
<AppCtxMenuProvider>
<MainNav stripes={connectedStripes} />
{typeof connectedStripes?.config?.staleBundleWarning === 'object' && <StaleBundleWarning />}
<HandlerManager
event={events.LOGIN}
stripes={connectedStripes}
/>
{ (typeof connectedStripes.okapi !== 'object' || connectedStripes.discovery.isFinished) && (
<ModuleContainer id="content">
<OverlayContainer />
{connectedStripes.config.useSecureTokens && <SessionEventContainer history={history} />}
<Switch>
<TitledRoute
name="home"
path="/"
key="root"
exact
component={<Front stripes={connectedStripes} />}
/>
<TitledRoute
name="ssoRedirect"
path="/sso-landing"
key="sso-landing"
component={<SSORedirect stripes={connectedStripes} />}
/>
<TitledRoute
name="oidcRedirect"
path="/oidc-landing"
key="oidc-landing"
component={<OIDCRedirect stripes={stripes} />}
/>
<TitledRoute
name="logoutTimeout"
path="/logout-timeout"
component={<LogoutTimeout />}
/>
<TitledRoute
name="settings"
path="/settings"
component={<Settings stripes={connectedStripes} />}
/>
<TitledRoute
name="logout"
path="/logout"
component={<Logout history={history} />}
/>
<ModuleRoutes stripes={connectedStripes} />
</Switch>
</ModuleContainer>
)}
</AppCtxMenuProvider>
</MainContainer>
<Callout ref={setCalloutDomRef} />
</> :
<Switch>
{/* The ? after :token makes that part of the path optional, so that token may optionally
be passed in via URL parameter to avoid length restrictions */}
<TitledRoute
name="CreateResetPassword"
path="/reset-password/:token?"
component={<CreateResetPassword stripes={connectedStripes} />}
/>
<TitledRoute
name="ssoLanding"
exact
path="/sso-landing"
component={<CookiesProvider><SSOLanding stripes={connectedStripes} /></CookiesProvider>}
key="sso-landing"
/>
<TitledRoute
name="oidcLanding"
exact
path="/oidc-landing"
component={<CookiesProvider><OIDCLanding stripes={stripes} /></CookiesProvider>}
key="oidc-landing"
/>
<TitledRoute
name="forgotPassword"
path="/forgot-password"
component={<ForgotPasswordCtrl stripes={connectedStripes} />}
/>
<TitledRoute
name="forgotUsername"
path="/forgot-username"
component={<ForgotUserNameCtrl stripes={connectedStripes} />}
/>
<TitledRoute
name="checkEmail"
path="/check-email"
component={<CheckEmailStatusPage />}
/>
<TitledRoute
name="logoutTimeout"
path="/logout-timeout"
component={<LogoutTimeout />}
/>
<TitledRoute
name="login"
component={<AuthnLogin stripes={connectedStripes} />}
/>
</Switch>
}
</Router>
</Provider>
</HotKeys>
</TitleManager>
</ModuleTranslator>
</CalloutContext.Provider>
</StripesContext.Provider>
);
};

return (
<StripesContext.Provider value={stripes}>
<CalloutContext.Provider value={this.state.callout}>
<ModuleTranslator>
<TitleManager>
<HotKeys
keyMap={stripes.bindings}
noWrapper
>
<Provider store={stripes.store}>
<Router history={history}>
{ isAuthenticated || token || disableAuth ?
<>
<MainContainer>
<AppCtxMenuProvider>
<MainNav stripes={stripes} />
{typeof stripes?.config?.staleBundleWarning === 'object' && <StaleBundleWarning />}
<HandlerManager
event={events.LOGIN}
stripes={stripes}
/>
{ (stripes.okapi !== 'object' || stripes.discovery.isFinished) && (
<ModuleContainer id="content">
<OverlayContainer />
<Switch>
<TitledRoute
name="home"
path="/"
key="root"
exact
component={<Front stripes={stripes} />}
/>
<TitledRoute
name="ssoRedirect"
path="/sso-landing"
key="sso-landing"
component={<SSORedirect stripes={stripes} />}
/>
<TitledRoute
name="oidcRedirect"
path="/oidc-landing"
key="oidc-landing"
component={<OIDCRedirect stripes={stripes} />}
/>
<TitledRoute
name="settings"
path="/settings"
component={<Settings stripes={stripes} />}
/>
<ModuleRoutes stripes={stripes} />
</Switch>
</ModuleContainer>
)}
</AppCtxMenuProvider>
</MainContainer>
<Callout ref={this.setCalloutRef} />
</> :
<Switch>
<TitledRoute
name="CreateResetPassword"
path="/reset-password/:token?"
component={<CreateResetPassword stripes={stripes} />}
/>
<TitledRoute
name="ssoLanding"
exact
path="/sso-landing"
component={<CookiesProvider><SSOLanding stripes={stripes} /></CookiesProvider>}
key="sso-landing"
/>
<TitledRoute
name="oidcLanding"
exact
path="/oidc-landing"
component={<CookiesProvider><OIDCLanding stripes={stripes} /></CookiesProvider>}
key="oidc-landing"
/>
<TitledRoute
name="forgotPassword"
path="/forgot-password"
component={<ForgotPasswordCtrl stripes={stripes} />}
/>
<TitledRoute
name="forgotUsername"
path="/forgot-username"
component={<ForgotUserNameCtrl stripes={stripes} />}
/>
<TitledRoute
name="checkEmail"
path="/check-email"
component={<CheckEmailStatusPage />}
/>
<TitledRoute
name="logout"
path="/logout"
component={renderLogoutComponent()}
/>
<TitledRoute
name="login"
component={<AuthnLogin stripes={this.props.stripes} />}
/>
</Switch>
}
</Router>
</Provider>
</HotKeys>
</TitleManager>
</ModuleTranslator>
</CalloutContext.Provider>
</StripesContext.Provider>
);
}
}
RootWithIntl.propTypes = {
stripes: PropTypes.shape({
clone: PropTypes.func.isRequired,
config: PropTypes.object,
epics: PropTypes.object,
logger: PropTypes.object.isRequired,
okapi: PropTypes.object.isRequired,
store: PropTypes.object.isRequired
}).isRequired,
token: PropTypes.string,
isAuthenticated: PropTypes.bool,
disableAuth: PropTypes.bool.isRequired,
history: PropTypes.shape({}),
};

export default RootWithIntl;
Loading
Loading