Module Expr Str Import alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore ListLoad Str Str Str Str Str Str Str Str ClassDef bases AttributeLoad NameLoad attr body Pass decorator_list ClassDef bases NameLoad AttributeLoad NameLoad attr body Pass decorator_list ClassDef bases NameLoad AttributeLoad NameLoad attr body Pass decorator_list ClassDef bases NameLoad AttributeLoad NameLoad attr body Pass decorator_list ClassDef bases NameLoad AttributeLoad NameLoad attr body Pass decorator_list Assign NameStore Str Assign NameStore Str ClassDef bases body FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Num body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body FunctionDef arguments args NameParam defaults body FunctionDef arguments args defaults vararg kwarg body Assign NameStore Call AttributeLoad NameLoad attr If UnaryOpNot NameLoad body Raise Call NameLoad Str Assign AttributeStore NameLoad attr Call NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore Call NameLoad NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad SubscriptLoad NameLoad Index NameLoad Return NameLoad decorator_list Call NameLoad NameLoad Return NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body FunctionDef arguments args NameParam defaults body FunctionDef arguments args defaults vararg kwarg body Assign NameStore Call AttributeLoad NameLoad attr If UnaryOpNot NameLoad body Raise Call NameLoad Str Assign AttributeStore NameLoad attr Call NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Return Call NameLoad NameLoad NameLoad decorator_list Call NameLoad NameLoad Return NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body If UnaryOpNot NameLoad body Raise Call NameLoad Str If UnaryOpNot NameLoad body Raise Call NameLoad Str If CompareNotEq NameLoad NameLoad body Raise Call NameLoad Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If BoolOpOr CompareIs NameLoad NameLoad CompareLt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body Assign NameStore Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Assign AttributeStore NameLoad attr Call NameLoad Call AttributeLoad NameLoad attr orelse Assign AttributeStore NameLoad attr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Return Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr ListLoad Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type NameLoad body Raise Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareNotEq Call NameLoad NameLoad Num body Raise Call NameLoad TryExcept body Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Num handlers ExceptHandler type NameLoad body Raise Call NameLoad If CompareIsNot NameLoad NameLoad body If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr If CompareLt BinOpAdd NameLoad NameLoad NameLoad body Raise Call NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareNotEq Call NameLoad NameLoad Call NameLoad NameLoad body Raise Call NameLoad Assign NameStore Num For TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad body AugAssignBitOr NameStore BinOpBitXor Call NameLoad NameLoad Call NameLoad NameLoad If NameLoad body Raise Call NameLoad decorator_list decorator_list
N/A N/A 
  flask-xsrf
  ~~~~~~~~~~

  flask extension for defending against cross-site request forgery attacks
  (XSRF/CSRF).

  :usage:

    from flask import Flask, Response, session
    from flask.ext import xsrf

    app = Flask(__name__)
    app.debug = True
    app.secret_key = 'session_secret_key'
    app.config['session_cookie_secure'] = True

    @app.before_request
    def before_request():
      if 'user_id' not in session:
        session['user_id'] = 'random_generated_anonymous_id'

    def get_user_id():
      return session.get('user_id')

    xsrfh = xsrf.XSRFTokenHandler(
      user_func=get_user_id, secret='xsrf_secret', timeout=3600)

    @app.route('/create', methods=['GET'])
    @xsrfh.send_token()
    def create_get():
      return Response('success')

    @app.route('/create', methods=['POST'])
    @xsrfh.handle_token()
    def create_post():
      return Response('success')


  :author: @gregorynicholas
  :license: MIT, see LICENSE for more details.
 N/A hmac N/A time N/A base64 N/A hashlib flask request flask session functools wraps werkzeug exceptions N/A __all__ N/A XSRFTokenHandler XSRFToken XSRFTokenUserIdInvalid XSRFTokenMalformed XSRFTokenExpiredException XSRFTokenInvalid TOKEN_FORM_NAME TOKEN_HEADER_NAME XSRFException N/A N/A exceptions HTTPException N/A N/A N/A XSRFTokenMalformed N/A XSRFException N/A exceptions NotAcceptable N/A N/A N/A XSRFTokenExpiredException N/A XSRFException N/A exceptions Unauthorized N/A N/A N/A XSRFTokenInvalid N/A XSRFException N/A exceptions NotAcceptable N/A N/A N/A XSRFTokenUserIdInvalid N/A XSRFException N/A exceptions NotAcceptable N/A N/A N/A N/A TOKEN_FORM_NAME xsrf-token N/A TOKEN_HEADER_NAME X-XSRF-Token XSRFTokenHandler N/A N/A __init__ N/A N/A self user_func secret timeout N/A 10 N/A N/A 
      :param user_func: Function which returns an key string for the current user.
      :param secret: String secret.
      :param timeout: Integer for the number of seconds the token is active for.
     N/A N/A self user_func user_func N/A N/A self secret secret N/A N/A self timeout timeout N/A send_token N/A N/A self N/A N/A wrapper N/A N/A func N/A N/A decorated N/A N/A N/A args kw N/A N/A user_id N/A N/A self user_func N/A N/A user_id N/A N/A N/A XSRFTokenUserIdInvalid XSRFTokenUserIdInvalid N/A N/A self token N/A XSRFToken user_id user_id secret N/A self secret N/A N/A session N/A TOKEN_FORM_NAME N/A N/A N/A self token generate_token_string N/A response N/A func args kw N/A N/A N/A N/A response headers add TOKEN_HEADER_NAME N/A session N/A TOKEN_FORM_NAME N/A response N/A N/A wraps func N/A decorated N/A N/A wrapper N/A handle_token N/A N/A self N/A N/A wrapper N/A N/A func N/A N/A decorated N/A N/A N/A args kw N/A N/A user_id N/A N/A self user_func N/A N/A user_id N/A N/A N/A XSRFTokenUserIdInvalid UserId not valid. N/A N/A self token N/A XSRFToken user_id user_id secret N/A self secret N/A request_token_string N/A N/A self parse_xsrftoken_from_request N/A token_string N/A N/A session pop TOKEN_FORM_NAME None N/A N/A N/A self verify_token token_string request_token_string N/A N/A func args kw N/A N/A wraps func N/A decorated N/A N/A wrapper N/A verify_token N/A N/A self token_string request_token_string N/A N/A N/A N/A token_string N/A N/A N/A XSRFTokenInvalid Token not set. N/A N/A request_token_string N/A N/A N/A XSRFTokenInvalid Request token not valid. N/A N/A token_string request_token_string N/A N/A N/A XSRFTokenInvalid Token not valid. N/A N/A N/A N/A self token verify_token_string token_string timeout N/A self timeout N/A parse_xsrftoken_from_request N/A N/A self N/A N/A N/A value N/A N/A N/A request headers get TOKEN_HEADER_NAME N/A N/A N/A value None N/A N/A len value 1 N/A N/A value N/A N/A N/A request form get TOKEN_FORM_NAME N/A value N/A N/A XSRFToken N/A object N/A N/A _DELIMITER | __init__ N/A N/A self user_id secret current_time N/A None N/A N/A Initializes the XSRFToken object.

    :param user_id:
      A string representing the user that the token will be valid for.
    :param secret:
      A string containing a secret key that will be used to seed the
      hash used by the :class:`XSRFToken`.
    :param current_time:
      An int representing the number of seconds since the epoch. Will be
      used by `verify_token_string` to check for token expiry. If `None`
      then the current time will be used.
     N/A N/A self user_id user_id N/A N/A self secret secret N/A N/A current_time None N/A N/A N/A self current_time N/A int N/A N/A time time N/A N/A N/A self current_time N/A int current_time N/A _digest_maker N/A N/A self N/A N/A N/A N/A N/A hmac new N/A self secret digestmod N/A hashlib sha256 N/A generate_token_string N/A N/A self action N/A None N/A N/A Generate a hash of the given token contents that can be verified.

    :param action:
      A string representing the action that the generated hash is valid
      for. This string is usually a URL.
    :returns:
      A string containing the hash contents of the given `action` and the
      contents of the `XSRFToken`. Can be verified with
      `verify_token_string`. The string is base64 encoded so it is safe
      to use in HTML forms without escaping.
     N/A digest_maker N/A N/A self _digest_maker N/A N/A N/A digest_maker update N/A self user_id N/A N/A N/A digest_maker update N/A self _DELIMITER N/A action N/A N/A N/A N/A digest_maker update action N/A N/A N/A digest_maker update N/A self _DELIMITER N/A N/A N/A digest_maker update N/A str N/A self current_time N/A N/A N/A base64 urlsafe_b64encode N/A N/A N/A self _DELIMITER join N/A N/A N/A digest_maker hexdigest N/A str N/A self current_time N/A verify_token_string N/A N/A self token_string action timeout current_time N/A None None None N/A N/A Generate a hash of the given token contents that can be verified.

    :param token_string:
      A string containing the hashed token (generated by
      `generate_token_string`).
    :param action:
      A string containing the action that is being verified.
    :param timeout:
      An int or float representing the number of seconds that the token
      is valid for. If None then tokens are valid forever.
    :current_time:
      An int representing the number of seconds since the epoch. Will be
      used by to check for token expiry if `timeout` is set. If `None`
      then the current time will be used.
    :raises:
      XSRFTokenMalformed if the given token_string cannot be parsed.
      XSRFTokenExpiredException if the given token string is expired.
      XSRFTokenInvalid if the given token string does not match the
      contents of the `XSRFToken`.
     N/A N/A N/A decoded_token_string N/A N/A base64 urlsafe_b64decode token_string N/A N/A N/A TypeError N/A N/A N/A XSRFTokenMalformed N/A split_token N/A N/A decoded_token_string split N/A self _DELIMITER N/A N/A N/A len split_token 2 N/A N/A N/A XSRFTokenMalformed N/A N/A N/A token_time N/A int N/A split_token N/A 1 N/A N/A N/A ValueError N/A N/A N/A XSRFTokenMalformed N/A N/A timeout None N/A N/A N/A current_time None N/A N/A current_time N/A N/A time time N/A N/A N/A token_time timeout current_time N/A N/A N/A XSRFTokenExpiredException N/A expected_token N/A XSRFToken N/A self user_id N/A self secret token_time N/A expected_token_string N/A N/A expected_token generate_token_string action N/A N/A N/A len expected_token_string N/A len token_string N/A N/A N/A XSRFTokenInvalid N/A different 0 N/A N/A a b N/A zip token_string expected_token_string N/A N/A different N/A N/A ord a N/A ord b N/A different N/A N/A N/A XSRFTokenInvalid N/A N/A