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

Auth: Allow listing unmanaged networks with fine-grained auth #14447

Merged
merged 7 commits into from
Nov 13, 2024

Conversation

markylaing
Copy link
Contributor

Fixes issue where fine-grained authorization was filtering out unmanaged networks (because they aren't in the database). To do this I added a new entitlement at the server level: can_view_unmanaged_networks. Restricted TLS clients are granted this by default to not break existing behaviour.

Opening this now but will mark as draft until I add some tests.

Closes #14085

@markylaing markylaing added the Bug Confirmed to be a bug label Nov 11, 2024
@markylaing markylaing self-assigned this Nov 11, 2024
@github-actions github-actions bot added the Documentation Documentation needs updating label Nov 11, 2024
Copy link

Heads up @mionaalex - the "Documentation" label was applied to this issue.

@markylaing markylaing changed the title Bug fga network list Allow listing unmanaged networks with fine-grained auth Nov 11, 2024
@markylaing markylaing changed the title Allow listing unmanaged networks with fine-grained auth Auth: Allow listing unmanaged networks with fine-grained auth Nov 11, 2024
@markylaing markylaing marked this pull request as ready for review November 12, 2024 08:58
lxd/networks.go Outdated

err = s.DB.Cluster.Transaction(r.Context(), func(ctx context.Context, tx *db.ClusterTx) error {
// Get list of managed networks (that may or may not have network interfaces on the host).
networkNames, err = tx.GetNetworks(ctx, effectiveProjectName)
networks[0], err = tx.GetNetworks(ctx, effectiveProjectName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please can we have local constants for the magic numbers 0 and 1 so we dont end up with hard to read logic like this:

		if !shared.ValueInSlice(iface.Name, networks[0]) {
				networks[1] = append(networks[1], iface.Name)
			}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep sure. I wasn't sure about this either and contemplated using a map but it seemed overkill for something so simple. I'll add some constants.

@tomponline tomponline merged commit 75aea99 into canonical:main Nov 13, 2024
27 checks passed
@tomponline
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed to be a bug Documentation Documentation needs updating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to see non-LXD managed networks for OIDC identity with server admin entitlement
2 participants