py2http.flask_plugins¶
Flask counterparts of the Bottle plugins: auth as a before_request hook, CORS as an
after_request hook.
The credential checks are the plugins’ own (JWTPlugin.authenticate,
ApiKeyAuthPlugin.authenticate, which call py2http.auth), so Bottle and Flask
refuse the same requests for the same reasons. A plugin without an authenticate
method is a Bottle-only plugin: it is refused with NotImplementedError rather than
dropped, because a silently dropped auth plugin would leave its routes open.
Functions
|
The |
|
A |
|
An |
- py2http.flask_plugins.check_flask_plugins(plugins)[source]¶
The
pluginsas a list, each known to work under Flask; elseNotImplementedError.>>> check_flask_plugins(None) [] >>> check_flask_plugins([object()]) Traceback (most recent call last): ... NotImplementedError: The plugin <object object at ...> is Bottle-only...- Return type:
- py2http.flask_plugins.mk_auth_hook(plugins, *, public_views, cors=False)[source]¶
A
before_requestfunction runningplugins(outermost first, as under Bottle).Everything is guarded except: the
public_views(the view functions themselves, not endpoint names: a user function namedopenapimust stay guarded); a request that matched no route (it answers 404/405, as under Bottle, and runs no view); and, withcors, theOPTIONSpreflight, which Bottle’s CORS plugin answers before any auth runs. A plugin’s claims go onrequest.token, where the endpoint finds them throughcurrent_request.