Adding user accounts to OHIF Viewer
Hi,
I would like to add a user accounts system to OHIF viewer similar to that implemented in Lesion Tracker, but I'm having trouble getting this set up. From what I can tell the primary relevant differences between these two applications are blocks of code in routes.js and config.js.
When I add the following to OHIF viwer client/routes.js as per Lesion Tracker:
import { Meteor } from 'meteor/meteor';
Router.onBeforeAction(function() {
// verifyEmail controls whether emailVerification template will be rendered or not
const publicSettings = Meteor.settings && Meteor.settings.public;
const verifyEmail = publicSettings && publicSettings.verifyEmail || false;
// Check if user is signed in or needs an email verification
if (!Meteor.userId() && !Meteor.loggingIn()) {
this.render('entrySignIn');
} else if (verifyEmail && Meteor.user().emails && !Meteor.user().emails[0].verified) {
this.render('emailVerification');
} else {
this.next();
}
}, {
except: ['entrySignIn', 'entrySignUp', 'forgotPassword', 'resetPassword', 'emailVerification']
});
And the following to OHIFViewer/client/config.js:
import { Accounts } from 'meteor/accounts-base';
cornerstoneWADOImageLoader.configure({
beforeSend: function(xhr) {
const userId = Meteor.userId();
const loginToken = Accounts._storedLoginToken();
if (userId && loginToken) {
xhr.setRequestHeader("x-user-id", userId);
xhr.setRequestHeader("x-auth-token", loginToken);
}
}
});
I get the following output when I load localhost:3000:
Couldn't find a template named "entrySignIn" or "entrySignIn". Are you sure you defined it?
Am I on the right track? Complete meteor/javascript beginner here, any help would be greatly appreciated.
Best wishes Heath
Hi Heath - we are actually trying now to decide the best way to do this as well. It's not clear if we will use what LesionTracker has, or something else (like https://www.keycloak.org/). At the moment, I'm thinking keycloak looks like a nice option, but it will take some work to integrate.
- Rob
Yes, keycloak looks promising - dcm4chee uses it for the docker compose installations.
I also wonder if anyone has tried setting up an oauth proxy like this one allowing login with github/google/etc accounts.
How OHIF is based on XNAT?
OHIF doesn't work directly with XNAT.
We're getting ready to formally announce version 2 of the OHIF Viewer. After the announcement, version 1 issues will receive lower priority support. As this issue is a bit stale, I'm going to close it for now.
For what it's worth, version 2 makes all of this a little easier with out of the box support for OpenID-Connect via it's oidc configuration key: https://github.com/OHIF/Viewers/blob/master/public/config/docker_openresty-orthanc-keycloak.js#L27-L41
You can find an advanced example that uses Keycloak to provide some advanced features from the get-go: https://docs.ohif.org/deployment/recipes/user-account-control.html
If there is a particular scenario/recipe that you would find helpful, please don't hesitate to create a new issue.