Commit aa220d26 authored by Andrea Ida Malkah Klaura's avatar Andrea Ida Malkah Klaura
Browse files

added oidc access token renewal with debug code

parent c75a659a
......@@ -4,6 +4,7 @@ const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
OIDC_CLIENT_ID: '"174626"',
API_STEERING: '"http://127.0.0.1:8000/api/v1/"',
API_STEERING_SHOWS: '"http://127.0.0.1:8000/api/v1/shows/"',
// OIDC endpoint of the pv/steering module
......
......@@ -38,19 +38,23 @@ export default {
name: '',
email: '',
access_token: '',
expires_at: 0,
logged_in: false
},
userOIDC: null,
mgr: new oidc.UserManager({
userStore: new oidc.WebStorageStateStore(),
authority: process.env.API_STEERING_OIDC_URI,
client_id: '174626',
// the client id has to be a string, therefore we add the + ''
client_id: process.env.OIDC_CLIENT_ID,
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',
popup_redirect_uri: 'http://localhost:8080/static/oidc_callback_popupRenew.html',
response_type: 'id_token token',
scope: 'openid profile email',
post_logout_redirect_uri: process.env.API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT,
loadUserInfo: true
loadUserInfo: true,
automaticSilentRenew: true
})
}
},
......@@ -89,6 +93,9 @@ export default {
self.user.name = u.profile.nickname
self.user.email = u.profile.email
self.user.access_token = u.access_token
console.log(new Date(u.expires_at * 1000).toString())
console.log(new Date(u.expires_at * 1000).toUTCString())
console.log(u.access_token)
}
}).catch(function (err) {
console.log(err)
......@@ -96,7 +103,31 @@ export default {
}
},
mounted () {
// TODO: remove oidc logging after thorough testing
oidc.Log.logger = console
let self = this
this.mgr.events.addSilentRenewError(function () {
// TODO: set accessTokenExpiringNotificationTime when this.mgr 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.mgr.events.addAccessTokenExpiring(function () {
console.log('token will soon expire')
console.log(self)
/* Use the following code instead of silent renewal if you want to use popups
console.log('starting signinPopup')
self.mgr.signinPopup(function (user) {
console.log('signinPopup result for user:')
console.log(user)
}).catch(function (err) {
console.log(err)
})
*/
})
this.mgr.events.addAccessTokenExpired(function () {
console.log('expired!')
})
this.getUser()
this.mgr.startSilentRenew()
}
}
</script>
......
......@@ -36,7 +36,7 @@
<b-dropdown-item href="#">Profile</b-dropdown-item>
<b-dropdown-item @click='$parent.signOut'>Signout</b-dropdown-item>
</b-nav-item-dropdown>
<b-nav-item v-if="! user.logged_in" to="login"><img src="../assets/16x16/system-users.png" alt="log-in symbol" title="Log in"></b-nav-item>
<b-nav-item v-if="! user.logged_in" to="home"><img src="../assets/16x16/system-users.png" alt="log-in symbol" title="Log in"></b-nav-item>
<div class="help-image-container">
<b-nav-item>
<router-link to="help"><img class="help-image" src="../assets/help-browser-32x32.png" alt="Help symbol" title="Go to help pages"></router-link>
......
......@@ -11,6 +11,7 @@
<script>
var mgr = new Oidc.UserManager({userStore: new Oidc.WebStorageStateStore()})
mgr.signinRedirectCallback().then(function (user) {
console.log(user)
window.location.href = '../'
}).catch(function (err) {
console.log(err)
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Waiting...</title>
</head>
<body>
<script src="oidc-client.js"></script>
<script>
var mgr = new Oidc.UserManager()
mgr.signinPopupCallback()
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Waiting...</title>
</head>
<body>
<script src="oidc-client.js"></script>
<script>
var mgr = new Oidc.UserManager()
mgr.signinSilentCallback()
</script>
</body>
</html>
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