Commit 993f3fd8 authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

enable authenticated session with tank

parent 99633cf9
...@@ -12,7 +12,7 @@ const oidcmgr = new oidc.UserManager({ ...@@ -12,7 +12,7 @@ const oidcmgr = new oidc.UserManager({
popup_redirect_uri: 'http://localhost:8080/oidc_callback_popupRenew.html', popup_redirect_uri: 'http://localhost:8080/oidc_callback_popupRenew.html',
accessTokenExpiringNotificationTime: process.env.VUE_APP_API_STEERING_OIDC_EXPIRE_NOTIFICATION, accessTokenExpiringNotificationTime: process.env.VUE_APP_API_STEERING_OIDC_EXPIRE_NOTIFICATION,
response_type: 'id_token token', response_type: 'id_token token',
scope: 'openid profile email', scope: 'openid profile email username aura_shows',
post_logout_redirect_uri: process.env.VUE_APP_API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT, post_logout_redirect_uri: process.env.VUE_APP_API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT,
loadUserInfo: true loadUserInfo: true
}) })
...@@ -28,6 +28,9 @@ const state = { ...@@ -28,6 +28,9 @@ const state = {
}, },
users: [], users: [],
userOIDC: null, userOIDC: null,
tank: {
session_token: '',
},
} }
const getters = { const getters = {
...@@ -69,6 +72,10 @@ const mutations = { ...@@ -69,6 +72,10 @@ const mutations = {
state.user.logged_in = false state.user.logged_in = false
}, },
setTankToken (state, token) {
state.tank.session_token = token
},
} }
const actions = { const actions = {
...@@ -146,6 +153,25 @@ const actions = { ...@@ -146,6 +153,25 @@ const actions = {
this.$log.debug(new Date(user.expires_at * 1000).toString()) this.$log.debug(new Date(user.expires_at * 1000).toString())
this.$log.debug(new Date(user.expires_at * 1000).toUTCString()) this.$log.debug(new Date(user.expires_at * 1000).toUTCString())
this.$log.debug(user.access_token) this.$log.debug(user.access_token)
let uri = process.env.VUE_APP_TANK + 'auth/session'
let payload = {
backend: "oidc",
arguments: {
access_token: user.access_token,
token_type: "Bearer"
}
}
axios.post(uri, payload , {
headers: {
'Authorization': 'Bearer ' + user.access_token,
}
}).then(response => {
this.$log.debug('tank session token:', response.data.token)
ctx.commit('setTankToken', response.data.token)
}).catch(error => {
handleApiError(this, error, 'could not get a session with tank')
})
} }
}).catch(err => { }).catch(err => {
this.$log.debug(err) this.$log.debug(err)
......
...@@ -63,7 +63,7 @@ const actions = { ...@@ -63,7 +63,7 @@ const actions = {
let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/files' let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/files'
axios.get(uri, { axios.get(uri, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token } headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token }
}).then(response => { }).then(response => {
// we don't have to check separately, if there are files, because tank // we don't have to check separately, if there are files, because tank
// always provides an empty array if there are no files (or even if there is no corresponding show) // always provides an empty array if there are no files (or even if there is no corresponding show)
...@@ -81,7 +81,7 @@ const actions = { ...@@ -81,7 +81,7 @@ const actions = {
let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/files/' + data.file + '/logs' let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/files/' + data.file + '/logs'
axios.get(uri, { axios.get(uri, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token } headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token }
}).then(response => { }).then(response => {
// we don't have to check separately, if there are files, because tank // we don't have to check separately, if there are files, because tank
// always provides an empty array if there are no files (or even if there is no corresponding show) // always provides an empty array if there are no files (or even if there is no corresponding show)
...@@ -102,7 +102,7 @@ const actions = { ...@@ -102,7 +102,7 @@ const actions = {
let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.show + '/imports' let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.show + '/imports'
axios.get(uri, { axios.get(uri, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token } headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token }
}).then(response => { }).then(response => {
if (data && typeof(data.callback) === 'function') { data.callback(response) } if (data && typeof(data.callback) === 'function') { data.callback(response) }
}).catch(error => { }).catch(error => {
...@@ -116,7 +116,7 @@ const actions = { ...@@ -116,7 +116,7 @@ const actions = {
// TODO: add mechanism to indicate the running patch request in the files table // TODO: add mechanism to indicate the running patch request in the files table
axios.patch(uri, data.metadata, { axios.patch(uri, data.metadata, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token } headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token }
}).then(response => { }).then(response => {
ctx.commit('setFileMeta', {id: data.file, metadata: response.data.metadata}) ctx.commit('setFileMeta', {id: data.file, metadata: response.data.metadata})
if (data && typeof(data.callback) === 'function') { data.callback() } if (data && typeof(data.callback) === 'function') { data.callback() }
...@@ -141,7 +141,7 @@ const actions = { ...@@ -141,7 +141,7 @@ const actions = {
} }
axios.post(uri, payload, { axios.post(uri, payload, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token } headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token }
}).then(response => { }).then(response => {
if (!data.addNewFileURI) { if (!data.addNewFileURI) {
ctx.dispatch('startUpload', { ctx.dispatch('startUpload', {
...@@ -165,7 +165,7 @@ const actions = { ...@@ -165,7 +165,7 @@ const actions = {
let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.show + '/files/' + data.file + '/import' let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.show + '/files/' + data.file + '/import'
axios.get(uri, { axios.get(uri, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token }, headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token },
params: {'wait-for': 'running'} params: {'wait-for': 'running'}
}).then( }).then(
ctx.dispatch('upload', data) ctx.dispatch('upload', data)
...@@ -201,7 +201,7 @@ const actions = { ...@@ -201,7 +201,7 @@ const actions = {
axios.put(uri, data.uploadSourceFile, { axios.put(uri, data.uploadSourceFile, {
withCredentials: true, withCredentials: true,
headers: { headers: {
'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token, 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token,
'Content-Type': 'application/octet-stream' 'Content-Type': 'application/octet-stream'
} }
}).then(() => { }).then(() => {
...@@ -231,7 +231,7 @@ const actions = { ...@@ -231,7 +231,7 @@ const actions = {
// TODO: add mechanism to indicate the running delete request in the files table // TODO: add mechanism to indicate the running delete request in the files table
axios.delete(uri, { axios.delete(uri, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token }, headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token },
}).then(() => { }).then(() => {
ctx.commit('deleteFile', data.file) ctx.commit('deleteFile', data.file)
if (data && typeof(data.callback) === 'function') { data.callback() } if (data && typeof(data.callback) === 'function') { data.callback() }
......
...@@ -47,7 +47,7 @@ const actions = { ...@@ -47,7 +47,7 @@ const actions = {
let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/playlists' let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/playlists'
axios.get(uri, { axios.get(uri, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token } headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token }
}).then(response => { }).then(response => {
// we don't have to check separately, if there are playlists, because tank // we don't have to check separately, if there are playlists, because tank
// always provides an empty array if there are no playlists (or even if there is no corresponding show) // always provides an empty array if there are no playlists (or even if there is no corresponding show)
...@@ -64,7 +64,7 @@ const actions = { ...@@ -64,7 +64,7 @@ const actions = {
let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/playlists' let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/playlists'
axios.post(uri, data.playlist, { axios.post(uri, data.playlist, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token } headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token }
}).then(response => { }).then(response => {
ctx.commit('addPlaylist', response.data) ctx.commit('addPlaylist', response.data)
if (data && typeof(data.callback) === 'function') { data.callback() } if (data && typeof(data.callback) === 'function') { data.callback() }
...@@ -78,7 +78,7 @@ const actions = { ...@@ -78,7 +78,7 @@ const actions = {
let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/playlists/' + data.id let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/playlists/' + data.id
axios.put(uri, data.playlist, { axios.put(uri, data.playlist, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token } headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token }
}).then(response => { }).then(response => {
ctx.commit('updatePlaylist', { ctx.commit('updatePlaylist', {
id: data.id, id: data.id,
...@@ -95,7 +95,7 @@ const actions = { ...@@ -95,7 +95,7 @@ const actions = {
let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/playlists/' + data.id let uri = process.env.VUE_APP_API_TANK + 'shows/' + data.slug + '/playlists/' + data.id
axios.delete(uri, { axios.delete(uri, {
withCredentials: true, withCredentials: true,
headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.user.access_token }, headers: { 'Authorization': 'Bearer ' + ctx.rootState.auth.tank.session_token },
}).then(() => { }).then(() => {
ctx.commit('deletePlaylist', data.id) ctx.commit('deletePlaylist', data.id)
if (data && typeof(data.callback) === 'function') { data.callback() } if (data && typeof(data.callback) === 'function') { data.callback() }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment