Skip to content

Commit 2d26564

Browse files
authored
Merge pull request #2 from IdentityPython/develop
Cleaning up after refactoring. Adjustments to Configure.
2 parents 17443dc + 804af5b commit 2d26564

File tree

9 files changed

+56
-21
lines changed

9 files changed

+56
-21
lines changed

.github/workflows/python-app.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- '3.7'
2222
- '3.8'
2323
- '3.9'
24+
- '3.10'
2425

2526
steps:
2627
- uses: actions/checkout@v2

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
Implementation of everything OIDC and OAuth2.
1010

11-
idpyoidc is the 2nd layer in the
12-
JwtConnect stack (cryptojwt, idpyoidc)
11+
idpyoidc is the 2nd layer in the JwtConnect stack (cryptojwt, idpyoidc)
1312

1413
Please read the [Official Documentation](https://idpyoidc.readthedocs.io/) for getting usage examples and further informations.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[metadata]
99
name = "idpyoidc"
10-
version = "1.0.0"
10+
version = "1.0.1"
1111
author = "Roland Hedberg"
1212
author_email = "[email protected]"
1313
description = "Everything OAuth2 and OIDC"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run_tests(self):
5050
setup(
5151
name="idpyoidc",
5252
version=version,
53-
description="Python implementation of OAuth2 and OpenID Connect messages",
53+
description="Python implementation of everything OAuth2 and OpenID Connect",
5454
long_description=README,
5555
long_description_content_type='text/markdown',
5656
author="Roland Hedberg",

src/idpyoidc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "Roland Hedberg"
2-
__version__ = "1.0.0"
2+
__version__ = "1.0.1"
33

44
import os
55
from typing import Dict

src/idpyoidc/configure.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Dict
44
from typing import List
55
from typing import Optional
6+
from typing import Union
67

78
from idpyoidc.logging import configure_logging
89
from idpyoidc.util import load_config_file
@@ -38,6 +39,9 @@ def add_path_to_directory_name(directory_name, base_path):
3839

3940
def add_base_path(conf: dict, base_path: str, attributes: List[str], attribute_type: str = "file"):
4041
for key, val in conf.items():
42+
if not val:
43+
continue
44+
4145
if key in attributes:
4246
if attribute_type == "file":
4347
conf[key] = add_path_to_filename(val, base_path)
@@ -168,7 +172,7 @@ def complete_paths(self, conf: Dict, keys: List[str], default_config: Dict, base
168172

169173
def format(self, conf, base_path: str, domain: str, port: int,
170174
file_attributes: Optional[List[str]] = None,
171-
dir_attributes: Optional[List[str]] = None) -> None:
175+
dir_attributes: Optional[List[str]] = None) -> Union[Dict, str]:
172176
"""
173177
Formats parts of the configuration. That includes replacing the strings {domain} and {port}
174178
with the used domain and port and making references to files and directories absolute
@@ -183,11 +187,17 @@ def format(self, conf, base_path: str, domain: str, port: int,
183187
"""
184188
if isinstance(conf, dict):
185189
if file_attributes:
186-
add_base_path(conf, base_path, file_attributes, attribute_type="file")
190+
conf = add_base_path(conf, base_path, file_attributes, attribute_type="file")
187191
if dir_attributes:
188-
add_base_path(conf, base_path, dir_attributes, attribute_type="dir")
192+
conf = add_base_path(conf, base_path, dir_attributes, attribute_type="dir")
189193
if isinstance(conf, dict):
190-
set_domain_and_port(conf, domain=domain, port=port)
194+
conf = set_domain_and_port(conf, domain=domain, port=port)
195+
elif isinstance(conf, list):
196+
conf = [_conv(v, domain=domain, port=port) for v in conf]
197+
elif isinstance(conf, str):
198+
conf = _conv(conf, domain, port)
199+
200+
return conf
191201

192202

193203
class Configuration(Base):
@@ -215,10 +225,24 @@ def __init__(self,
215225
self.web_conf = lower_or_upper(self.conf, "webserver")
216226

217227
if entity_conf:
228+
skip = [ec["path"] for ec in entity_conf if 'path' in ec]
229+
check = [l[0] for l in skip]
230+
218231
self.extend(conf=self.conf, base_path=base_path,
219232
domain=self.domain, port=self.port, entity_conf=entity_conf,
220233
file_attributes=self._file_attributes,
221234
dir_attributes=self._dir_attributes)
235+
for key, val in conf.items():
236+
if key in ["logging", "webserver", "domain", "port"]:
237+
continue
238+
239+
if key in check:
240+
continue
241+
242+
setattr(self, key, val)
243+
else:
244+
for key, val in conf.items():
245+
setattr(self, key, val)
222246

223247

224248
def create_from_config_file(cls,

src/idpyoidc/server/configure.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class EntityConfiguration(Base):
149149
"endpoint": {},
150150
"httpc_params": {},
151151
"issuer": "",
152-
"keys": None,
152+
"key_conf": None,
153153
"session_params": None,
154154
"template_dir": None,
155155
"token_handler_args": {},
@@ -168,17 +168,17 @@ def __init__(
168168
):
169169

170170
conf = copy.deepcopy(conf)
171-
Base.__init__(self, conf, base_path, file_attributes, dir_attributes=dir_attributes)
171+
Base.__init__(self, conf, base_path, file_attributes=file_attributes,
172+
dir_attributes=dir_attributes, domain=domain, port=port)
172173

173-
self.key_conf = conf.get('key_conf')
174+
self.key_conf = conf.get('key_conf', conf.get('keys'))
174175

175176
for key in self.parameter.keys():
176177
_val = conf.get(key)
177178
if not _val:
178179
if key in self.default_config:
179-
_val = copy.deepcopy(self.default_config[key])
180-
self.format(
181-
_val,
180+
_val = self.format(
181+
copy.deepcopy(self.default_config[key]),
182182
base_path=base_path,
183183
file_attributes=file_attributes,
184184
domain=domain,
@@ -189,7 +189,7 @@ def __init__(
189189
continue
190190

191191
if key not in DEFAULT_EXTENDED_CONF:
192-
logger.warning(f"{key} not seems to be a valid configuration parameter")
192+
logger.warning(f"{key} does not seems to be a valid configuration parameter")
193193
elif not _val:
194194
logger.warning(f"{key} not configured, using default configuration values")
195195

@@ -334,6 +334,10 @@ def __init__(
334334
"refresh_token",
335335
],
336336
},
337+
"claims_interface": {
338+
"class": "idpyoidc.server.session.claims.ClaimsInterface",
339+
"kwargs": {}
340+
},
337341
"cookie_handler": {
338342
"class": "idpyoidc.server.cookie_handler.CookieHandler",
339343
"kwargs": {
@@ -462,7 +466,9 @@ def __init__(
462466
"jwks_def": {
463467
"private_path": "private/token_jwks.json",
464468
"read_only": False,
465-
"key_defs": [{"type": "oct", "bytes": "24", "use": ["enc"], "kid": "code"}],
469+
"key_defs": [
470+
{"type": "oct", "bytes": "24", "use": ["enc"], "kid": "code"}
471+
],
466472
},
467473
"code": {"kwargs": {"lifetime": 600}},
468474
"token": {

tests/test_server_00_configure.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import json
22
import os
33

4-
import pytest
5-
64
from idpyoidc.configure import Configuration
75
from idpyoidc.configure import create_from_config_file
86
from idpyoidc.logging import configure_logging
97
from idpyoidc.server.configure import OPConfiguration
8+
import pytest
109

1110
BASEDIR = os.path.abspath(os.path.dirname(__file__))
1211

@@ -99,7 +98,13 @@ def test_op_configure_default_from_file():
9998
def test_server_configure():
10099
configuration = create_from_config_file(
101100
Configuration,
102-
entity_conf=[{"class": OPConfiguration, "attr": "op", "path": ["op", "server_info"]}],
101+
entity_conf=[
102+
{
103+
"class": OPConfiguration,
104+
"attr": "op",
105+
"path": ["op", "server_info"]
106+
}
107+
],
103108
filename=full_path("srv_config.json"),
104109
base_path=BASEDIR,
105110
)

tests/test_server_20a_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_capabilities_default():
111111
"code id_token token",
112112
}
113113
assert server.endpoint_context.provider_info["request_uri_parameter_supported"] is True
114-
assert server.endpoint_context.jwks_uri == 'https://127.0.0.1:80/static/jwks.json'
114+
assert server.endpoint_context.jwks_uri == 'https://127.0.0.1:443/static/jwks.json'
115115

116116

117117
def test_capabilities_subset1():

0 commit comments

Comments
 (0)