Fixes for Standalone OpenID Connect usage
This commit is contained in:
1 parent
9cc063430a
commit
d961a73b6c
28 files changed
+81117
-14405
No files matched your search
@@ -14,8 +14,8 @@
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"moment": "^2.22.2",
|
||||
"ohif-core": "^0.1.6",
|
||||
"ohif-viewer": "0.0.1",
|
||||
"ohif-core": "^0.1.7",
|
||||
"ohif-viewer": "0.0.5",
|
||||
"oidc-client": "^1.6.1",
|
||||
"prop-types": "^15.6.2",
|
||||
"query-string": "^6.2.0",
|
||||
|
||||
+22
-26
@@ -6,8 +6,7 @@ import { connect } from 'react-redux';
|
||||
import { ViewerbaseDragDropContext } from 'react-viewerbase';
|
||||
import routes from './routes/';
|
||||
import StudyListRouting from './studylist/StudyListRouting.js';
|
||||
//import CallbackPage from './CallbackPage.js';'
|
||||
import userManager from "./userManager.js";
|
||||
import CallbackPage from './CallbackPage.js';
|
||||
import './App.css';
|
||||
import './variables.css';
|
||||
import './theme-tide.css';
|
||||
@@ -24,14 +23,10 @@ function setContext(context) {
|
||||
});*/
|
||||
}
|
||||
|
||||
function LoadingUser() {
|
||||
return (<div>Loading user...</div>);
|
||||
}
|
||||
|
||||
class App extends Component {
|
||||
static propTypes = {
|
||||
history: PropTypes.object.isRequired,
|
||||
user: PropTypes.object
|
||||
user: PropTypes.object,
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -45,21 +40,30 @@ class App extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const user = this.props.user;
|
||||
const { user, userManager } = this.props;
|
||||
|
||||
/*if (!user || user.expired) {
|
||||
// TODO: redirect to OAuth page if necessary
|
||||
return <Switch>
|
||||
<Route path="/callback" component={CallbackPage} />
|
||||
<Route exact path='/login' component={() => {
|
||||
userManager.signinRedirect();
|
||||
}}/>
|
||||
<Route component={LoadingUser}/>
|
||||
</Switch>;
|
||||
}*/
|
||||
const userNotLoggedIn = userManager && (!user || user.expired);
|
||||
if (userNotLoggedIn) {
|
||||
return (
|
||||
<Switch>
|
||||
<Route exact path="/silent-refresh.html" onEnter={reload} />
|
||||
<Route exact path="/logout-redirect.html" onEnter={reload} />
|
||||
<Route path="/callback" render={
|
||||
() => <CallbackPage userManager={userManager}/>
|
||||
}/>
|
||||
<Route component={() => {
|
||||
userManager.signinRedirect();
|
||||
|
||||
return null;
|
||||
}}/>
|
||||
</Switch>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Switch>
|
||||
<Route exact path="/silent-refresh.html" onEnter={reload} />
|
||||
<Route exact path="/logout-redirect.html" onEnter={reload} />
|
||||
<Route
|
||||
exact
|
||||
path="/studylist"
|
||||
@@ -87,14 +91,6 @@ class App extends Component {
|
||||
path="/IHEInvokeImageDisplay"
|
||||
component={IHEInvokeImageDisplay}
|
||||
/>
|
||||
|
||||
<Route path="/silent-refresh.html" onEnter={reload} />
|
||||
<Route path="/logout-redirect.html" onEnter={reload} />
|
||||
<Route exact path='/login' component={() => {
|
||||
userManager.signinRedirect();
|
||||
}}
|
||||
/>
|
||||
{/*<Route path="/callback" component={CallbackPage} />*/}
|
||||
<Route render={() =>
|
||||
<div> Sorry, this page does not exist. </div>}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import React, { Component } from "react";
|
||||
import { CallbackComponent } from "redux-oidc";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
class CallbackPage extends Component {
|
||||
static propTypes = {
|
||||
userManager: PropTypes.object.isRequired,
|
||||
history: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<CallbackComponent
|
||||
userManager={this.props.userManager}
|
||||
successCallback={() => {
|
||||
this.props.history.push("/");
|
||||
}}
|
||||
errorCallback={error => {
|
||||
//this.props.history.push("/");
|
||||
throw new Error(error);
|
||||
}}
|
||||
>
|
||||
<div>Redirecting...</div>
|
||||
</CallbackComponent>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(CallbackPage);
|
||||
@@ -8,7 +8,8 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
return {
|
||||
studyInstanceUid,
|
||||
seriesInstanceUid
|
||||
seriesInstanceUid,
|
||||
displaySet
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ import PropTypes from 'prop-types';
|
||||
class ExampleViewportPlugin extends Component {
|
||||
static propTypes = {
|
||||
studyInstanceUid: PropTypes.string.isRequired,
|
||||
seriesInstanceUid: PropTypes.string.isRequired
|
||||
seriesInstanceUid: PropTypes.string.isRequired,
|
||||
displaySet: PropTypes.object
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
@@ -16,6 +17,7 @@ class ExampleViewportPlugin extends Component {
|
||||
return (<div className="ExampleViewportPlugin">
|
||||
<p>StudyInstanceUid: {this.props.studyInstanceUid}</p>
|
||||
<p>SeriesInstanceUid: {this.props.seriesInstanceUid}</p>
|
||||
{JSON.stringify(this.props.displaySet)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import ConnectedLayoutManager from './ConnectedLayoutManager.js';
|
||||
import './ViewerMain.css';
|
||||
|
||||
// Attempt to fix weird undefined dep issue
|
||||
cornerstoneTools.external.cornerstone = cornerstone;
|
||||
cornerstoneTools.external.cornerstoneMath = cornerstoneMath;
|
||||
|
||||
class ViewerMain extends Component {
|
||||
|
||||
@@ -1,27 +1,62 @@
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
import ReactDOM from 'react-dom';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import { Provider } from 'react-redux';
|
||||
import { createStore, combineReducers } from 'redux';
|
||||
import { loadUser, reducer as oidcReducer, OidcProvider} from 'redux-oidc';
|
||||
import { loadUser, reducer as oidcReducer, OidcProvider, createUserManager } from 'redux-oidc';
|
||||
import OHIF from 'ohif-core';
|
||||
import OHIFCornerstoneViewportPlugin from "./connectedComponents/OHIFCornerstoneViewportPlugin/OHIFCornerstoneViewportPlugin.js";
|
||||
import './config';
|
||||
import ui from './redux/ui.js';
|
||||
import App from './App.js';
|
||||
import userManager from './userManager.js';
|
||||
import ConnectedExampleViewportPlugin from './components/ConnectedExampleViewportPlugin.js';
|
||||
|
||||
import OHIFCornerstoneViewportPlugin from "./connectedComponents/OHIFCornerstoneViewportPlugin/OHIFCornerstoneViewportPlugin.js";
|
||||
//import ConnectedExampleViewportPlugin from './components/ConnectedExampleViewportPlugin.js';
|
||||
|
||||
const reducers = OHIF.redux.reducers;
|
||||
reducers.ui = ui;
|
||||
reducers.oidc = oidcReducer;
|
||||
|
||||
const Icons = '/icons.svg';
|
||||
|
||||
const combined = combineReducers(reducers)
|
||||
|
||||
const store = createStore(combined);
|
||||
loadUser(store, userManager);
|
||||
|
||||
// Note: Run your build like this:
|
||||
// REACT_APP_CONFIG=$(cat ../config-react/ccc.json) yarn start
|
||||
//
|
||||
// If you change the JSON config, you need to re-run the command!
|
||||
let config;
|
||||
if (process.env.REACT_APP_CONFIG) {
|
||||
config = JSON.parse(process.env.REACT_APP_CONFIG);
|
||||
}
|
||||
|
||||
let userManager;
|
||||
if (config.oidc) {
|
||||
const oidcClient = config.oidc[0];
|
||||
|
||||
const settings = {
|
||||
authority: oidcClient.authServerUrl,
|
||||
client_id: oidcClient.clientId,
|
||||
redirect_uri: oidcClient.authRedirectUri,
|
||||
silent_redirect_uri: '/silent-refresh.html',
|
||||
post_logout_redirect_uri: oidcClient.postLogoutRedirectUri,
|
||||
response_type: oidcClient.responseType,
|
||||
scope: 'email profile openid', // Note: Request must have scope 'openid' to be considered an OpenID Connect request
|
||||
automaticSilentRenew: true,
|
||||
revokeAccessTokenOnSignout: true,
|
||||
filterProtocolClaims: true,
|
||||
loadUserInfo: true,
|
||||
extraQueryParams: oidcClient.extraQueryParams
|
||||
};
|
||||
|
||||
userManager = createUserManager(settings);
|
||||
|
||||
loadUser(store, userManager);
|
||||
}
|
||||
|
||||
if (config.servers) {
|
||||
OHIF.utils.addServers(config.servers, store);
|
||||
}
|
||||
|
||||
|
||||
const defaultButtons = [
|
||||
{
|
||||
@@ -109,46 +144,28 @@ const pluginAction = OHIF.redux.actions.addPlugin({
|
||||
|
||||
store.dispatch(pluginAction);
|
||||
|
||||
const servers = {
|
||||
dicomWeb: [
|
||||
{
|
||||
"name": "DCM4CHEE",
|
||||
//"wadoUriRoot": "http://localhost:8080/dcm4chee-arc/aets/DCM4CHEE/wado",
|
||||
//"qidoRoot": "http://localhost:8080/dcm4chee-arc/aets/DCM4CHEE/rs",
|
||||
//"wadoRoot": "http://localhost:8080/dcm4chee-arc/aets/DCM4CHEE/rs",
|
||||
//"wadoUriRoot": "https://dcm4che.ohif.club/dcm4chee-arc/aets/DCM4CHEE/wado",
|
||||
//"qidoRoot": "https://dcm4che.ohif.club/dcm4chee-arc/aets/DCM4CHEE/rs",
|
||||
//"wadoRoot": "https://dcm4che.ohif.club/dcm4chee-arc/aets/DCM4CHEE/rs",
|
||||
"wadoUriRoot": "https://cancer.crowds-cure.org/dcm4chee-arc/aets/DCM4CHEE/wado",
|
||||
"qidoRoot": "https://cancer.crowds-cure.org/dcm4chee-arc/aets/DCM4CHEE/rs",
|
||||
"wadoRoot": "https://cancer.crowds-cure.org/dcm4chee-arc/aets/DCM4CHEE/rs",
|
||||
"qidoSupportsIncludeField": true,
|
||||
"imageRendering": "wadors",
|
||||
"thumbnailRendering": "wadors",
|
||||
"requestOptions": {
|
||||
"requestFromBrowser": true,
|
||||
"logRequests": true,
|
||||
"logResponses": false,
|
||||
"logTiming": true,
|
||||
//"auth": "admin:admin"
|
||||
//"auth": "cloud:healthcare"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
OHIF.utils.addServers(servers, store);
|
||||
|
||||
// TODO[react] Use a provider when the whole tree is React
|
||||
window.store = store;
|
||||
|
||||
ReactDOM.render(
|
||||
if (userManager) {
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<OidcProvider store={store} userManager={userManager}>
|
||||
<BrowserRouter>
|
||||
<App/>
|
||||
</BrowserRouter>
|
||||
</OidcProvider>
|
||||
<OidcProvider store={store} userManager={userManager}>
|
||||
<BrowserRouter>
|
||||
<App userManager={userManager}/>
|
||||
</BrowserRouter>
|
||||
</OidcProvider>
|
||||
</Provider>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
);
|
||||
} else {
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<BrowserRouter>
|
||||
<App/>
|
||||
</BrowserRouter>
|
||||
</Provider>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { createUserManager } from 'redux-oidc';
|
||||
|
||||
const oidcClient = {
|
||||
authServerUrl: 'https://cancer.crowds-cure.org/auth/realms/dcm4che',
|
||||
clientId: 'crowds-cure-cancer',
|
||||
authRedirectUri: '/callback',
|
||||
postLogoutRedirectUri: '/logout-redirect.html',
|
||||
responseType: 'id_token token',
|
||||
scope: 'email profile openid',
|
||||
revokeAccessTokenOnSignout: true,
|
||||
extraQueryParams: {
|
||||
kc_idp_hint: 'crowds-cure-cancer-auth0-oidc',
|
||||
client_id: 'crowds-cure-cancer'
|
||||
}
|
||||
};
|
||||
|
||||
const settings = {
|
||||
authority: oidcClient.authServerUrl,
|
||||
client_id: oidcClient.clientId,
|
||||
redirect_uri: oidcClient.authRedirectUri,
|
||||
silent_redirect_uri: '/silent-refresh.html',
|
||||
post_logout_redirect_uri: oidcClient.postLogoutRedirectUri,
|
||||
response_type: oidcClient.responseType,
|
||||
scope: 'email profile openid', // Note: Request must have scope 'openid' to be considered an OpenID Connect request
|
||||
automaticSilentRenew: true,
|
||||
revokeAccessTokenOnSignout: true,
|
||||
filterProtocolClaims: true,
|
||||
loadUserInfo: true,
|
||||
extraQueryParams: oidcClient.extraQueryParams
|
||||
};
|
||||
|
||||
const userManager = createUserManager(settings);
|
||||
|
||||
export default userManager;
|
||||
Reference in new issue
Block a user