Skip to content

Commit a11ebd6

Browse files
committed
fix: remove logout as session tokens are HttpOnly
1 parent 4e47493 commit a11ebd6

4 files changed

Lines changed: 1 addition & 92 deletions

File tree

docs/auth.md

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,6 @@ curl -X POST http://localhost:5000/ \
140140
}'
141141
```
142142

143-
### Logout
144-
145-
```graphql
146-
mutation {
147-
logout(sessionToken: "your_session_token_here")
148-
}
149-
```
150-
151-
This invalidates the specified session for the current user.
152-
153-
**Returns:** `true` if successful, `false` if not authenticated
154-
155143
## Bot Management
156144
### Creating Bots (Admin Only)
157145

@@ -180,16 +168,6 @@ mutation {
180168

181169
Bots use API keys instead of session tokens. Include the API key in the `Authorization` header in the same format as before.
182170

183-
### Deleting Bots (Admin Only)
184-
185-
```graphql
186-
mutation {
187-
deleteBot(apiKeyId: 1)
188-
}
189-
```
190-
191-
**Returns:** `true` if successful
192-
193171

194172
## Permission Checking in Code
195173

@@ -246,17 +224,6 @@ The GitHub account is not part of the specified organization. Either:
246224

247225
### GraphQL Mutations
248226

249-
#### `logout(sessionToken: String!): Boolean!`
250-
251-
Invalidate the specified session for current user.
252-
253-
**Input:**
254-
- `sessionToken`: The session token to invalidate
255-
256-
**Returns:** `true` if successful, `false` if not authenticated
257-
258-
---
259-
260227
#### `createBot(name: String!): String!` 🔒 Admin only
261228

262229
Create a new bot with API key.
@@ -266,17 +233,6 @@ Create a new bot with API key.
266233

267234
**Returns:** The API key string (only shown once!)
268235

269-
---
270-
271-
#### `deleteBot(apiKeyId: Int!): Boolean!` 🔒 Admin only
272-
273-
Delete a bot and revoke its API key.
274-
275-
**Input:**
276-
- `apiKeyId`: ID of the API key to delete
277-
278-
**Returns:** `true` if successful
279-
280236
## Example
281237

282238
### Complete Member Authentication Flow

src/auth/session.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,6 @@ impl SessionService {
7373
Ok(result)
7474
}
7575

76-
pub async fn delete_session_by_token(pool: &PgPool, token: &str) -> Result<(), String> {
77-
let token_hash = Self::hash_token(token);
78-
79-
sqlx::query(
80-
r#"
81-
DELETE FROM Sessions
82-
WHERE token_hash = $1
83-
"#,
84-
)
85-
.bind(token_hash)
86-
.execute(pool)
87-
.await
88-
.map_err(|e| format!("Failed to delete session: {}", e))?;
89-
90-
Ok(())
91-
}
92-
9376
pub async fn cleanup_expired_sessions(pool: &PgPool) -> Result<u64, String> {
9477
let now = chrono::Utc::now().with_timezone(&Kolkata);
9578

src/graphql/mutations/auth_mutations.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,6 @@ pub struct AuthMutations;
1212

1313
#[Object]
1414
impl AuthMutations {
15-
/// Logout - invalidate session
16-
#[graphql(name = "logout")]
17-
async fn logout(&self, ctx: &Context<'_>, session_token: String) -> Result<bool> {
18-
let pool = ctx.data::<Arc<PgPool>>().expect("Pool must be in context.");
19-
let auth = ctx
20-
.data::<AuthContext>()
21-
.expect("AuthContext must be in context.");
22-
23-
if auth.is_authenticated() {
24-
SessionService::delete_session_by_token(pool.as_ref(), &session_token)
25-
.await
26-
.map_err(|e| format!("Failed to logout: {}", e))?;
27-
Ok(true)
28-
} else {
29-
Ok(false)
30-
}
31-
}
32-
3315
/// Create a new bot with API key (Admin only)
3416
#[graphql(name = "createBot", guard = "AdminGuard")]
3517
async fn create_bot(&self, ctx: &Context<'_>, name: String) -> Result<ApiKeyResponse> {
@@ -50,16 +32,4 @@ impl AuthMutations {
5032

5133
Ok(ApiKeyResponse { api_key })
5234
}
53-
54-
/// Delete a bot (Admin only)
55-
#[graphql(name = "deleteBot", guard = "AdminGuard")]
56-
async fn delete_bot(&self, ctx: &Context<'_>, api_key_id: i32) -> Result<bool> {
57-
let pool = ctx.data::<Arc<PgPool>>().expect("Pool must be in context.");
58-
59-
ApiKeyService::delete_api_key(pool.as_ref(), api_key_id)
60-
.await
61-
.map_err(|e| format!("Failed to delete bot: {}", e))?;
62-
63-
Ok(true)
64-
}
6535
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn setup_cors() -> CorsLayer {
159159
];
160160

161161
CorsLayer::new()
162-
// TODO 2: https://github.com/amfoss/root/issues/151, enabling all origins for the time being
162+
// TODO 2: https://github.com/amfoss/root/issues/151
163163
.allow_credentials(true)
164164
.allow_origin(origins)
165165
.allow_methods([Method::GET, Method::POST, Method::OPTIONS])

0 commit comments

Comments
 (0)