1616from pyop .exceptions import (InvalidAuthenticationRequest , InvalidClientRegistrationRequest ,
1717 InvalidClientAuthentication , OAuthError , BearerTokenError , InvalidAccessToken )
1818from pyop .provider import Provider
19- from pyop .storage import MongoWrapper
19+ from pyop .storage import StorageBase
2020from pyop .subject_identifier import HashBasedSubjectIdentifierFactory
2121from pyop .userinfo import Userinfo
2222from pyop .util import should_fragment_encode
@@ -80,13 +80,22 @@ def _create_provider(self, endpoint_baseurl):
8080 client_db_uri = self .config .get ("client_db_uri" )
8181 cdb_file = self .config .get ("client_db_path" )
8282 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+ )
8486 elif cdb_file :
8587 with open (cdb_file ) as f :
8688 cdb = json .loads (f .read ())
8789 else :
8890 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+
9099 self .provider = Provider (
91100 self .signing_key ,
92101 capabilities ,
@@ -101,10 +110,22 @@ def _init_authorization_state(self):
101110 sub_hash_salt = self .config .get ("sub_hash_salt" , rndstr (16 ))
102111 db_uri = self .config .get ("db_uri" )
103112 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?
108129 else :
109130 authz_code_db = None
110131 access_token_db = None
0 commit comments