|
15 | 15 | from sqlmodel.ext.asyncio.session import AsyncSession
|
16 | 16 |
|
17 | 17 | from aioauth.collections import HTTPHeaderDict
|
| 18 | +from aioauth.errors import AccessDeniedError |
18 | 19 | from aioauth.requests import Post, Query
|
19 | 20 | from aioauth.requests import Request as OAuthRequest
|
20 | 21 | from aioauth.responses import Response as OAuthResponse
|
21 | 22 | from aioauth.types import RequestMethod
|
| 23 | +from aioauth.utils import build_error_response |
22 | 24 |
|
23 | 25 | from shared import AuthServer, BackendStore, engine, settings, try_login, lifespan
|
24 | 26 |
|
@@ -174,14 +176,18 @@ async def approve_submit(
|
174 | 176 | approval: int = Form(),
|
175 | 177 | oauth: AuthServer = Depends(get_auth_server),
|
176 | 178 | ):
|
177 |
| - """ """ |
| 179 | + """ |
| 180 | + scope approval form submission handler |
| 181 | + """ |
178 | 182 | oauthreq = request.session["oauth"]
|
179 | 183 | oauthreq.user = request.session["user"]
|
180 | 184 | if not approval:
|
181 |
| - # TODO: generate `permission_denied` response |
182 |
| - return await approve(request) |
183 |
| - # process authorize request |
184 |
| - response = await oauth.create_authorization_response(oauthreq) |
| 185 | + # generate error response on deny |
| 186 | + error = AccessDeniedError(oauthreq, 'User rejected scopes') |
| 187 | + response = build_error_response(error, oauthreq, skip_redirect_on_exc=()) |
| 188 | + else: |
| 189 | + # process authorize request |
| 190 | + response = await oauth.create_authorization_response(oauthreq) |
185 | 191 | return to_response(response)
|
186 | 192 |
|
187 | 193 |
|
|
0 commit comments