Performance: Why authorization matters
MEDIUM IMPACT
Authorization affects server response time and user experience by controlling access to resources, impacting perceived speed and security.
from flask import Flask, request, abort app = Flask(__name__) @app.route('/dashboard') def dashboard(): user = request.args.get('user') if user != 'admin': abort(403) # expensive data processing here return 'Welcome to admin dashboard'
from flask import Flask, request app = Flask(__name__) @app.route('/dashboard') def dashboard(): # expensive data processing here user = request.args.get('user') if user != 'admin': return 'Access Denied', 403 return 'Welcome to admin dashboard'
| Pattern | Server Processing | Response Delay | Network Impact | Verdict |
|---|---|---|---|---|
| Late authorization check after processing | High (full processing done) | High (blocks response) | No change | [X] Bad |
| Early authorization check with abort | Low (processing skipped if unauthorized) | Low (fast response) | No change | [OK] Good |