mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Update plugins to only be enabled when ALLOW_PLUGINS=1 env variable is set or AllowPlugins: true in dev.js
This commit is contained in:
		
							parent
							
								
									50e84fc2d5
								
							
						
					
					
						commit
						e7e0056288
					
				| @ -109,13 +109,16 @@ export default { | |||||||
|           id: 'config-authentication', |           id: 'config-authentication', | ||||||
|           title: this.$strings.HeaderAuthentication, |           title: this.$strings.HeaderAuthentication, | ||||||
|           path: '/config/authentication' |           path: '/config/authentication' | ||||||
|         }, |         } | ||||||
|         { |       ] | ||||||
|  | 
 | ||||||
|  |       if (this.$store.state.pluginsEnabled) { | ||||||
|  |         configRoutes.push({ | ||||||
|           id: 'config-plugins', |           id: 'config-plugins', | ||||||
|           title: 'Plugins', |           title: 'Plugins', | ||||||
|           path: '/config/plugins' |           path: '/config/plugins' | ||||||
|  |         }) | ||||||
|       } |       } | ||||||
|       ] |  | ||||||
| 
 | 
 | ||||||
|       if (this.currentLibraryId) { |       if (this.currentLibraryId) { | ||||||
|         configRoutes.push({ |         configRoutes.push({ | ||||||
|  | |||||||
| @ -170,7 +170,10 @@ export default { | |||||||
|       this.$store.commit('setServerSettings', serverSettings) |       this.$store.commit('setServerSettings', serverSettings) | ||||||
|       this.$store.commit('setSource', Source) |       this.$store.commit('setSource', Source) | ||||||
|       this.$store.commit('libraries/setEReaderDevices', ereaderDevices) |       this.$store.commit('libraries/setEReaderDevices', ereaderDevices) | ||||||
|  |       if (plugins !== undefined) { | ||||||
|         this.$store.commit('setPlugins', plugins) |         this.$store.commit('setPlugins', plugins) | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|       this.$setServerLanguageCode(serverSettings.language) |       this.$setServerLanguageCode(serverSettings.language) | ||||||
| 
 | 
 | ||||||
|       if (serverSettings.chromecastEnabled) { |       if (serverSettings.chromecastEnabled) { | ||||||
|  | |||||||
| @ -29,7 +29,8 @@ export const state = () => ({ | |||||||
|   innerModalOpen: false, |   innerModalOpen: false, | ||||||
|   lastBookshelfScrollData: {}, |   lastBookshelfScrollData: {}, | ||||||
|   routerBasePath: '/', |   routerBasePath: '/', | ||||||
|   plugins: [] |   plugins: [], | ||||||
|  |   pluginsEnabled: false | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| export const getters = { | export const getters = { | ||||||
| @ -64,6 +65,7 @@ export const getters = { | |||||||
|     return state.serverSettings.homeBookshelfView |     return state.serverSettings.homeBookshelfView | ||||||
|   }, |   }, | ||||||
|   getPluginExtensions: (state) => (target) => { |   getPluginExtensions: (state) => (target) => { | ||||||
|  |     if (!state.pluginsEnabled) return [] | ||||||
|     return state.plugins |     return state.plugins | ||||||
|       .map((pext) => { |       .map((pext) => { | ||||||
|         const extensionsMatchingTarget = pext.extensions?.filter((ext) => ext.target === target) || [] |         const extensionsMatchingTarget = pext.extensions?.filter((ext) => ext.target === target) || [] | ||||||
| @ -256,5 +258,6 @@ export const mutations = { | |||||||
|   }, |   }, | ||||||
|   setPlugins(state, val) { |   setPlugins(state, val) { | ||||||
|     state.plugins = val |     state.plugins = val | ||||||
|  |     state.pluginsEnabled = true | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								index.js
									
									
									
									
									
								
							| @ -13,6 +13,7 @@ if (isDev) { | |||||||
|   if (devEnv.SkipBinariesCheck) process.env.SKIP_BINARIES_CHECK = '1' |   if (devEnv.SkipBinariesCheck) process.env.SKIP_BINARIES_CHECK = '1' | ||||||
|   if (devEnv.AllowIframe) process.env.ALLOW_IFRAME = '1' |   if (devEnv.AllowIframe) process.env.ALLOW_IFRAME = '1' | ||||||
|   if (devEnv.BackupPath) process.env.BACKUP_PATH = devEnv.BackupPath |   if (devEnv.BackupPath) process.env.BACKUP_PATH = devEnv.BackupPath | ||||||
|  |   if (devEnv.AllowPlugins) process.env.ALLOW_PLUGINS = '1' | ||||||
|   process.env.SOURCE = 'local' |   process.env.SOURCE = 'local' | ||||||
|   process.env.ROUTER_BASE_PATH = devEnv.RouterBasePath || '' |   process.env.ROUTER_BASE_PATH = devEnv.RouterBasePath || '' | ||||||
| } | } | ||||||
|  | |||||||
| @ -935,14 +935,12 @@ class Auth { | |||||||
|    */ |    */ | ||||||
|   async getUserLoginResponsePayload(user) { |   async getUserLoginResponsePayload(user) { | ||||||
|     const libraryIds = await Database.libraryModel.getAllLibraryIds() |     const libraryIds = await Database.libraryModel.getAllLibraryIds() | ||||||
|     return { | 
 | ||||||
|       user: user.toOldJSONForBrowser(), |     let plugins = undefined | ||||||
|       userDefaultLibraryId: user.getDefaultLibraryId(libraryIds), |     if (process.env.ALLOW_PLUGINS === '1') { | ||||||
|       serverSettings: Database.serverSettings.toJSONForBrowser(), |  | ||||||
|       ereaderDevices: Database.emailSettings.getEReaderDevices(user), |  | ||||||
|       // TODO: Should be better handled by the PluginManager
 |       // TODO: Should be better handled by the PluginManager
 | ||||||
|       // restrict plugin extensions that are not allowed for the user type
 |       // restrict plugin extensions that are not allowed for the user type
 | ||||||
|       plugins: this.pluginManifests.map((manifest) => { |       plugins = this.pluginManifests.map((manifest) => { | ||||||
|         const manifestExtensions = (manifest.extensions || []).filter((ext) => { |         const manifestExtensions = (manifest.extensions || []).filter((ext) => { | ||||||
|           if (ext.restrictToAccountTypes?.length) { |           if (ext.restrictToAccountTypes?.length) { | ||||||
|             return ext.restrictToAccountTypes.includes(user.type) |             return ext.restrictToAccountTypes.includes(user.type) | ||||||
| @ -950,7 +948,15 @@ class Auth { | |||||||
|           return true |           return true | ||||||
|         }) |         }) | ||||||
|         return { ...manifest, extensions: manifestExtensions } |         return { ...manifest, extensions: manifestExtensions } | ||||||
|       }), |       }) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return { | ||||||
|  |       user: user.toOldJSONForBrowser(), | ||||||
|  |       userDefaultLibraryId: user.getDefaultLibraryId(libraryIds), | ||||||
|  |       serverSettings: Database.serverSettings.toJSONForBrowser(), | ||||||
|  |       ereaderDevices: Database.emailSettings.getEReaderDevices(user), | ||||||
|  |       plugins, | ||||||
|       Source: global.Source |       Source: global.Source | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -151,11 +151,15 @@ class Server { | |||||||
|       }) |       }) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     if (process.env.ALLOW_PLUGINS === '1') { | ||||||
|  |       Logger.info(`[Server] Experimental plugin support enabled`) | ||||||
|  | 
 | ||||||
|       // Initialize plugins
 |       // Initialize plugins
 | ||||||
|       await PluginManager.init() |       await PluginManager.init() | ||||||
|       // TODO: Prevents circular dependency for SocketAuthority
 |       // TODO: Prevents circular dependency for SocketAuthority
 | ||||||
|       this.auth.pluginManifests = PluginManager.pluginManifests |       this.auth.pluginManifests = PluginManager.pluginManifests | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|    * Listen for SIGINT and uncaught exceptions |    * Listen for SIGINT and uncaught exceptions | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user