CodeWitness

Audit a post-login redirect

The application redirects to a destination copied from a request parameter.

def after_login(request):
    return redirect(request.args.get("next", "/dashboard"))

Choose a destination from a small allowlist instead of trusting an arbitrary URL supplied by the caller.

What is the safest way to choose the post-login destination?