16
16
from pyop .exceptions import (InvalidAuthenticationRequest , InvalidClientRegistrationRequest ,
17
17
InvalidClientAuthentication , OAuthError , BearerTokenError , InvalidAccessToken )
18
18
from pyop .provider import Provider
19
- from pyop .storage import MongoWrapper
19
+ from pyop .storage import StorageBase
20
20
from pyop .subject_identifier import HashBasedSubjectIdentifierFactory
21
21
from pyop .userinfo import Userinfo
22
22
from pyop .util import should_fragment_encode
@@ -80,13 +80,22 @@ def _create_provider(self, endpoint_baseurl):
80
80
client_db_uri = self .config .get ("client_db_uri" )
81
81
cdb_file = self .config .get ("client_db_path" )
82
82
if client_db_uri :
83
- cdb = MongoWrapper (client_db_uri , "satosa" , "clients" )
83
+ cdb = StorageBase .from_uri (
84
+ client_db_uri , db_name = "satosa" , collection = "clients"
85
+ )
84
86
elif cdb_file :
85
87
with open (cdb_file ) as f :
86
88
cdb = json .loads (f .read ())
87
89
else :
88
90
cdb = {}
89
- self .user_db = MongoWrapper (db_uri , "satosa" , "authz_codes" ) if db_uri else {}
91
+
92
+ self .user_db = (
93
+ StorageBase .from_uri (db_uri , db_name = "satosa" , collection = "authz_codes" )
94
+ if db_uri
95
+ else {}
96
+ )
97
+ #XXX What is the correct ttl for user_db? Is it the same as authz_code_db?
98
+
90
99
self .provider = Provider (
91
100
self .signing_key ,
92
101
capabilities ,
@@ -101,10 +110,22 @@ def _init_authorization_state(self):
101
110
sub_hash_salt = self .config .get ("sub_hash_salt" , rndstr (16 ))
102
111
db_uri = self .config .get ("db_uri" )
103
112
if db_uri :
104
- authz_code_db = MongoWrapper (db_uri , "satosa" , "authz_codes" )
105
- access_token_db = MongoWrapper (db_uri , "satosa" , "access_tokens" )
106
- refresh_token_db = MongoWrapper (db_uri , "satosa" , "refresh_tokens" )
107
- sub_db = MongoWrapper (db_uri , "satosa" , "subject_identifiers" )
113
+ authz_code_db = StorageBase .from_uri (
114
+ db_uri , db_name = "satosa" , collection = "authz_codes" ,
115
+ )
116
+ authz_code_db .ttl = self .config ["provider" ].get ("authorization_code_lifetime" , 600 )
117
+ access_token_db = StorageBase .from_uri (
118
+ db_uri , db_name = "satosa" , collection = "access_tokens"
119
+ )
120
+ access_token_db .ttl = self .config ["provider" ].get ("access_token_lifetime" , 3600 )
121
+ refresh_token_db = StorageBase .from_uri (
122
+ db_uri , db_name = "satosa" , collection = "refresh_tokens"
123
+ )
124
+ refresh_token_db .ttl = self .config ["provider" ].get ("refresh_token_lifetime" , None )
125
+ sub_db = StorageBase .from_uri (
126
+ db_uri , db_name = "satosa" , collection = "subject_identifiers"
127
+ )
128
+ #XXX what is the correct TTL for sub_db?
108
129
else :
109
130
authz_code_db = None
110
131
access_token_db = None
0 commit comments