@app.route("<STR_LIT>")<EOL>def digest_auth(<EOL>qop=None, user="<STR_LIT:user>", passwd="<STR_LIT>", algorithm="<STR_LIT>", stale_after="<STR_LIT>"<EOL>):
require_cookie_handling = request.args.get("<STR_LIT>", "<STR_LIT>").lower() in (<EOL>"<STR_LIT:1>",<EOL>"<STR_LIT:t>",<EOL>"<STR_LIT:true>",<EOL>)<EOL>if algorithm not in ("<STR_LIT>", "<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>algorithm = "<STR_LIT>"<EOL><DEDENT>if qop not in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>qop = None<EOL><DEDENT>authorization = request.headers.get("<STR_LIT>")<EOL>credentials = None<EOL>if authorization:<EOL><INDENT>credentials = parse_authorization_header(authorization)<EOL><DEDENT>if (<EOL>not authorization<EOL>or not credentials<EOL>or credentials.type.lower() != "<STR_LIT>"<EOL>or (require_cookie_handling and "<STR_LIT>" not in request.headers)<EOL>):<EOL><INDENT>response = digest_challenge_response(app, qop, algorithm)<EOL>response.set_cookie("<STR_LIT>", value=stale_after)<EOL>response.set_cookie("<STR_LIT>", value="<STR_LIT>")<EOL>return response<EOL><DEDENT>if require_cookie_handling and request.cookies.get("<STR_LIT>") != "<STR_LIT>":<EOL><INDENT>response = jsonify({"<STR_LIT>": ["<STR_LIT>"]})<EOL>response.set_cookie("<STR_LIT>", value="<STR_LIT>")<EOL>response.status_code = <NUM_LIT><EOL>return response<EOL><DEDENT>current_nonce = credentials.get("<STR_LIT>")<EOL>stale_after_value = None<EOL>if "<STR_LIT>" in request.cookies:<EOL><INDENT>stale_after_value = request.cookies.get("<STR_LIT>")<EOL><DEDENT>if (<EOL>"<STR_LIT>" in request.cookies<EOL>and current_nonce == request.cookies.get("<STR_LIT>")<EOL>or stale_after_value == "<STR_LIT:0>"<EOL>):<EOL><INDENT>response = digest_challenge_response(app, qop, algorithm, True)<EOL>response.set_cookie("<STR_LIT>", value=stale_after)<EOL>response.set_cookie("<STR_LIT>", value=current_nonce)<EOL>response.set_cookie("<STR_LIT>", value="<STR_LIT>")<EOL>return response<EOL><DEDENT>if not check_digest_auth(user, passwd):<EOL><INDENT>response = digest_challenge_response(app, qop, algorithm, False)<EOL>response.set_cookie("<STR_LIT>", value=stale_after)<EOL>response.set_cookie("<STR_LIT>", value=current_nonce)<EOL>response.set_cookie("<STR_LIT>", value="<STR_LIT>")<EOL>return response<EOL><DEDENT>response = jsonify(authenticated=True, user=user)<EOL>response.set_cookie("<STR_LIT>", value="<STR_LIT>")<EOL>if stale_after_value:<EOL><INDENT>response.set_cookie(<EOL>"<STR_LIT>", value=next_stale_after_value(stale_after_value)<EOL>)<EOL><DEDENT>return response<EOL>
Prompts the user for authorization using Digest Auth + Algorithm.
    allow settings the stale_after argument.
    ---
    tags:
      - Auth
    parameters:
      - in: path
        name: qop
        type: string
        description: auth or auth-int
      - in: path
        name: user
        type: string
      - in: path
        name: passwd
        type: string
      - in: path
        name: algorithm
        type: string
        description: MD5, SHA-256, SHA-512
        default: MD5
      - in: path
        name: stale_after
        type: string
        default: never
    produces:
      - application/json
    responses:
      200:
        description: Sucessful authentication.
      401:
        description: Unsuccessful authentication.