SSO Provider Settings
@@ -9,32 +7,32 @@
@@ -42,32 +40,32 @@
-
+
Create a new user on first login
-
+
The new user is allowed to download
-
+
The new user is allowed to update
-
+
The new user is allowed to delete
-
+
The new user is allowed to upload
-
+
The new user is allowed to access all libraries
@@ -83,12 +81,12 @@ export default {
data() {
return {
oidc: {
- issuer: "",
- authorizationURL: "",
- tokenURL: "",
- userInfoURL: "",
- clientID: "",
- clientSecret: "",
+ issuer: '',
+ authorizationURL: '',
+ tokenURL: '',
+ userInfoURL: '',
+ clientID: '',
+ clientSecret: ''
},
user: {
createNewUser: false,
@@ -112,178 +110,103 @@ export default {
accessAllLibraries: false
}
},
- updatingSSOSettings: false,
- newSSOSettings: {}
+ updatingSSOSettings: false
}
},
watch: {
SSOSettings(newVal, oldVal) {
+ console.log('SSO Settings set', newVal, oldVal)
if (newVal && !oldVal) {
- this.newSSOSettings = { ...this.SSOSettings }
this.initSSOSettings()
}
}
},
computed: {
SSOSettings() {
- return this.$store.state.sso
- },
-
- issuer: {
- get() {
- return this.oidc.issuer
- return this.$store.state.sso.oidc.issuer
- },
- set(val) {
- this.oidc.issuer = val
- // this.$store.state.sso.oidc.issuer = val
- }
- },
- authorizationURL: {
- get() {
- return this.oidc.authorizationURL
- return this.$store.state.sso.oidc.authorizationURL
- },
- set(val) {
- this.oidc.authorizationURL = val
- // this.$store.state.sso.oidc.authorizationURL = val
- }
- },
- tokenURL: {
- get() {
- return this.oidc.tokenURL
- return this.$store.state.sso.oidc.tokenURL
- },
- set(val) {
- this.oidc.tokenURL = val
- // this.$store.state.sso.oidc.tokenURL = val
- }
- },
- userInfoURL: {
- get() {
- return this.oidc.userInfoURL
- return this.$store.state.sso.oidc.userInfoURL
- },
- set(val) {
- this.oidc.userInfoURL = val
- // this.$store.state.sso.oidc.userInfoURL = val
- },
- },
- clientID: {
- get() {
- return this.oidc.clientID
- return this.$store.state.sso.oidc.clientID
- },
- set(val) {
- this.oidc.clientID = val
- // this.$store.state.sso.oidc.clientID = val
- },
- },
- clientSecret: {
- get() {
- return this.oidc.clientSecret
- return this.$store.state.sso.oidc.clientSecret
- },
- set(val) {
- this.oidc.clientSecret = val
- // this.$store.state.sso.oidc.clientSecret = val
- },
- },
- createNewUser: {
- get() {
- return this.user.createNewUser
- return this.$store.state.sso.createNewUser
- },
- set(val) {
- this.user.createNewUser = val
- // this.$store.state.sso.createNewUser = val
- },
+ return this.$store.state.settings.SSOSettings
},
permissionDownload: {
get() {
return this.user.permissions.download
- return this.$store.state.sso.permissions.download
},
set(val) {
this.user.permissions.download = val
- // this.$store.state.sso.permissions.download = val
- },
+ }
},
permissionUpdate: {
get() {
return this.user.permissions.update
- return this.$store.state.sso.permissions.update
},
set(val) {
this.user.permissions.update = val
- // this.$store.state.sso.permissions.update = val
- },
+ }
},
permissionDelete: {
get() {
return this.user.permissions.delete
- return this.$store.state.sso.permissions.delete
},
set(val) {
this.user.permissions.delete = val
- // this.$store.state.sso.permissions.delete = val
- },
+ }
},
permissionUpload: {
get() {
return this.user.permissions.upload
- return this.$store.state.sso.permissions.upload
},
set(val) {
this.user.permissions.upload = val
- // this.$store.state.sso.permissions.upload = val
}
},
permissionAccessAllLibraries: {
get() {
return this.user.permissions.accessAllLibraries
- return this.$store.state.sso.permissions.accessAllLibraries
},
set(val) {
this.user.permissions.accessAllLibraries = val
- // this.$store.state.sso.permissions.accessAllLibraries = val
}
- },
+ }
},
methods: {
- saveSSOSettings(payload) {
+ saveSSOSettings() {
this.updatingSSOSettings = true
this.$store
- .dispatch('sso/updateSSOSettings', {oidc: this.oidc, user: this.user})
- .then((success) => {
+ .dispatch('settings/updateSSOSettings', { oidc: this.oidc, user: this.user })
+ .then((payload) => {
+ console.log('Update SSO settings success', payload)
this.updatingSSOSettings = false
+ this.$toast.success('SSO Settings Saved')
})
.catch((error) => {
console.error('Failed to update SSO settings', error)
this.updatingSSOSettings = false
+ this.$toast.error('Failed to save SSO Settings')
})
},
initSSOSettings() {
- for (const key in this.$store.state.sso.oidc) {
- this.oidc[key] = this.$store.state.sso.oidc[key]
+ if (!this.SSOSettings || !this.SSOSettings.user || !this.SSOSettings.oidc) {
+ console.error('Invalid SSOSettings obj', this.SSOSettings)
+ return
}
- for (const key in this.$store.state.sso.user) {
- if (typeof this.$store.state.sso.user[key] === "object" && typeof this.user[key] === "object") {
- for (const key2 in this.$store.state.sso.user[key]) {
- this.user[key][key2] = this.$store.state.sso.user[key][key2]
+ for (const key in this.SSOSettings.oidc) {
+ this.oidc[key] = this.SSOSettings.oidc[key]
+ }
+
+ for (const key in this.SSOSettings.user) {
+ if (typeof this.SSOSettings.user[key] === 'object' && typeof this.user[key] === 'object') {
+ for (const key2 in this.SSOSettings.user[key]) {
+ this.user[key][key2] = this.SSOSettings.user[key][key2]
}
continue
}
if (this.user[key] !== undefined) {
- this.user[key] = this.$store.state.sso.user[key]
+ this.user[key] = this.SSOSettings.user[key]
}
}
- },
-
+ }
},
mounted() {
- this.initSSOSettings()
+ if (this.SSOSettings) this.initSSOSettings()
}
}
\ No newline at end of file
diff --git a/client/pages/config/users/_id.vue b/client/pages/config/users/_id.vue
index 3454210ba..5f1bc2ef7 100644
--- a/client/pages/config/users/_id.vue
+++ b/client/pages/config/users/_id.vue
@@ -88,7 +88,7 @@ export default {
},
computed: {
coverAspectRatio() {
- return this.$store.getters['getServerSetting']('coverAspectRatio')
+ return this.$store.getters['settings/getServerSetting']('coverAspectRatio')
},
bookCoverAspectRatio() {
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE ? 1 : 1.6
diff --git a/client/store/index.js b/client/store/index.js
index 443aabad0..a1d25e3ac 100644
--- a/client/store/index.js
+++ b/client/store/index.js
@@ -3,7 +3,6 @@ import Vue from 'vue'
export const state = () => ({
versionData: null,
- serverSettings: null,
streamAudiobook: null,
editModalTab: 'details',
showEditModal: false,
@@ -28,14 +27,6 @@ export const getters = {
getIsAudiobookSelected: state => audiobookId => {
return !!state.selectedAudiobooks.includes(audiobookId)
},
- getServerSetting: state => key => {
- if (!state.serverSettings) return null
- return state.serverSettings[key]
- },
- getBookCoverAspectRatio: state => {
- if (!state.serverSettings || !state.serverSettings.coverAspectRatio) return 1.6
- return state.serverSettings.coverAspectRatio === 0 ? 1.6 : 1
- },
getNumAudiobooksSelected: state => state.selectedAudiobooks.length,
getAudiobookIdStreaming: state => {
return state.streamAudiobook ? state.streamAudiobook.id : null
@@ -43,22 +34,6 @@ export const getters = {
}
export const actions = {
- updateServerSettings({ commit }, payload) {
- var updatePayload = {
- ...payload
- }
- return this.$axios.$patch('/api/serverSettings', updatePayload).then((result) => {
- if (result.success) {
- commit('setServerSettings', result.serverSettings)
- return true
- } else {
- return false
- }
- }).catch((error) => {
- console.error('Failed to update server settings', error)
- return false
- })
- },
checkForUpdate({ commit }) {
return checkForUpdate()
.then((res) => {
@@ -102,10 +77,6 @@ export const mutations = {
setVersionData(state, versionData) {
state.versionData = versionData
},
- setServerSettings(state, settings) {
- if (!settings) return
- state.serverSettings = settings
- },
setStreamAudiobook(state, audiobook) {
state.playOnLoad = true
state.streamAudiobook = audiobook
diff --git a/client/store/settings.js b/client/store/settings.js
new file mode 100644
index 000000000..0023b1870
--- /dev/null
+++ b/client/store/settings.js
@@ -0,0 +1,63 @@
+export const state = () => ({
+ SSOSettings: null,
+ serverSettings: null
+})
+
+export const getters = {
+ getServerSetting: state => key => {
+ if (!state.serverSettings) return null
+ return state.serverSettings[key]
+ },
+ getBookCoverAspectRatio: state => {
+ if (!state.serverSettings || !state.serverSettings.coverAspectRatio) return 1.6
+ return state.serverSettings.coverAspectRatio === 0 ? 1.6 : 1
+ }
+}
+
+export const actions = {
+ updateServerSettings({ commit }, payload) {
+ var updatePayload = {
+ ...payload
+ }
+ return this.$axios.$patch('/api/serverSettings', updatePayload).then((result) => {
+ if (result.success) {
+ commit('setServerSettings', result.serverSettings)
+ return true
+ } else {
+ return false
+ }
+ }).catch((error) => {
+ console.error('Failed to update server settings', error)
+ return false
+ })
+ },
+ updateSSOSettings({ commit }, payload) {
+ var updatePayload = {
+ ...payload
+ }
+ // Immediately update
+ commit('setSSOSettings', updatePayload)
+ return this.$axios.$patch('/api/SSOSettings', updatePayload).then((result) => {
+ if (result.success) {
+ commit('setSSOSettings', result.settings)
+ return true
+ } else {
+ return false
+ }
+ }).catch((error) => {
+ console.error('Failed to update sso settings', error)
+ return false
+ })
+ }
+}
+
+export const mutations = {
+ setServerSettings(state, settings) {
+ if (!settings) return
+ state.serverSettings = settings
+ },
+ setSSOSettings(state, settings) {
+ if (!settings || !settings.oidc || !settings.user) return
+ state.SSOSettings = settings
+ }
+}
\ No newline at end of file
diff --git a/client/store/sso.js b/client/store/sso.js
deleted file mode 100644
index 7bd70812b..000000000
--- a/client/store/sso.js
+++ /dev/null
@@ -1,108 +0,0 @@
-const defaultSSOSettings = {
- oidc: {
- issuer: "",
- authorizationURL: "",
- tokenURL: "",
- userInfoURL: "",
- clientID: "",
- clientSecret: "",
- callbackURL: "/oidc/callback",
- scope: "openid email profile"
- },
- user: {
- createNewUser: false,
- isActive: true,
- settings: {
- mobileOrderBy: 'recent',
- mobileOrderDesc: true,
- mobileFilterBy: 'all',
- orderBy: 'book.title',
- orderDesc: false,
- filterBy: 'all',
- playbackRate: 1,
- bookshelfCoverSize: 120,
- collapseSeries: false
- },
- permissions: {
- download: false,
- update: false,
- delete: false,
- upload: false,
- accessAllLibraries: false
- }
- }
-}
-
-export const state = () => defaultSSOSettings
-
-export const getters = {
- getSSOIssuer: (state) => state.oidc.issuer,
- getSSOAuthorizationURL: (state) => state.oidc.authorizationURL,
- getSSOTokenURL: (state) => state.oidc.tokenURL,
- getSSOUserInfoURL: (state) => state.oidc.userInfoURL,
- getSSOClientID: (state) => state.oidc.clientID,
- getSSOClientSecret: (state) => state.oidc.clientSecret,
- getSSOCallbackURL: (state) => state.oidc.callbackURL,
- getSSOScope: (state) => state.oidc.scope,
-
- getUserCreateNewUser: (state) => state.user.createNewUser,
- getUserIsActive: (state) => state.user.isActive,
- getUserPermissionDownload: (state) => state.user.permissions.download,
- getUserPermissionUpdate: (state) => state.user.permissions.update,
- getUserPermissionDelete: (state) => state.user.permissions.delete,
- getUserPermissionUpload: (state) => state.user.permissions.upload,
- getUserPermissionAccessAllLibraries: (state) => state.user.permissions.accessAllLibraries,
-}
-
-export const actions = {
- updateSSOSettings({ commit }, payload) {
- var updatePayload = {
- ...payload
- }
- // Immediately update
- commit('setSSOSettings', updatePayload)
- return this.$axios.$patch('/api/SSOSettings', updatePayload).then((result) => {
- if (result.success) {
- commit('setSSOSettings', result.settings)
- return true
- } else {
- return false
- }
- }).catch((error) => {
- console.error('Failed to update sso settings', error)
- return false
- })
- },
- loadSSOSettings({ state, commit }) {
-
- return this.$axios.$get('/api/collections').then((collections) => {
- commit('setCollections', collections)
- return collections
- }).catch((error) => {
- console.error('Failed to get collections', error)
- return []
- })
- }
-}
-
-export const mutations = {
- setSSOSettings(state, settings) {
- if (!settings || !settings.oidc || !settings.user) return
-
- for (const key in settings.oidc) {
- state.oidc[key] = settings.oidc[key]
- }
-
- for (const key in settings.user) {
- if (typeof settings.user[key] === "object" && typeof state.user[key] === "object") {
- for (const key2 in settings.user[key]) {
- state.user[key][key2] = settings.user[key][key2]
- }
- continue
- }
- if (state.user[key] !== undefined) {
- state.user[key] = settings.user[key]
- }
- }
- },
-}
\ No newline at end of file