Logout User
Endpoint
Authentication
No authentication required. This endpoint can be called by any client to clear cookies.
Behavior
When this endpoint is called:- Clears the
refresh_tokenHTTP-only cookie - Sets cookie path to
/auth/refresh - Returns success message
Cookie Clearing
The endpoint clears the refresh token cookie with these parameters:- Cookie Name:
refresh_token - Path:
/auth/refresh - Action: Cookie is removed from client
Client-Side Implementation
After calling logout, the client should:- Clear any stored access tokens from memory/localStorage
- Clear user state from application store
- Redirect to login page
- Remove Authorization headers from future requests
Example Implementation
Security Notes
- HTTP-Only Cookies: Refresh tokens are stored in HTTP-only cookies and cannot be accessed by JavaScript
- Path Restriction: Cookie is scoped to
/auth/refreshpath only - No Server-Side Invalidation: Tokens are not invalidated on the server (stateless JWT design)
- Token Expiration: Access tokens naturally expire after 15 minutes
Token Lifecycle After Logout
| Token Type | What Happens |
|---|---|
| Access Token | Client must delete; still valid until expiration (15 min) |
| Refresh Token | Cookie cleared; cannot be used for refresh |
Frontend Integration (Vue.js Example)
Related Endpoints
- Login - Authenticate user
- Refresh - Refresh access token
- Get Profile - Get current user info
