Ejemplo n.º 1
0
    def __init__(self, conf: Dict) -> None:
        self.logger = configure_logging(
            config=conf.get('logging')).getChild(__name__)

        # server info
        self.domain = lower_or_upper(conf, "domain")
        self.port = lower_or_upper(conf, "port")

        # HTTP params
        _params = get_http_params(conf.get("httpc_params"))
        if _params:
            self.httpc_params = _params
        else:
            _params = {'verify', lower_or_upper(conf, "verify_ssl", True)}

        # web server config
        self.web_conf = lower_or_upper(conf, "webserver")

        srv_info = lower_or_upper(conf, "server_info", {})
        for entity, spec in srv_info.items():
            for key, arg in spec.items():
                if key == "kwargs":
                    _kw_args = {}
                    for attr, val in arg.items():
                        if attr in ["entity_id_pattern", "url_prefix"]:
                            _kw_args[attr] = val.format(domain=self.domain,
                                                        port=self.port)
                        else:
                            _kw_args[attr] = val

                    spec["kwargs"] = _kw_args

        self.server_info = srv_info
    def __init__(
        self,
        conf: Dict,
        base_path: str = '',
        entity_conf: Optional[List[dict]] = None,
        file_attributes: Optional[List[str]] = None,
        domain: Optional[str] = "",
        port: Optional[int] = 0,
        dir_attributes: Optional[List[str]] = None,
    ):
        Base.__init__(self,
                      conf,
                      base_path=base_path,
                      file_attributes=file_attributes,
                      dir_attributes=dir_attributes)

        log_conf = conf.get('logging')
        if log_conf:
            self.logger = configure_logging(config=log_conf).getChild(__name__)
        else:
            self.logger = logging.getLogger('oidcrp')

        self.web_conf = lower_or_upper(conf, "webserver")

        if entity_conf:
            self.extend(entity_conf=entity_conf,
                        conf=conf,
                        base_path=base_path,
                        file_attributes=file_attributes,
                        domain=domain,
                        port=port,
                        dir_attributes=dir_attributes)
    def __init__(self, conf: Dict) -> None:
        self.logger = configure_logging(config=conf.get('logging')).getChild(__name__)

        # server info
        self.domain = lower_or_upper(conf, "domain")
        self.port = lower_or_upper(conf, "port")
        for param in ["server_name", "base_url"]:
            _pre = lower_or_upper(conf, param)
            if _pre:
                if '{domain}' in _pre:
                    setattr(self, param, _pre.format(domain=self.domain, port=self.port))
                else:
                    setattr(self, param, _pre)

        # HTTP params
        _params = get_http_params(conf.get("http_params"))
        if _params:
            self.httpc_params = _params
        else:
            _params = {'verify', lower_or_upper(conf, "verify_ssl", True)}

        self.web_conf = lower_or_upper(conf, "webserver")

        # diverse
        for param in ["html_home", "session_cookie_name", "preferred_url_scheme",
                      "services", "federation"]:
            setattr(self, param, lower_or_upper(conf, param))

        rp_keys_conf = lower_or_upper(conf, 'rp_keys')
        if rp_keys_conf is None:
            rp_keys_conf = lower_or_upper(conf, 'oidc_keys')
        setattr(self, "rp_keys", rp_keys_conf)

        _clients = lower_or_upper(conf, "clients")
        for key, spec in _clients.items():
            if key == "":
                continue
            if not spec.get("redirect_uris"):
                continue

            _redirects = []
            for _r in spec["redirect_uris"]:
                if '{domain}' in _r:
                    _redirects.append(_r.format(domain=self.domain, port=self.port))
                else:
                    _redirects.append(_r)
            spec["redirect_uris"] = _redirects

        setattr(self, "clients", _clients)

        hash_seed = lower_or_upper(conf, 'hash_seed')
        if not hash_seed:
            hash_seed = rnd_token(32)
        setattr(self, "hash_seed", hash_seed)
Ejemplo n.º 4
0
    def __init__(self, conf: Dict) -> None:
        self.logger = configure_logging(config=conf.get('logging')).getChild(__name__)

        # server info
        self.domain = lower_or_upper(conf, "domain")
        self.port = lower_or_upper(conf, "port")
        if self.port:
            format_args = {'domain': self.domain, 'port': self.port}
        else:
            format_args = {'domain': self.domain, "port": ""}

        for param in ["server_name", "base_url"]:
            set_param(self, conf, param, **format_args)

        # HTTP params
        _params = get_http_params(conf.get("httpc_params"))
        if _params:
            self.httpc_params = _params
        else:
            _params = {'verify', lower_or_upper(conf, "verify_ssl", True)}

        self.web_conf = lower_or_upper(conf, "webserver")

        # diverse
        for param in ["html_home", "session_cookie_name", "preferred_url_scheme",
                      "services", "federation"]:
            set_param(self, conf, param)

        rp_keys_conf = lower_or_upper(conf, 'rp_keys')
        if rp_keys_conf is None:
            rp_keys_conf = lower_or_upper(conf, 'oidc_keys')
        setattr(self, "rp_keys", rp_keys_conf)

        _clients = lower_or_upper(conf, "clients")
        if _clients:
            for key, spec in _clients.items():
                if key == "":
                    continue
                # if not spec.get("redirect_uris"):
                #     continue

                for uri in ['redirect_uris', 'post_logout_redirect_uris', 'frontchannel_logout_uri',
                            'backchannel_logout_uri', 'issuer']:
                    replace(spec, uri, **format_args)

            setattr(self, "clients", _clients)

        hash_seed = lower_or_upper(conf, 'hash_seed')
        if not hash_seed:
            hash_seed = rnd_token(32)
        setattr(self, "hash_seed", hash_seed)
        self.load_extension(conf)