Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit a8fb6ba

Browse files
committed
Allow relative paths in configuration to be made absolute.
Bumped version.
1 parent f4e2c63 commit a8fb6ba

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

src/oidcrp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from oidcrp import provider
2929

3030
__author__ = 'Roland Hedberg'
31-
__version__ = '0.8.0'
31+
__version__ = '0.8.1'
3232

3333
logger = logging.getLogger(__name__)
3434

src/oidcrp/configure.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""Configuration management for RP"""
2-
2+
import os
33
from typing import Dict
4+
from typing import Optional
5+
6+
from oidcmsg import add_base_path
47

58
from oidcrp.logging import configure_logging
69
from oidcrp.util import get_http_params
@@ -15,10 +18,35 @@
1518
from oidcendpoint import rndstr as rnd_token
1619

1720

21+
DEFAULT_ITEM_PATHS = {
22+
"webserver": ['server_key', 'server_cert'],
23+
"rp_keys": ["public_path", "private_path"],
24+
"oidc_keys": ["public_path", "private_path"],
25+
"httpc_params": ["client_cert", "client_key"],
26+
"db_conf": {
27+
"keyjar": ["fdir"],
28+
"default": ["fdir"],
29+
"state": ["fdir"]
30+
},
31+
"logging": {
32+
"handlers": {
33+
"file": ["filename"]
34+
}
35+
}
36+
}
37+
38+
1839
class Configuration:
1940
"""RP Configuration"""
2041

21-
def __init__(self, conf: Dict) -> None:
42+
def __init__(self, conf: Dict, base_path: str = '', item_paths: Optional[dict] = None) -> None:
43+
if item_paths is None:
44+
item_paths = DEFAULT_ITEM_PATHS
45+
46+
if base_path and item_paths:
47+
# this adds a base path to all paths in the configuration
48+
add_base_path(conf, item_paths, base_path)
49+
2250
self.logger = configure_logging(config=conf.get('logging')).getChild(__name__)
2351

2452
# server info
@@ -49,6 +77,7 @@ def __init__(self, conf: Dict) -> None:
4977
rp_keys_conf = lower_or_upper(conf, 'rp_keys')
5078
if rp_keys_conf is None:
5179
rp_keys_conf = lower_or_upper(conf, 'oidc_keys')
80+
5281
setattr(self, "rp_keys", rp_keys_conf)
5382

5483
_clients = lower_or_upper(conf, "clients")
@@ -75,6 +104,6 @@ def load_extension(self, conf):
75104
pass
76105

77106
@classmethod
78-
def create_from_config_file(cls, filename: str):
107+
def create_from_config_file(cls, filename: str, base_path: str = ''):
79108
"""Load configuration as YAML"""
80-
return cls(load_yaml_config(filename))
109+
return cls(load_yaml_config(filename), base_path)

0 commit comments

Comments
 (0)