mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-04 06:11:52 +09:00
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from mitmproxy import http
|
|
import asyncio
|
|
from pkce_check import PKCEDowngradeChecker
|
|
from ScopeDetection import ScopeDetection
|
|
|
|
|
|
class PKCEAddon:
|
|
def __init__(self):
|
|
self.checker = PKCEDowngradeChecker()
|
|
|
|
async def request(self, flow: http.HTTPFlow):
|
|
print(
|
|
f"[DEBUG] Processing request: {flow.request.method} {flow.request.pretty_url}"
|
|
)
|
|
try:
|
|
await self.checker.test(flow)
|
|
except Exception as e:
|
|
print(f"[ERROR] Addon failed: {e}")
|
|
|
|
class ScopeAddon:
|
|
def __init__(self):
|
|
self.checker = ScopeDetection()
|
|
self._flow_map = {} # 요청 정보를 저장
|
|
|
|
async def request(self, flow: http.HTTPFlow):
|
|
self._flow_map[flow.id] = {
|
|
"method": flow.request.method,
|
|
"url": flow.request.pretty_url,
|
|
"query": flow.request.query,
|
|
}
|
|
|
|
async def response(self, flow: http.HTTPFlow):
|
|
try:
|
|
await self.checker.test(flow)
|
|
except Exception as e:
|
|
print(f"[ERROR] ScopeDetection failed: {e}")
|
|
|
|
|
|
addons = [PKCEAddon(), ScopeAddon()]
|