Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable autoredirect to IdP #4138

Merged
merged 6 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/login-autoredirect
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Change: Enable autoredirect to the IdP

We've added a key into the theme to enable autoredirect to the IdP when entering ocis-web instead of displaying the login page first.
The default value is set to true.

https://github.com/owncloud/phoenix/pull/4138
14 changes: 12 additions & 2 deletions src/pages/login.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="oc-login" uk-height-viewport>
<div v-if="initialized" class="oc-login" uk-height-viewport>
<div class="oc-login-card uk-position-center">
<h1 v-translate class="oc-login-logo">
ownCloud
Expand Down Expand Up @@ -38,7 +38,8 @@ export default {
name: 'LoginPage',
data() {
return {
loading: false
loading: false,
initialized: false
}
},
computed: {
Expand All @@ -48,6 +49,15 @@ export default {
return this.configuration.theme.general.name
}
},

created() {
if (this.configuration.theme.loginPage.autoRedirect) {
this.login()
} else {
this.initialized = true
}
},

methods: {
...mapActions(['login'])
}
Expand Down
22 changes: 15 additions & 7 deletions src/phoenix.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const supportedLanguages = {
gl: 'Galego'
}

function loadApps () {
async function loadApps () {
let plugins = []
let translations = coreTranslations

Expand Down Expand Up @@ -168,6 +168,9 @@ function loadApps () {
silent: true
})

// inject custom theme config into vuex
await fetchTheme()

const OC = new Vue({
el: '#owncloud',
data: {
Expand All @@ -181,13 +184,18 @@ function loadApps () {

// externalize Vue - this is not the Vue instance but the class
window.Vue = Vue
}

// inject custom theme config into vuex
fetch(`themes/${config.theme}.json`)
.then(res => res.json())
.then(res => {
store.dispatch('loadTheme', { theme: res, name: config.theme })
})
function fetchTheme() {
return new Promise((resolve, reject) => {
fetch(`themes/${config.theme}.json`)
.then(res => res.json())
.then(res => {
store.dispatch('loadTheme', { theme: res, name: config.theme })
resolve(true)
})
.catch(err => reject(err))
})
}

function registerStoreModule (app) {
Expand Down
5 changes: 4 additions & 1 deletion src/store/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const state = {
},
filesList: {
hideDefaultStatusIndicators: false
},
loginPage: {
autoRedirect: true
}
},
options: {
Expand Down Expand Up @@ -63,7 +66,7 @@ const mutations = {
}
},
LOAD_THEME(state, theme) {
state.theme = theme
state.theme = { ...state.theme, ...theme }
}
}

Expand Down
4 changes: 1 addition & 3 deletions tests/acceptance/features/webUILogin/login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Feature: login users
And user "user1" has logged in using the webUI
And the user has browsed to the files page
When the user logs out of the webUI
Then the authentication page should be visible
Then the user should be redirected to the IdP login page

@ocisSmokeTest
Scenario: logging out redirects to the url with state attribute
Expand All @@ -43,7 +43,6 @@ Feature: login users
| username |
| user1 |
And the user has browsed to the login page
And the user has clicked the authenticate button
When the user tries to log in with username "invalid" and password "1234" using the webUI
Then the warning 'Logon failed. Please verify your credentials and try again.' should be displayed on the login page

Expand All @@ -53,7 +52,6 @@ Feature: login users
| username |
| user1 |
And the user has browsed to the login page
And the user has clicked the authenticate button
When the user tries to log in with username "user1" and password "invalid" using the webUI
Then the files table should be displayed
# Then the warning 'Logon failed. Please verify your credentials and try again.' should be displayed on the login page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ Feature: Access private link

Scenario: Access the private link anonymously
When the user tries to navigate to the private link created by user "user1" for file "lorem.txt"
Then the user should be redirected to the login page
Then the user should be redirected to the IdP login page
5 changes: 1 addition & 4 deletions tests/acceptance/helpers/loginHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ module.exports = {
* @param {password} [password=null] - If not passed, default password for given `userId` will be used
*/
loginAsUser: async function(userId, password = null) {
await client.page
.loginPage()
.navigate()
.authenticate()
await client.page.loginPage().navigate()

password = password || userSettings.getPasswordForUser(userId)
if (client.globals.openid_login) {
Expand Down
3 changes: 3 additions & 0 deletions tests/acceptance/pageObjects/ocisLoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ module.exports = {
})
.useCss()
return errorMessage
},
waitForPage: function() {
return this.waitForElementVisible('@loginSubmitButton')
}
}
]
Expand Down
3 changes: 3 additions & 0 deletions tests/acceptance/pageObjects/ownCloudAuthorizePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ module.exports = {
}
}
)
},
waitForPage: function() {
return this.waitForElementVisible('@authorizeButton')
}
}
]
Expand Down
8 changes: 8 additions & 0 deletions tests/acceptance/stepDefinitions/loginContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,11 @@ Then('the accounts page should be visible in the webUI', async function() {
Then('the user should be redirected to the login page', function() {
return client.page.loginPage().waitForPage()
})

Then('the user should be redirected to the IdP login page', function() {
if (client.globals.openid_login) {
return client.page.ocisLoginPage().waitForPage()
}

return client.page.ownCloudAuthorizePage().waitForPage()
})
3 changes: 3 additions & 0 deletions themes/owncloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
},
"filesList": {
"hideDefaultStatusIndicators": false
},
"loginPage": {
"autoRedirect": true
}
}