From e40df4d25dd3ceb84deb73c6dcf40951c56847ac Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 19 Feb 2020 17:52:46 +0530 Subject: [PATCH] login: add SAML single-sign-on support (#169) This adds SAML single-sign-on support. Signed-off-by: Rohit Yadav Co-authored-by: Rohit Yadav --- ui/src/permission.js | 2 ++ ui/src/utils/request.js | 17 +++++---- ui/src/views/auth/Login.vue | 72 ++++++++++++++++++++++++++----------- 3 files changed, 64 insertions(+), 27 deletions(-) diff --git a/ui/src/permission.js b/ui/src/permission.js index bf437205b85..2bbc789a90d 100644 --- a/ui/src/permission.js +++ b/ui/src/permission.js @@ -22,6 +22,7 @@ import store from './store' import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style +import message from 'ant-design-vue/es/message' import notification from 'ant-design-vue/es/notification' import { setDocumentTitle, domTitle } from '@/utils/domUtil' import { ACCESS_TOKEN } from '@/store/mutation-types' @@ -41,6 +42,7 @@ router.beforeEach((to, from, next) => { NProgress.done() } else { if (Object.keys(store.getters.apis).length === 0) { + message.loading('Discovering features...', 5) store .dispatch('GetInfo') .then(apis => { diff --git a/ui/src/utils/request.js b/ui/src/utils/request.js index 235793ad097..f28958fcef1 100644 --- a/ui/src/utils/request.js +++ b/ui/src/utils/request.js @@ -29,15 +29,18 @@ const service = axios.create({ }) const err = (error) => { - if (error.response) { - console.log('error has occurred') - console.log(error) + const response = error.response + if (response) { + console.log(response) const token = Vue.ls.get(ACCESS_TOKEN) - if (error.response.status === 403) { - const data = error.response.data + if (response.status === 403) { + const data = response.data notification.error({ message: 'Forbidden', description: data.message }) } - if (error.response.status === 401) { + if (response.status === 401) { + if (response.config && response.config.params && ['listIdps'].includes(response.config.params.command)) { + return + } notification.error({ message: 'Unauthorized', description: 'Authorization verification failed' }) if (token) { store.dispatch('Logout').then(() => { @@ -47,7 +50,7 @@ const err = (error) => { }) } } - if (error.response.status === 404) { + if (response.status === 404) { notification.error({ message: 'Not Found', description: 'Resource not found' }) this.$router.push({ path: '/exception/404' }) } diff --git a/ui/src/views/auth/Login.vue b/ui/src/views/auth/Login.vue index 1bc6ec0498d..2e6f01957c8 100644 --- a/ui/src/views/auth/Login.vue +++ b/ui/src/views/auth/Login.vue @@ -28,11 +28,12 @@ size="large" :tabBarStyle="{ textAlign: 'center', borderBottom: 'unset' }" @change="handleTabClick" + :animated="false" > - + - CloudStack Login + Portal Login - + - SAML + Single-Sign-On + + + + {{ idp.orgName }} + + + @@ -100,14 +108,18 @@