SSO package for RDP products
npm install @leroyleejh/rdp-sso
To be used with Vue 2.x and Vue-Router 3.x
#!/bin/sh
PARENT_DIR=$( pwd -P )
PATH="${PARENT_DIR}/.env.development.local"
if [ "$1" == "prod" ]; then
PATH="${CI_PROJECT_DIR}/frontend/.env.production"
fi
echo "VUE_APP_RDP_SSO_ENDPOINT=\"$RDP_SSO_ENDPOINT\"" >> $PATH
echo "VUE_APP_RDP_SSO_PAGE=\"$RDP_SSO_PAGE\"" >> $PATH
echo "VUE_APP_RDP_SSO_PUB=\"$RDP_SSO_PUBLIC_KEY\"" >> $PATH
echo "VUE_APP_RDP_SSO_ISS=\"$RDP_SSO_ISS\"" >> $PATH
echo "VUE_APP_RDP_SSO_SHORTKEY_TIMEOUT=\"$RDP_SSO_SHORTLIVE_TIMEOUT\"" >> $PATH
Create a few files below to use
<template>
</template>
<script>
export default {
name: 'auth',
mounted() {
const vue = this;
vue.$sso.checkSSO(vue.$router);
}
}
</script>
<template>
</template>
<script>
export default {
name: 'login',
mounted() {
const vue = this;
vue.$sso.doLogin(vue.$route, vue.$router);
}
}
</script>
import Login from './views/login.vue'; // path to login.vue
import Auth from './views/auth.vue'; // path to auth.vue
routes: [
{
path: '/login',
component: Login,
name: 'login',
},
{
path: '/auth',
component: Auth,
name: 'auth',
},
]
import Vue from 'vue';
import SSO from '@leroyleejh/rdp-sso';
Object.defineProperty(Vue.prototype, '$sso', { value: SSO });
router.beforeEach((to, from, next) => {
if (window.location.pathname.length >= 2) {
window.location = `${window.location.origin}/#${window.location.pathname}${window.location.search}`;
}
SSO.init(to, from, router);
next();
}
export default {
mounted() {
const vue = this;
const permissionsObj = vue.$sso.getPermissions();
}
}