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) -> 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)
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") 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)
def __init__( self, conf: Dict, base_path: Optional[str] = '', entity_conf: Optional[List[dict]] = None, domain: Optional[str] = "127.0.0.1", port: Optional[int] = 80, file_attributes: Optional[List[str]] = None, dir_attributes: Optional[List[str]] = None, ): Base.__init__(self, conf, base_path=base_path, domain=domain, port=port, file_attributes=file_attributes, dir_attributes=dir_attributes) self.key_conf = lower_or_upper(conf, 'rp_keys') or lower_or_upper( conf, 'oidc_keys') self.clients = lower_or_upper(conf, "clients") hash_seed = lower_or_upper(conf, 'hash_seed') if not hash_seed: hash_seed = rnd_token(32) self.hash_seed = hash_seed self.services = lower_or_upper(conf, "services") self.base_url = lower_or_upper(conf, "base_url") self.httpc_params = lower_or_upper(conf, "httpc_params", {"verify": True}) if entity_conf: self.extend(entity_conf=entity_conf, conf=conf, base_path=base_path, file_attributes=file_attributes, domain=domain, port=port)
try: from .views import intermediate except ImportError: from views import intermediate app.register_blueprint(intermediate) # Initialize the oidc_provider after views to be able to set correct urls app.server = init_entity(app.srv_config.federation, dir_path) return app if __name__ == "__main__": name = sys.argv[1] conf = sys.argv[2] template_dir = os.path.join(dir_path, 'templates') app = init_app(conf, name, template_folder=template_dir) _web_conf = app.srv_config.web_conf context = create_context(dir_path, _web_conf) _cert = "{}/{}".format(dir_path, lower_or_upper(_web_conf, "server_cert")) print('Listening on {}:{}'.format(_web_conf.get('domain'), _web_conf.get('port'))) # app.rph.federation_entity.collector.web_cert_path = _cert app.run(host=_web_conf.get('domain'), port=_web_conf.get('port'), debug=_web_conf.get("debug"), ssl_context=context)