[discourse] Limit namespaces display with authz #4326
-
Originally posted by andi4000 on Discourse Hello community, OPA noob here. With following rego policy
I was hoping to only able to see only both namespaces in the UI. But instead all namespaces are displayed ( Is it possible that the unauthorized namespaces not to be displayed in the UI? So the team member can only see the namespaces they own. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Yes, it is possible to limit which namespaces are displayed in the UI using OPA policies in Flipt, but your policy needs to define a Here's an example of how you can structure your Rego policy: package flipt.authz.v1
import rego.v1
default allow := false
# Define which namespaces are viewable for the user
viewable_namespaces := ["default", "my-team"]
allow if {
input.request.namespace in viewable_namespaces
} Or, for more dynamic control (for example, based on user roles): package flipt.authz.v1
import rego.v1
default allow := false
# Example: data.roles_to_namespaces = {"admin": ["default", "my-team"], "user": ["my-team"]}
viewable_namespaces contains namespace if {
some role in input.roles
some namespace in data.roles_to_namespaces[role]
}
allow if {
input.request.namespace in viewable_namespaces
} Flipt's backend will use the If you still see all namespaces, double-check that your policy includes the To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
Reply from erka on Discourse: Hey @andi4000, Unfortunately, it isn’t implemented. Please create an issue in Github about it. |
Beta Was this translation helpful? Give feedback.
-
Reply from andi4000 on Discourse: Got it, will do. Thanks! edit: created the issue here Restrict namespace listing based on user authorization · Issue #3686 · flipt-io/flipt · GitHub |
Beta Was this translation helpful? Give feedback.
Yes, it is possible to limit which namespaces are displayed in the UI using OPA policies in Flipt, but your policy needs to define a
viewable_namespaces
rule. Flipt's authorization engine uses this rule to determine which namespaces a user can see, and the API/UI should only show those namespaces.Here's an example of how you can structure your Rego policy:
Or, for more dynamic control (for example, based on user roles):