mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
feat: refactor plugin host permissions to use RequiredHosts directly for improved clarity
This commit is contained in:
parent
2e1166f718
commit
2006474507
@ -268,8 +268,10 @@ func (m *Manager) loadPluginWithConfig(p *model.Plugin) error {
|
||||
Timeout: uint64(defaultTimeout.Milliseconds()),
|
||||
}
|
||||
|
||||
if hosts := pkg.Manifest.RequiredHTTPHosts(); len(hosts) > 0 {
|
||||
pluginManifest.AllowedHosts = hosts
|
||||
if pkg.Manifest.Permissions != nil && pkg.Manifest.Permissions.Http != nil {
|
||||
if hosts := pkg.Manifest.Permissions.Http.RequiredHosts; len(hosts) > 0 {
|
||||
pluginManifest.AllowedHosts = hosts
|
||||
}
|
||||
}
|
||||
|
||||
// Configure filesystem access for library permission
|
||||
|
||||
@ -45,15 +45,6 @@ func ValidateWithCapabilities(m *Manifest, capabilities []Capability) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RequiredHTTPHosts returns a list of required hosts for HTTP requests.
|
||||
// Returns the hosts directly from the manifest's permissions.
|
||||
func (m *Manifest) RequiredHTTPHosts() []string {
|
||||
if m.Permissions == nil || m.Permissions.Http == nil {
|
||||
return nil
|
||||
}
|
||||
return m.Permissions.Http.RequiredHosts
|
||||
}
|
||||
|
||||
// HasExperimentalThreads returns true if the manifest requests experimental threads support.
|
||||
func (m *Manifest) HasExperimentalThreads() bool {
|
||||
return m.Experimental != nil && m.Experimental.Threads != nil
|
||||
|
||||
@ -117,35 +117,6 @@ var _ = Describe("Manifest", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("RequiredHTTPHosts", func() {
|
||||
It("returns nil when no permissions", func() {
|
||||
m := &Manifest{}
|
||||
|
||||
Expect(m.RequiredHTTPHosts()).To(BeNil())
|
||||
})
|
||||
|
||||
It("returns nil when no HTTP permissions", func() {
|
||||
m := &Manifest{
|
||||
Permissions: &Permissions{},
|
||||
}
|
||||
|
||||
Expect(m.RequiredHTTPHosts()).To(BeNil())
|
||||
})
|
||||
|
||||
It("returns hosts from permissions", func() {
|
||||
m := &Manifest{
|
||||
Permissions: &Permissions{
|
||||
Http: &HTTPPermission{
|
||||
RequiredHosts: []string{"api.example.com", "*.spotify.com"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
hosts := m.RequiredHTTPHosts()
|
||||
Expect(hosts).To(Equal([]string{"api.example.com", "*.spotify.com"}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("HasExperimentalThreads", func() {
|
||||
It("returns false when no experimental section", func() {
|
||||
m := &Manifest{}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user