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

Commit 10058ed

Browse files
authored
Merge pull request #114 from nsklikas/fix-client-session
Don't create a new client session every time
2 parents ec7b7d2 + 7ca060d commit 10058ed

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/oidcop/session/manager.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from oidcop.exception import ConfigurationError
1313
from oidcop.token import handler
1414
from oidcop.util import Crypt
15+
from oidcop.session.database import NoSuchClientSession
1516
from .database import Database
1617
from .grant import Grant
1718
from .grant import SessionToken
@@ -226,9 +227,11 @@ def create_session(
226227
if not client_id:
227228
client_id = auth_req["client_id"]
228229

229-
client_info = ClientSessionInfo(client_id=client_id)
230-
231-
self.set([user_id, client_id], client_info)
230+
try:
231+
self.get([user_id, client_id])
232+
except (NoSuchClientSession, ValueError):
233+
client_info = ClientSessionInfo(client_id=client_id)
234+
self.set([user_id, client_id], client_info)
232235

233236
return self.create_grant(
234237
auth_req=auth_req,

tests/test_34_oidc_sso.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,4 @@ def test_sso(self):
255255

256256
assert len(csi1.subordinate) == 2
257257
assert len(csi2.subordinate) == 1
258-
assert len(csi3.subordinate) == 1
258+
assert len(csi3.subordinate) == 2

0 commit comments

Comments
 (0)