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

Reduce polling to /user/refresh #2835

Merged
merged 7 commits into from
Aug 15, 2023
2 changes: 1 addition & 1 deletion js/components/analysisExecution/analysis-execution-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ define([
startPolling() {
this.pollId = this.PollService.add({
callback: silently => this.loadData({ silently }),
interval: 10000,
interval: config.pollInterval,
chrisknoll marked this conversation as resolved.
Show resolved Hide resolved
isSilentAfterFirstCall: true,
});
}
Expand Down
320 changes: 161 additions & 159 deletions js/config/app.js
Original file line number Diff line number Diff line change
@@ -1,167 +1,169 @@
define(function () {
var appConfig = {};
var appConfig = {};

// default configuration
appConfig.api = {
name: 'Local',
url: 'http://localhost:8080/WebAPI/'
};
appConfig.disableBrowserCheck = false; // browser check will happen by default
appConfig.enablePermissionManagement = true; // allow UI to assign read/write permissions to entities
appConfig.cacheSources = false;
appConfig.pollInterval = 60000;
appConfig.cohortComparisonResultsEnabled = false;
appConfig.userAuthenticationEnabled = false;
appConfig.enableSkipLogin = false; // automatically opens login window when user is not authenticated
appConfig.plpResultsEnabled = false;
appConfig.useExecutionEngine = false;
appConfig.viewProfileDates = false;
appConfig.enableCosts = false;
appConfig.supportUrl = "https://github.com/ohdsi/atlas/issues";
appConfig.supportMail = "[email protected]";
appConfig.feedbackContacts = 'For access or questions concerning the Atlas application please contact:';
appConfig.feedbackCustomHtmlTemplate = '';
appConfig.companyInfoCustomHtmlTemplate = '';
appConfig.showCompanyInfo = true;
appConfig.defaultLocale = "en";
appConfig.authProviders = [
{
"name": "Windows",
"url": "user/login/windows",
"ajax": true,
"icon": "fab fa-windows"
},
{
"name": "Kerberos",
"url": "user/login/kerberos",
"ajax": true,
"icon": "fab fa-windows"
},
{
"name": "OpenID",
"url": "user/login/openid",
"ajax": false,
"icon": "fab fa-openid"
},
{
"name": "Google",
"url": "user/oauth/google",
"ajax": false,
"icon": "fab fa-google"
},
{
"name": "Facebook",
"url": "user/oauth/facebook",
"ajax": false,
"icon": "fab fa-facebook-f"
},
{
"name": "Github",
"url": "user/oauth/github",
"ajax": false,
"icon": "fab fa-github"
},
{
"name": "DB",
"url": "user/login/db",
"ajax": true,
"icon": "fa fa-database",
"isUseCredentialsForm": true
},
{
"name": "LDAP",
"url": "user/login/ldap",
"ajax": true,
"icon": "fa fa-cubes",
"isUseCredentialsForm": true
},
{
"name": "SAML",
"url": "user/login/saml",
"ajax": false,
"icon": "fab fa-openid"
},
{
"name": "Active Directory LDAP",
"url": "user/login/ad",
"ajax": true,
"icon": "fa fa-cubes",
"isUseCredentialsForm": true
}
];
appConfig.strictXSSOptions = {
whiteList: [],
};
appConfig.xssOptions = {
"whiteList": {
"a": ["href", "class", "data-bind", "data-toggle", "aria-expanded"],
"button": ["class", "type", "data-toggle", "aria-expanded"],
"span": ["class", "data-bind"],
"i": ["class", "id", "aria-hidden"],
"div": ["class", "style", "id"],
"option": ["value"],
"input": ["type", "class"],
"ui": ["class"],
"path": ["d", "class"],
"br": "",
"li": ["class", "title"],
"ul": ["class"]
},
"stripIgnoreTag": true,
"stripIgnoreTagBody": ['script'],
};
appConfig.cemOptions = {
"evidenceLinkoutSources": ["medline_winnenburg", "splicer"],
"sourceRestEndpoints": {
"medline_winnenburg": "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&id={@ids}&retmode=json&tool=ohdsi_atlas&[email protected]",
},
"externalLinks": {
"medline_winnenburg": "https://www.ncbi.nlm.nih.gov/pubmed/{@id}",
"splicer": "https://dailymed.nlm.nih.gov/dailymed/drugInfo.cfm?setid={@id}"
},
};
appConfig.enableTermsAndConditions = true;
appConfig.webAPIRoot = appConfig.api.url;
// todo: move "userAuthenticationEnabled", "plpResultsEnabled", etc into the object
appConfig.features = {
locationDistance: false,
};
// default configuration
appConfig.api = {
name: 'Local',
url: 'http://localhost:8080/WebAPI/'
};
appConfig.disableBrowserCheck = false; // browser check will happen by default
appConfig.enablePermissionManagement = true; // allow UI to assign read/write permissions to entities
appConfig.cacheSources = false;
appConfig.pollInterval = 60000;
appConfig.cohortComparisonResultsEnabled = false;
appConfig.userAuthenticationEnabled = false;
appConfig.enableSkipLogin = false; // automatically opens login window when user is not authenticated
appConfig.plpResultsEnabled = false;
appConfig.useExecutionEngine = false;
appConfig.viewProfileDates = false;
appConfig.enableCosts = false;
appConfig.supportUrl = "https://github.com/ohdsi/atlas/issues";
appConfig.supportMail = "[email protected]";
appConfig.feedbackContacts = 'For access or questions concerning the Atlas application please contact:';
appConfig.feedbackCustomHtmlTemplate = '';
appConfig.companyInfoCustomHtmlTemplate = '';
appConfig.showCompanyInfo = true;
appConfig.defaultLocale = "en";
appConfig.authProviders = [
{
"name": "Windows",
"url": "user/login/windows",
"ajax": true,
"icon": "fab fa-windows"
},
{
"name": "Kerberos",
"url": "user/login/kerberos",
"ajax": true,
"icon": "fab fa-windows"
},
{
"name": "OpenID",
"url": "user/login/openid",
"ajax": false,
"icon": "fab fa-openid"
},
{
"name": "Google",
"url": "user/oauth/google",
"ajax": false,
"icon": "fab fa-google"
},
{
"name": "Facebook",
"url": "user/oauth/facebook",
"ajax": false,
"icon": "fab fa-facebook-f"
},
{
"name": "Github",
"url": "user/oauth/github",
"ajax": false,
"icon": "fab fa-github"
},
{
"name": "DB",
"url": "user/login/db",
"ajax": true,
"icon": "fa fa-database",
"isUseCredentialsForm": true
},
{
"name": "LDAP",
"url": "user/login/ldap",
"ajax": true,
"icon": "fa fa-cubes",
"isUseCredentialsForm": true
},
{
"name": "SAML",
"url": "user/login/saml",
"ajax": false,
"icon": "fab fa-openid"
},
{
"name": "Active Directory LDAP",
"url": "user/login/ad",
"ajax": true,
"icon": "fa fa-cubes",
"isUseCredentialsForm": true
}
];
appConfig.strictXSSOptions = {
whiteList: [],
};
appConfig.xssOptions = {
"whiteList": {
"a": ["href", "class", "data-bind", "data-toggle", "aria-expanded"],
"button": ["class", "type", "data-toggle", "aria-expanded"],
"span": ["class", "data-bind"],
"i": ["class", "id", "aria-hidden"],
"div": ["class", "style", "id"],
"option": ["value"],
"input": ["type", "class"],
"ui": ["class"],
"path": ["d", "class"],
"br": "",
"li": ["class", "title"],
"ul": ["class"]
},
"stripIgnoreTag": true,
"stripIgnoreTagBody": ['script'],
};
appConfig.cemOptions = {
"evidenceLinkoutSources": ["medline_winnenburg", "splicer"],
"sourceRestEndpoints": {
"medline_winnenburg": "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&id={@ids}&retmode=json&tool=ohdsi_atlas&[email protected]",
},
"externalLinks": {
"medline_winnenburg": "https://www.ncbi.nlm.nih.gov/pubmed/{@id}",
"splicer": "https://dailymed.nlm.nih.gov/dailymed/drugInfo.cfm?setid={@id}"
},
};
appConfig.enableTermsAndConditions = true;
appConfig.webAPIRoot = appConfig.api.url;
// todo: move "userAuthenticationEnabled", "plpResultsEnabled", etc into the object
appConfig.features = {
locationDistance: false,
};

appConfig.externalLibraries = [];
appConfig.externalLibraries = [];

appConfig.commonDataTableOptions = {
pageLength: {
ONLY_5: 5,
XS: 5,
S: 10,
M: 25,
L: 50,
},
lengthMenu: {
ONLY_5: [[5], ['5']],
XS: [
[5, 10],
['5', '10'],
],
S: [
[10, 15, 20, 25, 50, -1],
['10', '15', '20', '25', '50', 'All'],
],
M: [
[10, 25, 50, 100, -1],
['10', '25', '50', '100', 'All'],
],
L: [
[25, 50, 75, 100, -1],
['25', '50', '75', '100', 'All'],
],
}
};
appConfig.commonDataTableOptions = {
pageLength: {
ONLY_5: 5,
XS: 5,
S: 10,
M: 25,
L: 50,
},
lengthMenu: {
ONLY_5: [[5], ['5']],
XS: [
[5, 10],
['5', '10'],
],
S: [
[10, 15, 20, 25, 50, -1],
['10', '15', '20', '25', '50', 'All'],
],
M: [
[10, 25, 50, 100, -1],
['10', '25', '50', '100', 'All'],
],
L: [
[25, 50, 75, 100, -1],
['25', '50', '75', '100', 'All'],
],
}
};

appConfig.enablePersonCount = true;
appConfig.enablePersonCount = true;

// "Tagging" section is hidden by default
appConfig.enableTaggingSection = false;
// "Tagging" section is hidden by default
appConfig.enableTaggingSection = false;

return appConfig;
appConfig.refreshTokenThreshold = 1000 * 60 * 60 * 4; // refresh auth token if it will expire within 4 hours

return appConfig;
});
6 changes: 5 additions & 1 deletion js/pages/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define([
checkPermission() {
if (authApi.authProvider() === authApi.AUTH_PROVIDERS.IAP) {
return authApi.loadUserInfo();
} else if (appConfig.userAuthenticationEnabled && authApi.token() != null && authApi.tokenExpirationDate() > new Date()) {
} else if (appConfig.userAuthenticationEnabled && authApi.token() != null && this.timeToExpire() < appConfig.refreshTokenThreshold) {
chrisknoll marked this conversation as resolved.
Show resolved Hide resolved
return authApi.refreshToken();
}
return Promise.resolve();
Expand All @@ -25,6 +25,10 @@ define([
handler() {
throw new Exception('Handler should be overriden');
}

timeToExpire() {
return authApi.tokenExpirationDate() - new Date();
}
}

class AuthorizedRoute extends Route {
Expand Down
Loading
Loading