|
37 | 37 | ) |
38 | 38 |
|
39 | 39 | # Configuration |
40 | | -CLIENT_ID = os.environ.get("CLIENT_ID", "stac") |
41 | | -CLIENT_SECRET = os.environ.get("CLIENT_SECRET", "secret") |
42 | | -REDIRECT_URI = os.environ.get( |
43 | | - "REDIRECT_URI", "http://localhost:8000/docs/oauth2-redirect" |
44 | | -) |
45 | 40 | ISSUER = os.environ.get("ISSUER", "http://localhost:3000") |
46 | 41 | AVAILABLE_SCOPES = os.environ.get("SCOPES", "") |
47 | 42 | KEY_ID = "1" |
@@ -110,15 +105,6 @@ def int_to_base64url(value): |
110 | 105 | access_tokens = {} |
111 | 106 | auth_requests = {} |
112 | 107 |
|
113 | | -# Mock client registry |
114 | | -CLIENT_REGISTRY = { |
115 | | - CLIENT_ID: { |
116 | | - "client_secret": CLIENT_SECRET, |
117 | | - "redirect_uris": [REDIRECT_URI], |
118 | | - "grant_types": ["authorization_code"], |
119 | | - } |
120 | | -} |
121 | | - |
122 | 108 |
|
123 | 109 | @app.get("/") |
124 | 110 | async def root(): |
@@ -167,14 +153,6 @@ async def authorize( |
167 | 153 | if response_type != "code": |
168 | 154 | raise HTTPException(status_code=400, detail="Invalid response type") |
169 | 155 |
|
170 | | - # Validate client |
171 | | - if client_id not in CLIENT_REGISTRY: |
172 | | - raise HTTPException(status_code=400, detail="Invalid client_id") |
173 | | - |
174 | | - # Validate redirect URI |
175 | | - if redirect_uri not in CLIENT_REGISTRY[client_id]["redirect_uris"]: |
176 | | - raise HTTPException(status_code=400, detail="Invalid redirect_uri") |
177 | | - |
178 | 156 | # Validate PKCE if provided |
179 | 157 | if code_challenge is not None: |
180 | 158 | if code_challenge_method != "S256": |
@@ -277,13 +255,6 @@ async def token( |
277 | 255 |
|
278 | 256 | if computed_challenge != code_challenge: |
279 | 257 | raise HTTPException(status_code=400, detail="Invalid code verifier") |
280 | | - else: |
281 | | - # If not PKCE, verify client secret |
282 | | - if not client_secret: |
283 | | - raise HTTPException(status_code=400, detail="Client secret required") |
284 | | - |
285 | | - if client_secret != CLIENT_REGISTRY[client_id]["client_secret"]: |
286 | | - raise HTTPException(status_code=400, detail="Invalid client secret") |
287 | 258 |
|
288 | 259 | # Clean up the used code and PKCE challenge |
289 | 260 | del authorization_codes[code] |
|
0 commit comments