mirror of
https://github.com/lnbits/lnbits.git
synced 2026-08-13 12:42:47 +02:00
fix: sso missing user id (#4082)
This commit is contained in:
parent
2223733c2d
commit
eee372bb3c
2 changed files with 19 additions and 1 deletions
|
|
@ -326,7 +326,7 @@ async def api_delete_user_api_token(
|
|||
async def login_with_sso_provider(
|
||||
request: Request,
|
||||
provider: str,
|
||||
user_id: str | None,
|
||||
user_id: str | None = None,
|
||||
auth_user_id: str | None = Depends(optional_user_id),
|
||||
):
|
||||
provider_sso = _new_sso(provider)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,24 @@ async def test_auth_api_logout_and_update_ui_customization(
|
|||
assert "cookie_access_token=" in logout.headers["set-cookie"]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_auth_api_keycloak_login_without_user_id_redirects_to_provider(
|
||||
http_client: AsyncClient, mocker
|
||||
):
|
||||
provider = "keycloak"
|
||||
login_sso = _FakeSSO()
|
||||
mocker.patch("lnbits.core.views.auth_api._new_sso", return_value=login_sso)
|
||||
|
||||
response = await http_client.get(f"/api/v1/auth/{provider}")
|
||||
|
||||
assert response.status_code == 307
|
||||
assert response.headers["location"] == "https://example.com/sso/login"
|
||||
assert login_sso.redirect_uri == (
|
||||
f"{http_client.base_url}/api/v1/auth/{provider}/token"
|
||||
)
|
||||
assert login_sso.state is None
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_auth_api_sso_login_and_callback(http_client: AsyncClient, mocker):
|
||||
user = await create_user_account(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue