1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/static/keycloak_index.html
Steve Richards 48c712da32 Working POC against DECC
For the demo to work the following env vars need to passed when running lens in dev
mode:

- DECC_URL: This is the DECC Manager URL
- DECC_USERNAME: This is the username you would use against keycloak
- DECC_PASSWORD: This is the password you would use against keycloak
- NODE_ENV: Should be set to `development`
2020-09-24 15:14:36 +01:00

53 lines
2.0 KiB
HTML

<!-- <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval' https://a69adcd0687194b2b8adebdbe93f2a02-977850409.eu-west-2.elb.amazonaws.com/auth/js/keycloak.js;"> -->
<script src="https://a69adcd0687194b2b8adebdbe93f2a02-977850409.eu-west-2.elb.amazonaws.com/auth/js/keycloak.js"></script>
<script>
const { ipcRenderer } = require('electron')
const useK8sClientId = new URL(location.href).searchParams.get('k8s');
var keycloak = new Keycloak({
url: 'https://a69adcd0687194b2b8adebdbe93f2a02-977850409.eu-west-2.elb.amazonaws.com/auth',
realm: 'iam',
clientId: 'kaas',
scope: 'offline_access openid',
});
var keycloakOptions = {
flow: 'standard',
enableLogging: true,
useNonce: false,
onLoad: 'login-required',
checkLoginIframe: false,
redirectUri: 'http://localhost:3000'
}
//if param "logout" was passed to this page, logout user!
const logoutUser = new URL(location.href).searchParams.get('logout');
if(logoutUser){
keycloak.init();
keycloak.logout({redirectUri: 'http://localhost:3000'});
}else{
keycloak.init(keycloakOptions).success(function(authenticated) {
console.log('success!!');
if (authenticated) {
console.log("keycloak.token: " + keycloak.token);
console.log("keycloak.idToken: " + keycloak.idToken);
console.log("keycloak.refreshToken: " + keycloak.refreshToken);
console.log("keycloak object: "+ JSON.stringify(keycloak));
ipcRenderer.send('keycloak-token', keycloak.idToken, keycloak.refreshToken);
//TODO: check if token refresh is possible here
// setInterval(() => {
// let tokenRefreshAt = new Date();
// console.log(`keycloak interval: ${tokenRefreshAt.toString()}`);
// keycloak.updateToken(10).error(() => keycloak.logout());
// console.log(keycloak.token);
// ipcRenderer.send('keycloak-token-update', keycloak.idToken, keycloak.refreshToken);
// }, 10000);
}
}).error(function(error) {
console.log('error: ' + JSON.stringify(error));
});
}
</script>