-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
persistent Session DB storage #435
Comments
Hi @taskoma, you need to adapt the SessionDB to use a data store of your choice underneath. This is really unfortunate to not have inside the library and there is some talk between maintainers about providing a pre-built persistent sessionDB store. We didn't get there yet. I've written a Redis one, so can provide portable code for that - which data store will you choose? |
redis is good choice, if you can share you code it will help a lot :) |
OK, let's see now, here's what I had: class RedisSessionDB(dict):
"""Dict interface for Redis session management."""
def __init__(self, connection):
self.connection = connection
def keys(self):
return self.connection.keys()
def flushall(self):
self.connection.flushall()
def __getitem__(self, key):
value = self.connection.get(key)
if value is None:
raise KeyError(key)
utf8ified = str(value, "utf-8")
return json.loads(utf8ified)
def __setitem__(self, key, value):
value = json.dumps(value)
self.connection.set(key, value)
def __contains__(self, item):
return self.connection.exists(item)
def __delitem__(self, key):
self.connection.delete(key) Let me know if that works! |
@lwm thanks a lot, may be you can share example of using you code? |
No worries, it looks like I did: connection = Redis(host=host, port=port, db=db_num)
redis_db = RedisSessionDB(connection)
session_db = SessionDB("", db=redis_db)
Provider(
issuer,
session_db, # passed in here!
client_db,
auth_broker,
user_info_store,
authz_handler,
verification_function,
) |
this is result of outdated source? I use source base that fetched before " [#387]: Refactored the |
Perhaps, although we have made frequent releases. You can try latest HEAD as well. If you provide more information, perhaps raise another issue with the problem. |
Yes, AuthnEvent wasn't json serializable in older versions. Update. |
@lwm finally I migrated to current version of codebase but anyway something go wrong
in logs for user_info:
in logs
api response:
and response for new acess_token
|
answers
|
Good day,
for now SessionDB in-memory solution, this mean that after application restart all "authorized" users flush and need again pass authorization.
What is right way to support persistent storage? Or maybe there are any "ready to use" solutions?
The text was updated successfully, but these errors were encountered: