Code RoomRedirect target accepts user-supplied URL
MediumPrep Room Coding #1994

Redirect target accepts user-supplied URL

Code reviewCode quality & reviewMid–Senior~20 min

Review this Python OAuth-callback handler that redirects back to a client-supplied URL.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1@app.get('/auth/callback')
2def callback():
3 code = request.args['code']
4 next_url = request.args.get('next', '/dashboard')
5 token = exchange_code(code)
6 resp = redirect(next_url)
7 resp.set_cookie('session', token, httponly=True)
8 return resp
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.