//
// SPDX-License-Identifier: AGPL-3.0
+$(document).on('ready', function() {
+ var db = new SessionDB()
+ db.migrateNonFederatedSessions()
+})
+
window.SearchResultsTable = {
maybeLoadMore: function(dom) {
var loader = this.loader
window.Search = {
oninit: function(vnode) {
- vnode.state.sessionDB = new SessionDB(vnode.attrs.remoteHosts)
+ vnode.state.sessionDB = new SessionDB()
vnode.state.searchEntered = m.stream()
vnode.state.searchActive = m.stream()
// When searchActive changes (e.g., when restoring state
var db = new SessionDB()
db.checkForNewToken()
db.fillMissingUUIDs()
+ db.migrateNonFederatedSessions()
})
window.SessionsTable = {
m('td', session.user.is_active ?
m('span.label.label-success', 'logged in') :
m('span.label.label-warning', 'inactive')),
- m('td', {title: session.baseURL}, uuidPrefix),
+ m('td', {title: session.baseURL}, [
+ m('a', {
+ href: db.workbenchBaseURL(session) + '?api_token=' + session.token
+ }, uuidPrefix),
+ ]),
m('td', session.user.username),
m('td', session.user.email),
m('td', session.isFromRails ? null : m('button.btn.btn-xs.btn-default', {
//
// SPDX-License-Identifier: AGPL-3.0
-window.SessionDB = function(rhosts) {
+window.SessionDB = function() {
var db = this
Object.assign(db, {
- remoteHosts: rhosts || [],
discoveryCache: {},
tokenUUIDCache: null,
loadFromLocalStorage: function() {
})
})
},
- login: function(baseURL) {
+ login: function(baseURL, fallbackLogin = true) {
// Initiate login procedure with given API base URL (e.g.,
// "http://api.example/").
//
db.save(user.owner_uuid.slice(0, 5), remoteSession)
})
})
- } else {
+ } else if (fallbackLogin) {
// Classic login
document.location = baseURL + 'login?return_to=' + encodeURIComponent(document.location.href.replace(/\?.*/, '')+'?baseURL='+encodeURIComponent(baseURL))
}
opts.headers.authorization = 'OAuth2 '+ session.token
return m.request(session.baseURL + path, opts)
},
+ // Check non-federated remote active sessions if they should be migrated to
+ // a salted token.
+ migrateNonFederatedSessions: function() {
+ var sessions = db.loadActive()
+ Object.keys(sessions).map(function(uuidPrefix) {
+ session = sessions[uuidPrefix]
+ if (!session.isFromRails && session.token && session.token.indexOf('v2/') < 0) {
+ // Only try the federated login
+ db.login(session.baseURL, false)
+ }
+ })
+ },
})
}
SPDX-License-Identifier: AGPL-3.0 -->
-<div data-mount-mithril="Search"
- data-remote-hosts="<%= Rails.configuration.remote_hosts %>">
+<div data-mount-mithril="Search">
</div>
# Link to use for Arvados Workflow Composer app, or false if not available.
#
composer_url: false
-
- # Multi site search federation feature:
- # * remote_hosts: List of API servers that allow logins from accounts on this
- # workbench's cluster.
- remote_hosts: []