[ARVADOS] updated: 1.1.2-145-g1b350dc
Git user
git at public.curoverse.com
Mon Feb 5 16:33:42 EST 2018
Summary of changes:
.../app/assets/javascripts/components/sessions.js | 4 +-
.../app/assets/javascripts/models/session_db.js | 75 +++++++++++++++-------
2 files changed, 55 insertions(+), 24 deletions(-)
via 1b350dc780c38740819ff0dbb495557742aabd1a (commit)
via fa9f5461910fede92df37bfce1e46514a59861eb (commit)
from 0312a5e5aa076fa3458dd83a33e72663d23bb1ba (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 1b350dc780c38740819ff0dbb495557742aabd1a
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Mon Feb 5 18:27:07 2018 -0300
11454: Remotes listed on remoteHosts show "enable/disable" action button
instead of "Log in/Log out".
When a listed remote rejects the salted token, the session shows as
disabled.
When a user entered (ie: not listed) remote rejects the salted token,
classic login is attempted.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/apps/workbench/app/assets/javascripts/components/sessions.js b/apps/workbench/app/assets/javascripts/components/sessions.js
index 12015b0..231db9b 100644
--- a/apps/workbench/app/assets/javascripts/components/sessions.js
+++ b/apps/workbench/app/assets/javascripts/components/sessions.js
@@ -53,7 +53,7 @@ window.SessionsTable = {
m('td', session.isFromRails ? null : m('button.btn.btn-xs.btn-default', {
uuidPrefix: uuidPrefix,
onclick: m.withAttr('uuidPrefix', db.logout),
- }, 'Log out ', m('span.glyphicon.glyphicon-log-out'))),
+ }, session.listedHost ? 'Disable ':'Log out ', m('span.glyphicon.glyphicon-log-out'))),
] : [
m('td', m('span.label.label-default', 'logged out')),
m('td', {title: session.baseURL}, uuidPrefix),
@@ -62,7 +62,7 @@ window.SessionsTable = {
m('td', m('a.btn.btn-xs.btn-primary', {
uuidPrefix: uuidPrefix,
onclick: db.login.bind(db, session.baseURL),
- }, 'Log in ', m('span.glyphicon.glyphicon-log-in'))),
+ }, session.listedHost ? 'Enable ':'Log in ', m('span.glyphicon.glyphicon-log-in'))),
],
m('td', session.isFromRails ? null : m('button.btn.btn-xs.btn-default', {
uuidPrefix: uuidPrefix,
diff --git a/apps/workbench/app/assets/javascripts/models/session_db.js b/apps/workbench/app/assets/javascripts/models/session_db.js
index 9bbf53b..f9e17b2 100644
--- a/apps/workbench/app/assets/javascripts/models/session_db.js
+++ b/apps/workbench/app/assets/javascripts/models/session_db.js
@@ -87,37 +87,54 @@ window.SessionDB = function() {
var session = db.loadLocal()
var uuidPrefix = session.user.owner_uuid.slice(0, 5)
var apiHostname = new URL(session.baseURL).hostname
- m.request(baseURL+'discovery/v1/apis/arvados/v1/rest').then(function(dd) {
- if (uuidPrefix in dd.remoteHosts ||
- (dd.remoteHostsViaDNS && apiHostname.indexOf('arvadosapi.com') >= 0)) {
- // Federated identity login via salted token
- db.saltedToken(dd.uuidPrefix).then(function(token) {
- m.request(baseURL+'arvados/v1/users/current', {
- headers: {
- authorization: 'Bearer '+token,
- },
- }).then(function(user) {
- var remoteSession = {
- user: user,
- baseURL: baseURL,
- token: token
- }
- db.save(dd.uuidPrefix, remoteSession)
- }).catch(function(e) {
- // If the remote system is configured to allow federated
- // logins from this cluster, but rejected the salted
- // token, save as a logged out session anyways.
- db.save(dd.uuidPrefix, {baseURL: baseURL})
+ m.request(session.baseURL+'discovery/v1/apis/arvados/v1/rest').then(function(localDD) {
+ m.request(baseURL+'discovery/v1/apis/arvados/v1/rest').then(function(dd) {
+ if (uuidPrefix in dd.remoteHosts ||
+ (dd.remoteHostsViaDNS && apiHostname.indexOf('arvadosapi.com') >= 0)) {
+ // Federated identity login via salted token
+ db.saltedToken(dd.uuidPrefix).then(function(token) {
+ m.request(baseURL+'arvados/v1/users/current', {
+ headers: {
+ authorization: 'Bearer '+token,
+ },
+ }).then(function(user) {
+ // Federated login successful.
+ var remoteSession = {
+ user: user,
+ baseURL: baseURL,
+ token: token,
+ listedHost: (dd.uuidPrefix in localDD.remoteHosts),
+ }
+ db.save(dd.uuidPrefix, remoteSession)
+ }).catch(function(e) {
+ if (dd.uuidPrefix in localDD.remoteHosts) {
+ // If the remote system is configured to allow federated
+ // logins from this cluster, but rejected the salted
+ // token, save as a logged out session anyways.
+ var remoteSession = {
+ baseURL: baseURL,
+ listedHost: true,
+ }
+ db.save(dd.uuidPrefix, remoteSession)
+ } else if (fallbackLogin) {
+ // Remote cluster not listed as a remote host and rejecting
+ // the salted token, try classic login.
+ db.loginClassic(baseURL)
+ }
+ })
})
- })
- } else if (fallbackLogin) {
- // Classic login will be used when the remote system doesn't list this
- // cluster as part of the federation.
- document.location = baseURL + 'login?return_to=' + encodeURIComponent(document.location.href.replace(/\?.*/, '')+'?baseURL='+encodeURIComponent(baseURL))
- }
+ } else if (fallbackLogin) {
+ // Classic login will be used when the remote system doesn't list this
+ // cluster as part of the federation.
+ db.loginClassic(baseURL)
+ }
+ })
})
return false
},
+ loginClassic: function(baseURL) {
+ document.location = baseURL + 'login?return_to=' + encodeURIComponent(document.location.href.replace(/\?.*/, '')+'?baseURL='+encodeURIComponent(baseURL))
+ },
logout: function(k) {
// Forget the token, but leave the other info in the db so
// the user can log in again without providing the login
commit fa9f5461910fede92df37bfce1e46514a59861eb
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Mon Feb 5 16:33:40 2018 -0300
11454: When adding a uuid prefix on the add session box, append
'.arvadosapi.com' before trying to get the API server url.
When a salted token is rejected, save the the session as logged out.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/apps/workbench/app/assets/javascripts/models/session_db.js b/apps/workbench/app/assets/javascripts/models/session_db.js
index 0c3a081..9bbf53b 100644
--- a/apps/workbench/app/assets/javascripts/models/session_db.js
+++ b/apps/workbench/app/assets/javascripts/models/session_db.js
@@ -24,7 +24,7 @@ window.SessionDB = function() {
loadActive: function() {
var sessions = db.loadAll()
Object.keys(sessions).forEach(function(key) {
- if (!sessions[key].token || !sessions[key].user.is_active)
+ if (!sessions[key].token || (sessions[key].user && !sessions[key].user.is_active))
delete sessions[key]
})
return sessions
@@ -59,6 +59,8 @@ window.SessionDB = function() {
// for the corresponding API server's base URL. Typical
// use:
// sessionDB.findAPI('https://workbench.example/foo').then(sessionDB.login)
+ if (url.length === 5 && url.indexOf('.') < 0)
+ url += '.arvadosapi.com'
if (url.indexOf('://') < 0)
url = 'https://' + url
url = new URL(url)
@@ -100,11 +102,17 @@ window.SessionDB = function() {
baseURL: baseURL,
token: token
}
- db.save(user.owner_uuid.slice(0, 5), remoteSession)
+ db.save(dd.uuidPrefix, remoteSession)
+ }).catch(function(e) {
+ // If the remote system is configured to allow federated
+ // logins from this cluster, but rejected the salted
+ // token, save as a logged out session anyways.
+ db.save(dd.uuidPrefix, {baseURL: baseURL})
})
})
} else if (fallbackLogin) {
- // Classic login
+ // Classic login will be used when the remote system doesn't list this
+ // cluster as part of the federation.
document.location = baseURL + 'login?return_to=' + encodeURIComponent(document.location.href.replace(/\?.*/, '')+'?baseURL='+encodeURIComponent(baseURL))
}
})
@@ -253,6 +261,12 @@ window.SessionDB = function() {
})
})
},
+ // If the current logged in account is from a remote federated cluster,
+ // redirect the user to their home cluster's workbench.
+ // This is meant to avoid confusion when the user clicks through a search
+ // result on the home cluster's multi site search page, landing on the
+ // remote workbench and later trying to do another search by just clicking
+ // on the multi site search button instead of going back with the browser.
autoRedirectToHomeCluster: function(path = '/') {
var session = db.loadLocal()
var userUUIDPrefix = session.user.uuid.slice(0, 5)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list