generator-flask-api icon indicating copy to clipboard operation
generator-flask-api copied to clipboard

support for authentication?

Open tharrington opened this issue 9 years ago • 5 comments

Do you have authentication middleware support? Is it on your roadmap?

tharrington avatar Apr 09 '16 16:04 tharrington

@tharrington I hadn't considered it yet. Different applications can have pretty diverse authentication / authorization requirements, so it could be a bit out of scope for a scaffolding tool.

Did you have anything in particular in mind? I'm a little out of the loop on Python auth frameworks.

coalkettler avatar Apr 10 '16 22:04 coalkettler

@ColeKettler some sort of decorator using HTTPAuth could be good

tharrington avatar Apr 14 '16 18:04 tharrington

In either case, the build doesn't work for me... does this support pythong 3.5?

$ ./manage.py runserver
/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.
  warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.')
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.
  warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.')
 * Debugger is active!
Traceback (most recent call last):
  File "./manage.py", line 20, in <module>
    manager.run()
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/flask_script/__init__.py", line 412, in run
    result = self.handle(sys.argv[0], sys.argv[1:])
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/flask_script/__init__.py", line 383, in handle
    res = handle(*args, **config)
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/flask_script/commands.py", line 425, in __call__
    **self.server_options)
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/flask/app.py", line 772, in run
    run_simple(host, port, self, **options)
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/werkzeug/serving.py", line 633, in run_simple
    application = DebuggedApplication(application, use_evalex)
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/werkzeug/debug/__init__.py", line 249, in __init__
    if self.pin is None:
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/werkzeug/debug/__init__.py", line 259, in _get_pin
    self._pin, self._pin_cookie = get_pin_and_cookie_name(self.app)
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/werkzeug/debug/__init__.py", line 159, in get_pin_and_cookie_name
    get_machine_id(),
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/werkzeug/debug/__init__.py", line 94, in get_machine_id
    _machine_id = rv = _generate()
  File "/Users/tyler/Desktop/Projects/playground/flask-api/venv/lib/python3.5/site-packages/werkzeug/debug/__init__.py", line 70, in _generate
    match = re.match(r'"serial-number" = <([^>]+)', dump)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/re.py", line 163, in match
    return _compile(pattern, flags).match(string)
TypeError: <flask_script.commands.Server object at 0x10403f0b8>: cannot use a string pattern on a bytes-like object

tharrington avatar Apr 14 '16 18:04 tharrington

@tharrington Regarding the decorator: I'll evaluate that in the coming week. A generic decorator to restrict a given endpoint could be useful, as long as it's agnostic of the authorization scheme.

Regarding the error: huh, that's funny, it should run fine against 3.5. I'll test a sample API against a few versions of Python to see what's up. Hopefully there's nothing wrong with the underlying dependencies.

coalkettler avatar Apr 18 '16 01:04 coalkettler

@tharrington I haven't forgotten about your issue. I've been in the process of moving, but my schedule is stabilizing. I'll be investigating this soon.

coalkettler avatar May 18 '16 01:05 coalkettler