diff --git a/docs/API.md b/docs/API.md index 896313a..918af0f 100644 --- a/docs/API.md +++ b/docs/API.md @@ -15,7 +15,7 @@ For integrating Paskia with your app frontend, see [integration](Integration.md) | Method | Path | Used for | Notes | |---:|---|---|---| | GET | `/auth/api/settings` | Paskia configuration | Returns RP info + base paths + session cookie name | -| POST | `/auth/api/user-info` | Full user profile | Basic information, credentials, sessions, permissions | +| GET | `/auth/api/user-info` | Full user profile | Basic information, credentials, sessions, permissions | | POST | `/auth/api/logout` | Terminate session and delete session cookie | Signs out of the current site | | POST | `/auth/api/validate` | Validate and renew session cookie | Optional query: `perm=` (repeatable), `max_age=` | | GET | `/auth/api/forward` | Validate access (Caddy/Nginx) | 204 on success; 401/403 otherwise (HTML if requested) | diff --git a/docs/Integration.md b/docs/Integration.md index 9be5810..cc7abf3 100644 --- a/docs/Integration.md +++ b/docs/Integration.md @@ -91,7 +91,7 @@ if (response.status === 401 || response.status === 403) { Get current user details: ```js -const user = await apiJson('/auth/api/user-info', { method: 'POST' }) +const user = await apiJson('/auth/api/user-info', { method: 'GET' }) // Returns: { uuid, display_name, credentials, sessions, permissions, ... } ``` diff --git a/e2e/tests/fixtures/passkey-helpers.ts b/e2e/tests/fixtures/passkey-helpers.ts index 2df748e..c0d365b 100644 --- a/e2e/tests/fixtures/passkey-helpers.ts +++ b/e2e/tests/fixtures/passkey-helpers.ts @@ -479,7 +479,7 @@ export async function getUserInfo( sessionToken: string ): Promise { const cookieName = getSessionCookieName() - const response = await page.request.post(`${baseUrl}/auth/api/user-info`, { + const response = await page.request.get(`${baseUrl}/auth/api/user-info`, { headers: { 'Cookie': `${cookieName}=${sessionToken}`, }, diff --git a/examples/index.html b/examples/index.html index 4a5bddf..dac6fe0 100644 --- a/examples/index.html +++ b/examples/index.html @@ -27,7 +27,7 @@

API Mode (not leaving the page)

For SPAs and fetch() calls - shows auth in an iframe overlay:

- + diff --git a/frontend/auth/App.vue b/frontend/auth/App.vue index e510b3a..70a005c 100644 --- a/frontend/auth/App.vue +++ b/frontend/auth/App.vue @@ -63,7 +63,7 @@ async function loadUserInfo() { try { const [validateData, userInfoData] = await Promise.all([ apiJson('/auth/api/validate', { method: 'POST' }), - apiJson('/auth/api/user-info', { method: 'POST' }) + apiJson('/auth/api/user-info', { method: 'GET' }) ]) store.userInfo = userInfoData store.ctx = validateData.ctx diff --git a/frontend/src/stores/auth.js b/frontend/src/stores/auth.js index 9015e1f..1f10d95 100644 --- a/frontend/src/stores/auth.js +++ b/frontend/src/stores/auth.js @@ -87,7 +87,7 @@ export const useAuthStore = defineStore('auth', { }, async loadUserInfo() { try { - this.userInfo = await apiJson('/auth/api/user-info', { method: 'POST' }) + this.userInfo = await apiJson('/auth/api/user-info', { method: 'GET' }) updateThemeFromSession(this.ctx) console.log('User info loaded:', this.userInfo) } catch (error) { diff --git a/paskia/fastapi/api.py b/paskia/fastapi/api.py index e505d98..bfbbcd7 100644 --- a/paskia/fastapi/api.py +++ b/paskia/fastapi/api.py @@ -203,7 +203,7 @@ async def get_settings(): ) -@app.post("/user-info") +@app.get("/user-info") async def api_user_info( request: Request, response: Response, diff --git a/tests/test_api.py b/tests/test_api.py index 4fb1b22..eb86632 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -230,12 +230,12 @@ class TestLogoutEndpoint: class TestUserInfoEndpoint: - """Tests for POST /auth/api/user-info""" + """Tests for GET /auth/api/user-info""" @pytest.mark.asyncio async def test_user_info_without_auth_returns_401(self, client: httpx.AsyncClient): """User info without session should return 401.""" - response = await client.post("/auth/api/user-info") + response = await client.get("/auth/api/user-info") assert response.status_code == 401 @pytest.mark.asyncio @@ -243,7 +243,7 @@ class TestUserInfoEndpoint: self, client: httpx.AsyncClient, session_token: str, test_user ): """User info with valid session should return user data.""" - response = await client.post( + response = await client.get( "/auth/api/user-info", headers={**auth_headers(session_token), "Host": "localhost:4401"}, ) @@ -258,7 +258,7 @@ class TestUserInfoEndpoint: self, client: httpx.AsyncClient, session_token: str ): """User info should include user's credentials.""" - response = await client.post( + response = await client.get( "/auth/api/user-info", headers={**auth_headers(session_token), "Host": "localhost:4401"}, ) @@ -272,7 +272,7 @@ class TestUserInfoEndpoint: self, client: httpx.AsyncClient, session_token: str ): """User info should include user's active sessions.""" - response = await client.post( + response = await client.get( "/auth/api/user-info", headers={**auth_headers(session_token), "Host": "localhost:4401"}, ) @@ -286,7 +286,7 @@ class TestUserInfoEndpoint: self, client: httpx.AsyncClient, session_token: str ): """User info should include user's permissions.""" - response = await client.post( + response = await client.get( "/auth/api/user-info", headers={**auth_headers(session_token), "Host": "localhost:4401"}, )