Skip to content
Snippets Groups Projects
Commit 421822f5 authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

code cleanup and minor fixes

parent 6332ae47
No related branches found
No related tags found
No related merge requests found
...@@ -9,8 +9,12 @@ module.exports = merge(prodEnv, { ...@@ -9,8 +9,12 @@ module.exports = merge(prodEnv, {
API_STEERING_SHOWS: '"http://127.0.0.1:8000/api/v1/shows/"', API_STEERING_SHOWS: '"http://127.0.0.1:8000/api/v1/shows/"',
// OIDC endpoint of the pv/steering module // OIDC endpoint of the pv/steering module
API_STEERING_OIDC_URI: '"http://localhost:8000/openid"', API_STEERING_OIDC_URI: '"http://localhost:8000/openid"',
// local callback handler that is called by the pv/steering OIDC module after login // number of seconds before token gets invalid, when renewal should be started
API_STEERING_OIDC_EXPIRE_NOTIFICATION: '120',
// local callback handlers that are called by the pv/steering OIDC module after login/renwal
API_STEERING_OIDC_REDIRECT_URI: '"http://localhost:8080/static/oidc_callback.html"', API_STEERING_OIDC_REDIRECT_URI: '"http://localhost:8080/static/oidc_callback.html"',
API_STEERING_OIDC_REDIRECT_URI_SILENT: '"http://localhost:8080/static/oidc_callback_silentRenew.html"',
API_STEERING_OIDC_REDIRECT_URI_POPUP: '"http://localhost:8080/static/oidc_callback_popupRenew.html"',
// address that is called by the pv/steering OIDC module after logout - should be the dashboard entry point // address that is called by the pv/steering OIDC module after logout - should be the dashboard entry point
API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT: '"http://localhost:8080"' API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT: '"http://localhost:8080"'
}) })
...@@ -50,12 +50,11 @@ export default { ...@@ -50,12 +50,11 @@ export default {
redirect_uri: process.env.API_STEERING_OIDC_REDIRECT_URI, redirect_uri: process.env.API_STEERING_OIDC_REDIRECT_URI,
silent_redirect_uri: 'http://localhost:8080/static/oidc_callback_silentRenew.html', silent_redirect_uri: 'http://localhost:8080/static/oidc_callback_silentRenew.html',
popup_redirect_uri: 'http://localhost:8080/static/oidc_callback_popupRenew.html', popup_redirect_uri: 'http://localhost:8080/static/oidc_callback_popupRenew.html',
accessTokenExpiringNotificationTime: process.env.API_STEERING_OIDC_EXPIRE_NOTIFICATION,
response_type: 'id_token token', response_type: 'id_token token',
scope: 'openid profile email', scope: 'openid profile email',
post_logout_redirect_uri: process.env.API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT, post_logout_redirect_uri: process.env.API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT,
loadUserInfo: true, loadUserInfo: true
// automaticSilentRenew: true
automaticSilentRenew: false
}) })
} }
}, },
...@@ -89,6 +88,8 @@ export default { ...@@ -89,6 +88,8 @@ export default {
self.user.email = '' self.user.email = ''
self.user.access_token = '' self.user.access_token = ''
} else { } else {
// TODO: check user.expires_at
// if token already expired try to get a new one or mark the user as logged out
self.setUserProperties(user) self.setUserProperties(user)
} }
}).catch(function (err) { }).catch(function (err) {
...@@ -101,6 +102,7 @@ export default { ...@@ -101,6 +102,7 @@ export default {
this.user.name = user.profile.nickname this.user.name = user.profile.nickname
this.user.email = user.profile.email this.user.email = user.profile.email
this.user.access_token = user.access_token this.user.access_token = user.access_token
// TODO: remove debug info after thorough testing
console.log(new Date(user.expires_at * 1000).toString()) console.log(new Date(user.expires_at * 1000).toString())
console.log(new Date(user.expires_at * 1000).toUTCString()) console.log(new Date(user.expires_at * 1000).toUTCString())
console.log(user.access_token) console.log(user.access_token)
...@@ -110,29 +112,15 @@ export default { ...@@ -110,29 +112,15 @@ export default {
// TODO: remove oidc logging after thorough testing // TODO: remove oidc logging after thorough testing
oidc.Log.logger = console oidc.Log.logger = console
let self = this let self = this
this.oidcmgr.events.addSilentRenewError(function () {
// TODO: set accessTokenExpiringNotificationTime when this.oidcmgr is created and insert this value here too
alert('Your OpenID access token could not be renewed automatically. You will be logged out in 60 seconds.')
})
this.oidcmgr.events.addAccessTokenExpiring(function () { this.oidcmgr.events.addAccessTokenExpiring(function () {
console.log('token will soon expire') console.log('starting silent access_token renewal')
/* Use the following code instead of silent renewal if you want to use popups
console.log('starting signinPopup')
self.oidcmgr.signinPopup(function (user) {
console.log('signinPopup result for user:')
console.log(user)
}).catch(function (err) {
console.log(err)
})
*/
console.log('starting signinSilent')
self.oidcmgr.signinSilent().then(function (user) { self.oidcmgr.signinSilent().then(function (user) {
console.log('signinPopup result for user:')
console.log(self.user.access_token)
self.user.access_token = user.access_token self.user.access_token = user.access_token
console.log(self.user.access_token) console.log(self.user.access_token)
}).catch(function (err) { }).catch(function (err) {
console.log(err) console.log(err)
alert('Your OpenID access token could not be renewed automatically.\n' +
'You will be logged out in ' + process.env.API_STEERING_OIDC_EXPIRE_NOTIFICATION + ' seconds.')
}) })
}) })
this.oidcmgr.events.addAccessTokenExpired(function () { this.oidcmgr.events.addAccessTokenExpired(function () {
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<script> <script>
var mgr = new Oidc.UserManager({userStore: new Oidc.WebStorageStateStore()}) var mgr = new Oidc.UserManager({userStore: new Oidc.WebStorageStateStore()})
mgr.signinRedirectCallback().then(function (user) { mgr.signinRedirectCallback().then(function (user) {
console.log(user)
window.location.href = '../' window.location.href = '../'
}).catch(function (err) { }).catch(function (err) {
console.log(err) console.log(err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment