Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
AURA
dashboard
Commits
993f3fd8
Commit
993f3fd8
authored
Jun 30, 2020
by
jackie / Andrea Ida Malkah Klaura
Browse files
enable authenticated session with tank
parent
99633cf9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/store/modules/auth.js
View file @
993f3fd8
...
...
@@ -12,7 +12,7 @@ const oidcmgr = new oidc.UserManager({
popup_redirect_uri
:
'
http://localhost:8080/oidc_callback_popupRenew.html
'
,
accessTokenExpiringNotificationTime
:
process
.
env
.
VUE_APP_API_STEERING_OIDC_EXPIRE_NOTIFICATION
,
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
,
loadUserInfo
:
true
})
...
...
@@ -28,6 +28,9 @@ const state = {
},
users
:
[],
userOIDC
:
null
,
tank
:
{
session_token
:
''
,
},
}
const
getters
=
{
...
...
@@ -69,6 +72,10 @@ const mutations = {
state
.
user
.
logged_in
=
false
},
setTankToken
(
state
,
token
)
{
state
.
tank
.
session_token
=
token
},
}
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
).
toUTCString
())
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
=>
{
this
.
$log
.
debug
(
err
)
...
...
src/store/modules/files.js
View file @
993f3fd8
...
...
@@ -63,7 +63,7 @@ const actions = {
let
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
data
.
slug
+
'
/files
'
axios
.
get
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
}
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
}
}).
then
(
response
=>
{
// 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)
...
...
@@ -81,7 +81,7 @@ const actions = {
let
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
data
.
slug
+
'
/files/
'
+
data
.
file
+
'
/logs
'
axios
.
get
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
}
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
}
}).
then
(
response
=>
{
// 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)
...
...
@@ -102,7 +102,7 @@ const actions = {
let
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
data
.
show
+
'
/imports
'
axios
.
get
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
}
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
}
}).
then
(
response
=>
{
if
(
data
&&
typeof
(
data
.
callback
)
===
'
function
'
)
{
data
.
callback
(
response
)
}
}).
catch
(
error
=>
{
...
...
@@ -116,7 +116,7 @@ const actions = {
// TODO: add mechanism to indicate the running patch request in the files table
axios
.
patch
(
uri
,
data
.
metadata
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
}
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
}
}).
then
(
response
=>
{
ctx
.
commit
(
'
setFileMeta
'
,
{
id
:
data
.
file
,
metadata
:
response
.
data
.
metadata
})
if
(
data
&&
typeof
(
data
.
callback
)
===
'
function
'
)
{
data
.
callback
()
}
...
...
@@ -141,7 +141,7 @@ const actions = {
}
axios
.
post
(
uri
,
payload
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
}
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
}
}).
then
(
response
=>
{
if
(
!
data
.
addNewFileURI
)
{
ctx
.
dispatch
(
'
startUpload
'
,
{
...
...
@@ -165,7 +165,7 @@ const actions = {
let
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
data
.
show
+
'
/files/
'
+
data
.
file
+
'
/import
'
axios
.
get
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
},
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
},
params
:
{
'
wait-for
'
:
'
running
'
}
}).
then
(
ctx
.
dispatch
(
'
upload
'
,
data
)
...
...
@@ -201,7 +201,7 @@ const actions = {
axios
.
put
(
uri
,
data
.
uploadSourceFile
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
,
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
,
'
Content-Type
'
:
'
application/octet-stream
'
}
}).
then
(()
=>
{
...
...
@@ -231,7 +231,7 @@ const actions = {
// TODO: add mechanism to indicate the running delete request in the files table
axios
.
delete
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
},
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
},
}).
then
(()
=>
{
ctx
.
commit
(
'
deleteFile
'
,
data
.
file
)
if
(
data
&&
typeof
(
data
.
callback
)
===
'
function
'
)
{
data
.
callback
()
}
...
...
src/store/modules/playlists.js
View file @
993f3fd8
...
...
@@ -47,7 +47,7 @@ const actions = {
let
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
data
.
slug
+
'
/playlists
'
axios
.
get
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
}
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
}
}).
then
(
response
=>
{
// 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)
...
...
@@ -64,7 +64,7 @@ const actions = {
let
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
data
.
slug
+
'
/playlists
'
axios
.
post
(
uri
,
data
.
playlist
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
}
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
}
}).
then
(
response
=>
{
ctx
.
commit
(
'
addPlaylist
'
,
response
.
data
)
if
(
data
&&
typeof
(
data
.
callback
)
===
'
function
'
)
{
data
.
callback
()
}
...
...
@@ -78,7 +78,7 @@ const actions = {
let
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
data
.
slug
+
'
/playlists/
'
+
data
.
id
axios
.
put
(
uri
,
data
.
playlist
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
}
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
}
}).
then
(
response
=>
{
ctx
.
commit
(
'
updatePlaylist
'
,
{
id
:
data
.
id
,
...
...
@@ -95,7 +95,7 @@ const actions = {
let
uri
=
process
.
env
.
VUE_APP_API_TANK
+
'
shows/
'
+
data
.
slug
+
'
/playlists/
'
+
data
.
id
axios
.
delete
(
uri
,
{
withCredentials
:
true
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
user
.
access
_token
},
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
ctx
.
rootState
.
auth
.
tank
.
session
_token
},
}).
then
(()
=>
{
ctx
.
commit
(
'
deletePlaylist
'
,
data
.
id
)
if
(
data
&&
typeof
(
data
.
callback
)
===
'
function
'
)
{
data
.
callback
()
}
...
...
Andrea Ida Malkah Klaura
@jackie
mentioned in issue
#15 (closed)
·
Jun 30, 2020
mentioned in issue
#15 (closed)
mentioned in issue #15
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment