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

Filter network integration config keys #667

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion cmd/incusd/api_1.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ func doApi10UpdateTriggers(d *Daemon, nodeChanged, clusterChanged map[string]str
case "network.ovn.northbound_connection", "network.ovn.ca_cert", "network.ovn.client_cert", "network.ovn.client_key":
ovnChanged = true

case "oidc.issuer", "oidc.client.id", "oidc.audience":
case "oidc.issuer", "oidc.client.id", "oidc.audience", "oidc.claim":
oidcChanged = true

case "openfga.api.url", "openfga.api.token", "openfga.store.id":
Expand Down
12 changes: 12 additions & 0 deletions cmd/incusd/network_integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ func networkIntegrationsGet(d *Daemon, r *http.Request) response.Response {
return err
}

// Check if the user should see the configuration.
err = s.Authorizer.CheckPermission(r.Context(), r, auth.ObjectNetworkIntegration(result.Name), auth.EntitlementCanEdit)
if err != nil {
result.Config = map[string]string{}
}

// Add UsedBy field.
usedBy, err := tx.GetNetworkPeersURLByIntegration(ctx, integration.Name)
if err != nil {
Expand Down Expand Up @@ -428,6 +434,12 @@ func networkIntegrationGet(d *Daemon, r *http.Request) response.Response {
return err
}

// Check if the user should see the configuration.
err = s.Authorizer.CheckPermission(r.Context(), r, auth.ObjectNetworkIntegration(info.Name), auth.EntitlementCanEdit)
if err != nil {
info.Config = map[string]string{}
}

// Add UsedBy field.
usedBy, err := tx.GetNetworkPeersURLByIntegration(ctx, info.Name)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions test/suites/openfga.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ test_openfga() {
incus config set openfga.api.token "$(fga_token)"
incus config set openfga.store.id "${OPENFGA_STORE_ID}"

# Wait for initial connection to OpenFGA.
sleep 1s

echo "==> Checking permissions for unknown user..."
user_is_not_server_admin
user_is_not_server_operator
Expand Down
Loading