Move roles initialization to individual modules

Roles constants were initialized before the configuration file was
parsed. The result was that default values were always used. This commit
moves roles constants initialization to the modules where they are used.

Change-Id: I87406c320e5a403126a9c9c9a258390851f50056
Story: 2002541
Task: 22099
This commit is contained in:
Witold Bedyk 2018-06-13 15:01:26 +02:00
parent 493d36f1ad
commit 8a8f116ec4
7 changed files with 38 additions and 18 deletions

View File

@ -16,7 +16,6 @@
import os
import pkgutil
from oslo_config import cfg
from oslo_log import log
from oslo_utils import importutils
@ -35,13 +34,6 @@ def roles_list_to_check_str(roles_list):
security.register_opts(CONF)
HEALTHCHECK_ROLES = roles_list_to_check_str(cfg.CONF.security.healthcheck_roles)
VERSIONS_ROLES = roles_list_to_check_str(cfg.CONF.security.versions_roles)
DEFAULT_AUTHORIZED_ROLES = roles_list_to_check_str(cfg.CONF.security.default_authorized_roles)
READ_ONLY_AUTHORIZED_ROLES = roles_list_to_check_str(cfg.CONF.security.read_only_authorized_roles)
AGENT_AUTHORIZED_ROLES = roles_list_to_check_str(cfg.CONF.security.agent_authorized_roles)
DELEGATE_AUTHORIZED_ROLES = roles_list_to_check_str(cfg.CONF.security.delegate_authorized_roles)
def load_policy_modules():
"""Load all modules that contain policies.

View File

@ -12,10 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_policy import policy
from monasca_api.policies import DEFAULT_AUTHORIZED_ROLES
from monasca_api.policies import READ_ONLY_AUTHORIZED_ROLES
from monasca_api import policies
CONF = cfg.CONF
DEFAULT_AUTHORIZED_ROLES = policies.roles_list_to_check_str(
cfg.CONF.security.default_authorized_roles)
READ_ONLY_AUTHORIZED_ROLES = policies.roles_list_to_check_str(
cfg.CONF.security.read_only_authorized_roles)
rules = [
policy.DocumentedRuleDefault(

View File

@ -12,9 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_policy import policy
from monasca_api.policies import DELEGATE_AUTHORIZED_ROLES
from monasca_api import policies
DELEGATE_AUTHORIZED_ROLES = policies.roles_list_to_check_str(
cfg.CONF.security.delegate_authorized_roles)
rules = [
policy.RuleDefault(

View File

@ -12,9 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_policy import policy
from monasca_api.policies import HEALTHCHECK_ROLES
from monasca_api import policies
CONF = cfg.CONF
HEALTHCHECK_ROLES = policies.roles_list_to_check_str(cfg.CONF.security.healthcheck_roles)
rules = [
policy.DocumentedRuleDefault(

View File

@ -12,12 +12,17 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_policy import policy
from monasca_api.policies import AGENT_AUTHORIZED_ROLES
from monasca_api.policies import DEFAULT_AUTHORIZED_ROLES
from monasca_api.policies import READ_ONLY_AUTHORIZED_ROLES
from monasca_api import policies
CONF = cfg.CONF
DEFAULT_AUTHORIZED_ROLES = policies.roles_list_to_check_str(
cfg.CONF.security.default_authorized_roles)
READ_ONLY_AUTHORIZED_ROLES = policies.roles_list_to_check_str(
cfg.CONF.security.read_only_authorized_roles)
AGENT_AUTHORIZED_ROLES = policies.roles_list_to_check_str(cfg.CONF.security.agent_authorized_roles)
rules = [
policy.DocumentedRuleDefault(

View File

@ -12,11 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_policy import policy
from monasca_api.policies import DEFAULT_AUTHORIZED_ROLES
from monasca_api.policies import READ_ONLY_AUTHORIZED_ROLES
from monasca_api import policies
CONF = cfg.CONF
DEFAULT_AUTHORIZED_ROLES = policies.roles_list_to_check_str(
cfg.CONF.security.default_authorized_roles)
READ_ONLY_AUTHORIZED_ROLES = policies.roles_list_to_check_str(
cfg.CONF.security.read_only_authorized_roles)
rules = [
policy.DocumentedRuleDefault(

View File

@ -12,9 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_policy import policy
from monasca_api.policies import VERSIONS_ROLES
from monasca_api import policies
CONF = cfg.CONF
VERSIONS_ROLES = policies.roles_list_to_check_str(cfg.CONF.security.versions_roles)
rules = [
policy.DocumentedRuleDefault(