mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-07 04:53:24 -05:00
feat(connectors): enforce add-on permissions on each connector turn
The capabilities, role grants and pairing that a connector binding
stores now decide what a sender can make the agent do.
Authorize is one pure function: the capability must be in the owner's
ceiling for the binding and the sender must be on the allowlist. A
sensitive capability then needs a paired sender; roles never count for
it. Any other capability needs a pairing or a role that the owner
granted and that the kind lists. The default is no.
Each message gets a grant for its sender. A message that joins a
running turn narrows it to what both senders may do. The tool builder
offers a gated tool only for a held capability, and the tool checks
again when the model calls it, so a call that gets through is refused
with the reason. Today this covers propose_change (memory and profile
kinds), revert_change, the trigger tools, and files sent to the bot. A
chat worker gets the grant with the start request.
The capability gate that the trigger features ask is now answered by
Authorize, and the application sets it. Other features can add a
global switch with AddCapabilitySwitch.
Every use records an allow or deny row (time, binding, sender IDs,
roles, capability, result; no text or codes). GET
/api/chats/connectors/{id}/access returns the effective permissions
per kind of sender and the latest rows, for an add-on settings page.
A binding saved before this change has no capabilities, so its senders
lose these features until the owner enables them.
Assisted-by: Claude:claude-sonnet-5-5 go swag
This commit is contained in:
179 files changed
+2248
-7917
No files matched your search
@@ -1,35 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Command github is the executable of the GitHub add-on. It reads repositories
|
||||
// for the chats and the agents with a token that the host keeps for the person
|
||||
// and hands over with each call. The add-on stores no token and writes nothing
|
||||
// to GitHub.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/mudler/LocalAI/addons/github/internal/ghapi"
|
||||
"github.com/mudler/LocalAI/addons/github/internal/platform"
|
||||
"github.com/mudler/LocalAI/addons/github/internal/tools"
|
||||
"github.com/mudler/LocalAI/addons/internal/connector"
|
||||
"github.com/mudler/LocalAI/addons/internal/protocol"
|
||||
"github.com/mudler/LocalAI/pkg/addons/contract"
|
||||
)
|
||||
|
||||
type runtime struct {
|
||||
*tools.Runtime
|
||||
platform platform.Platform
|
||||
}
|
||||
|
||||
func (r runtime) Connector(ctx context.Context, req contract.ConnectorRequest) (contract.ConnectorResponse, error) {
|
||||
return connector.Serve(ctx, r.platform, req)
|
||||
}
|
||||
|
||||
func main() {
|
||||
os.Exit(protocol.Run(os.Args, func(protocol.Startup) contract.Runtime {
|
||||
api := ghapi.New()
|
||||
return runtime{Runtime: tools.New(api), platform: platform.Platform{API: api}}
|
||||
}))
|
||||
}
|
||||
Reference in new issue
Block a user