MCPcopy Create free account
hub / github.com/StackStorm/st2 / validate_rbac_is_correctly_configured

Function validate_rbac_is_correctly_configured

st2api/st2api/validation.py:69–102  ·  view source on GitHub ↗

Function which verifies that RBAC is correctly set up and configured.

()

Source from the content-addressed store, hash-verified

67
68
69def validate_rbac_is_correctly_configured() -> bool:
70 """
71 Function which verifies that RBAC is correctly set up and configured.
72 """
73 if not cfg.CONF.rbac.enable:
74 return True
75
76 from st2common.rbac.backends import get_available_backends
77
78 available_rbac_backends = get_available_backends()
79
80 # 1. Verify auth is enabled
81 if not cfg.CONF.auth.enable:
82 msg = (
83 "Authentication is not enabled. RBAC only works when authentication is enabled. "
84 "You can either enable authentication or disable RBAC."
85 )
86 raise ValueError(msg)
87
88 # 2. Verify default backend is set
89 if cfg.CONF.rbac.backend != "default":
90 msg = (
91 'You have enabled RBAC, but RBAC backend is not set to "default". '
92 "For RBAC to work, you need to set "
93 '"rbac.backend" config option to "default" and restart st2api service.'
94 )
95 raise ValueError(msg)
96
97 # 3. Verify default RBAC backend is available
98 if "default" not in available_rbac_backends:
99 msg = '"default" RBAC backend is not available.'
100 raise ValueError(msg)
101
102 return True

Calls 1

get_available_backendsFunction · 0.90