Giter Club home page Giter Club logo

flask-cookie-decode's People

Contributors

wgwz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

psidney

flask-cookie-decode's Issues

total_seconds is missing from flask.helpers on recent flask/python setups

  • flask-cookie-decode version: 0.3.2
  • Python version: 3.10.11
  • Operating System: Docker/Linux
  • Flask: 2.3.2

Description

It seems on recent flask/python setups the total_seconds is missing from flask.helpers

What I Did

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.10/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.10/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.10/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.10/site-packages/gunicorn/util.py", line 359, in import_app
    mod = importlib.import_module(module)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/theapp/run.py", line 1, in <module>
    from theapp import create_app
  File "/theapp/theapp/__init__.py", line 42, in <module>
    from flask_cookie_decode import CookieDecode
  File "/usr/local/lib/python3.10/site-packages/flask_cookie_decode/__init__.py", line 19, in <module>
    from .cookie_decode import CookieDecode
  File "/usr/local/lib/python3.10/site-packages/flask_cookie_decode/cookie_decode.py", line 8, in <module>
    from flask.helpers import total_seconds
ImportError: cannot import name 'total_seconds' from 'flask.helpers' (/usr/local/lib/python3.10/site-packages/flask/helpers.py)

fcd CLI read cookie from browser and decode command

one feature that would be kind of interesting is if the fcd CLI could automatically read cookies from the browser. as it stands the only way to use this tool is to manually go into the browser tools and copy the cookie from the storage tab by hand. this is somewhat of a tricky problem to solve because of the usual fact that browsers do things differently. but also after digging into this a little bit it looks like firefox has some complex set of rules for when they update there cookies database.

so this is a tracking issue where the hope is to build a command like:

$ fcd firefox
$ fcd chrome
$ fcd edge

the assumption is that this is run during local development, on a system that has a browser. each of those commands will do it's best to search for the cookie set by the flask application on the users filesystem, read it and then send the decoded results back to command-line.

so far i've gathered some resources about how this implemented in firefox.

one noteworthy thing is that when you try to access your cookies sqlite db while firefox is running, there is a lock placed on the database which prevents access from any other sqlite3 clients. as mentioned in those resources above you can bypass that by creating a copy of the .sqlite file. but that is problematic because the copied version does have the results, which are yet to be committed by the firefox process locking the db.

that puts a major damper on this approach as figuring out how to get firefox to commit changes to the cookies db probably would involve manual work or an extension.

Add cli that is independent of the flask application object

the only CLI that is available at the moment is made available through the flask command. this is valuable in situations where you would like to validate the session cookie (verify it's signature) in addition to reading the content of the cookie. but it has a down-side of needing to be configured with the flask application you are looking to read cookies for.

in some situations you might just want to run a cli script without having to attach to any flask applications, in order to just read the cookie. so for this case, i want to add CLI that allows just that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.