Skip to content

Commit 995d775

Browse files
[autofix.ci] apply automated fixes
1 parent 4348c7d commit 995d775

4 files changed

Lines changed: 36 additions & 19 deletions

File tree

scripts/mock_oidc_server.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ def _b64url(n: int) -> str:
127127
JWKS = {
128128
"keys": [
129129
{
130-
"kty": "RSA", "use": "sig", "kid": _KID, "alg": "RS256",
130+
"kty": "RSA",
131+
"use": "sig",
132+
"kid": _KID,
133+
"alg": "RS256",
131134
"n": _b64url(_pub_numbers.n),
132135
"e": _b64url(_pub_numbers.e),
133136
}
@@ -274,7 +277,7 @@ async def authorization_submit(
274277
if not _has_client_access(emp_id, client_id):
275278
project = client_id.removeprefix("langflow-")
276279
groups = _get_employee_groups(emp_id)
277-
reason = f"소속 그룹 없음" if not groups else f"소속 그룹: {', '.join(groups)}"
280+
reason = "소속 그룹 없음" if not groups else f"소속 그룹: {', '.join(groups)}"
278281
return HTMLResponse(
279282
_error_page(
280283
f"<b>{emp['name']} ({emp_id})</b> 계정은 "
@@ -304,7 +307,9 @@ async def token(
304307

305308
entry = _codes.pop(code, None)
306309
if not entry:
307-
return JSONResponse({"error": "invalid_grant", "error_description": "Code not found or already used"}, status_code=400)
310+
return JSONResponse(
311+
{"error": "invalid_grant", "error_description": "Code not found or already used"}, status_code=400
312+
)
308313

309314
employee_id, issued_client_id = entry
310315
return {
@@ -318,7 +323,6 @@ async def token(
318323
@app.get("/admin", include_in_schema=False)
319324
async def admin_page():
320325
"""Read-only page: employees, groups, and client access."""
321-
322326
# ── Group table ───────────────────────────────────────────────────────
323327
group_rows = ""
324328
for gname, g in GROUPS.items():

src/backend/langflow-keycloak-sso/src/langflow_keycloak_sso/keycloak_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ def __init__(self, token_endpoint: str, jwks_uri: str, client_id: str, client_se
1717
self._client_secret = client_secret
1818
self._jwks_client = PyJWKClient(jwks_uri)
1919

20-
async def exchange_code(
21-
self, code: str, redirect_uri: str, code_verifier: str | None = None
22-
) -> dict[str, Any]:
20+
async def exchange_code(self, code: str, redirect_uri: str, code_verifier: str | None = None) -> dict[str, Any]:
2321
"""Exchange authorization code for tokens. Returns the token response dict."""
2422
post_data: dict[str, str] = {
2523
"grant_type": "authorization_code",

src/backend/langflow-keycloak-sso/src/langflow_keycloak_sso/mapping.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
import secrets
44

5-
from passlib.context import CryptContext
6-
from sqlmodel.ext.asyncio.session import AsyncSession
7-
85
from langflow.initial_setup.setup import get_or_create_default_folder
96
from langflow.services.database.models.user.crud import get_user_by_username
107
from langflow.services.database.models.user.model import User
118
from langflow.services.deps import get_variable_service
9+
from passlib.context import CryptContext
10+
from sqlmodel.ext.asyncio.session import AsyncSession
1211

1312
_pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
1413

src/backend/langflow-keycloak-sso/src/langflow_keycloak_sso/router.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
import secrets
77
import urllib.parse
88
from datetime import datetime, timedelta, timezone
9-
from typing import Annotated
109

1110
import jwt as pyjwt
1211
from fastapi import APIRouter, HTTPException, Request, status
1312
from fastapi.responses import RedirectResponse
14-
1513
from langflow.api.utils.core import DbSession
1614
from langflow.services.deps import get_auth_service, get_settings_service
1715

@@ -36,9 +34,7 @@ def _get_state_secret() -> str:
3634
def _generate_pkce() -> tuple[str, str]:
3735
"""Return (code_verifier, code_challenge) for PKCE S256."""
3836
verifier = base64.urlsafe_b64encode(os.urandom(32)).rstrip(b"=").decode()
39-
challenge = base64.urlsafe_b64encode(
40-
hashlib.sha256(verifier.encode()).digest()
41-
).rstrip(b"=").decode()
37+
challenge = base64.urlsafe_b64encode(hashlib.sha256(verifier.encode()).digest()).rstrip(b"=").decode()
4238
return verifier, challenge
4339

4440

@@ -227,7 +223,12 @@ async def keycloak_logout(request: Request):
227223

228224
redirect = RedirectResponse(url="/login", status_code=status.HTTP_302_FOUND)
229225
for name, httponly, samesite, secure in [
230-
("refresh_token_lf", auth_settings.REFRESH_HTTPONLY, auth_settings.REFRESH_SAME_SITE, auth_settings.REFRESH_SECURE),
226+
(
227+
"refresh_token_lf",
228+
auth_settings.REFRESH_HTTPONLY,
229+
auth_settings.REFRESH_SAME_SITE,
230+
auth_settings.REFRESH_SECURE,
231+
),
231232
("access_token_lf", auth_settings.ACCESS_HTTPONLY, auth_settings.ACCESS_SAME_SITE, auth_settings.ACCESS_SECURE),
232233
("apikey_tkn_lflw", auth_settings.ACCESS_HTTPONLY, auth_settings.ACCESS_SAME_SITE, auth_settings.ACCESS_SECURE),
233234
("kc_id_token_lf", True, auth_settings.ACCESS_SAME_SITE, auth_settings.ACCESS_SECURE),
@@ -261,9 +262,24 @@ async def keycloak_logout(request: Request):
261262
redirect = RedirectResponse(url=kc_logout_url, status_code=status.HTTP_302_FOUND)
262263
# Re-delete the cookies on the new redirect response as well.
263264
for name, httponly, samesite, secure in [
264-
("refresh_token_lf", auth_settings.REFRESH_HTTPONLY, auth_settings.REFRESH_SAME_SITE, auth_settings.REFRESH_SECURE),
265-
("access_token_lf", auth_settings.ACCESS_HTTPONLY, auth_settings.ACCESS_SAME_SITE, auth_settings.ACCESS_SECURE),
266-
("apikey_tkn_lflw", auth_settings.ACCESS_HTTPONLY, auth_settings.ACCESS_SAME_SITE, auth_settings.ACCESS_SECURE),
265+
(
266+
"refresh_token_lf",
267+
auth_settings.REFRESH_HTTPONLY,
268+
auth_settings.REFRESH_SAME_SITE,
269+
auth_settings.REFRESH_SECURE,
270+
),
271+
(
272+
"access_token_lf",
273+
auth_settings.ACCESS_HTTPONLY,
274+
auth_settings.ACCESS_SAME_SITE,
275+
auth_settings.ACCESS_SECURE,
276+
),
277+
(
278+
"apikey_tkn_lflw",
279+
auth_settings.ACCESS_HTTPONLY,
280+
auth_settings.ACCESS_SAME_SITE,
281+
auth_settings.ACCESS_SECURE,
282+
),
267283
("kc_id_token_lf", True, auth_settings.ACCESS_SAME_SITE, auth_settings.ACCESS_SECURE),
268284
]:
269285
redirect.delete_cookie(

0 commit comments

Comments
 (0)