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

Commit 37e9943

Browse files
authored
Merge pull request #22 from peppelinux/master
Custom DB configuration
2 parents 0947b5c + b7fb886 commit 37e9943

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/oidcendpoint/client_authn.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ def verify_client(
244244
_token = auth_info.get("token")
245245

246246
if client_id:
247-
248247
if not client_id in endpoint_context.cdb:
249248
raise ValueError("Unknown Client ID")
250249

src/oidcendpoint/endpoint_context.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from oidcendpoint import authz
1212
from oidcendpoint import rndstr
13-
from oidcendpoint import util
1413
from oidcendpoint.client_authn import CLIENT_AUTHN_METHOD
1514
from oidcendpoint.id_token import IDToken
1615
from oidcendpoint.session import create_session_db
@@ -44,7 +43,7 @@ def init_user_info(conf, cwd):
4443
kwargs["db_file"] = os.path.join(cwd, kwargs["db_file"])
4544

4645
if isinstance(conf["class"], str):
47-
return util.importer(conf["class"])(**kwargs)
46+
return importer(conf["class"])(**kwargs)
4847

4948
return conf["class"](**kwargs)
5049

@@ -56,7 +55,7 @@ def init_service(conf, endpoint_context=None):
5655
kwargs["endpoint_context"] = endpoint_context
5756

5857
if isinstance(conf["class"], str):
59-
return util.importer(conf["class"])(**kwargs)
58+
return importer(conf["class"])(**kwargs)
6059

6160
return conf["class"](**kwargs)
6261

@@ -126,14 +125,19 @@ def __init__(
126125
# arguments for endpoints add-ons
127126
self.args = {}
128127

128+
self.th_args = get_token_handlers(conf)
129+
129130
# client database
130131
self.cdb = client_db or {}
131132

132133
# session db
133134
self._sub_func = {}
134135
self.do_sub_func()
135-
self.sdb = session_db
136-
if not self.sdb:
136+
137+
# set self.sdb
138+
if session_db:
139+
self.set_session_db(conf, sso_db, db=session_db)
140+
else:
137141
self.set_session_db(conf, sso_db)
138142

139143
self.scope2claims = SCOPE2CLAIMS
@@ -284,14 +288,13 @@ def do_sub_func(self):
284288
self._sub_func[key] = init_service(args)
285289
elif "function" in args:
286290
if isinstance(args["function"], str):
287-
self._sub_func[key] = util.importer(args["function"])
291+
self._sub_func[key] = importer(args["function"])
288292
else:
289293
self._sub_func[key] = args["function"]
290294

291295
def do_session_db(self, conf, sso_db, db=None):
292-
th_args = get_token_handlers(conf)
293296
self.sdb = create_session_db(
294-
self, th_args, db=db,
297+
self, self.th_args, db=db,
295298
sso_db=sso_db,
296299
sub_func=self._sub_func
297300
)

src/oidcendpoint/oidc/authorization.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ def get_uri(endpoint_context, request, uri_type):
191191
verify_uri(endpoint_context, request, uri_type)
192192
uri = request[uri_type]
193193
else:
194-
195194
uris = "{}s".format(uri_type)
196195
client_id = str(request["client_id"])
197196
if client_id in endpoint_context.cdb:

src/oidcendpoint/session.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def dict_match(a, b):
118118

119119

120120
class SessionDB(object):
121-
def __init__(self, db, handler, sso_db, userinfo=None, sub_func=None):
121+
def __init__(self, db, handler, sso_db=SSODb(), userinfo=None, sub_func=None):
122122
# db must implement the InMemoryDataBase interface
123123
self._db = db
124124
self.handler = handler
@@ -568,10 +568,9 @@ def get_authentication_event(self, sid):
568568

569569

570570
def create_session_db(ec, token_handler_args, db=None,
571-
sso_db=SSODb(), sub_func=None):
571+
sso_db=None, sub_func=None):
572572
_token_handler = token_handler.factory(ec, **token_handler_args)
573573

574-
if not db:
575-
db = InMemoryDataBase()
576-
574+
db = db or InMemoryDataBase()
575+
sso_db = sso_db or SSODb()
577576
return SessionDB(db, _token_handler, sso_db, sub_func=sub_func)

0 commit comments

Comments
 (0)