Skip to content

Conversation

@sip-21
Copy link
Owner

@sip-21 sip-21 commented Nov 25, 2025

Configurable access token expiration with optimized test speed

Added command-line configuration for access token expiration to enable
faster E2E tests while maintaining production defaults.

Server Changes (Kotlin)

TokenService.kt

  • Made accessTokenExpirationSeconds configurable via application config
  • Default: 60 seconds (production)
  • Reads from jwt.accessTokenExpirationSeconds property

Ambrosia.kt

  • Added --jwt-access-token-expiration CLI option (default: "60")
  • Passes option value to application config

Authorize.kt

  • Updated /login and /refresh cookie expiration to use
    tokenService.accessTokenExpirationSeconds instead of hardcoded 60s
  • Wrapped /logout endpoint in authenticate("auth-jwt") for proper
    authentication (security improvement)

Test Changes (Python)

test_server.py

  • Configured E2E tests to use 5-second token expiration via
    --jwt-access-token-expiration 5 for faster test runs
  • Added command logging for troubleshooting

test_auth_e2e.py

  • Renamed test_access_token_expires_after_one_minute to test_access_token_expiration_and_refresh updated the test to wait 8 seconds
    instead of 65 seconds
  • Removed manual cookie workarounds (httpx handles automatically)
  • Updated test_logout_revokes_tokens to expect proper authentication

test_routing_e2e.py

  • Added test_logout_revokes_tokens to verify server-side token
    revocation (70 lines)

Results

  • Test suite runs in ~15 seconds (was ~80 seconds) - 5.3× faster
  • Production behavior unchanged (60-second default)
  • Improved security: logout now requires authentication
  • Cleaner test code: removed 44 lines of manual cookie handling

Configuration

Production (default):
--jwt-access-token-expiration 60

Testing (E2E):
--jwt-access-token-expiration 5

@sip-21 sip-21 force-pushed the add-dynamic-secure-cookie-helper-for-auth-endpoints branch from c597ba9 to 6135ede Compare December 2, 2025 20:27
@sip-21 sip-21 force-pushed the fix-logout-auth-and-token-revocation branch from f3118cd to 4eb0bd4 Compare December 2, 2025 20:55
@sip-21 sip-21 force-pushed the add-dynamic-secure-cookie-helper-for-auth-endpoints branch from 6135ede to e96a468 Compare December 3, 2025 05:32
@sip-21 sip-21 force-pushed the fix-logout-auth-and-token-revocation branch from 8db6050 to da7ebfc Compare December 3, 2025 16:38
@sip-21
Copy link
Owner Author

sip-21 commented Dec 9, 2025

Postpone this for after the workshop presentation!

Sharmaz and others added 25 commits December 18, 2025 16:26
…stall

Functional Refactoring and Installation Robustness
…stall

chore: refactor installation scripts
Solve lint problems in users, and add tests for users
@sip-21 sip-21 changed the base branch from add-dynamic-secure-cookie-helper-for-auth-endpoints to main December 30, 2025 23:32
@sip-21 sip-21 force-pushed the fix-logout-auth-and-token-revocation branch from 2c56aa3 to da7ebfc Compare December 31, 2025 00:30
@sip-21 sip-21 force-pushed the fix-logout-auth-and-token-revocation branch from da7ebfc to ac119a6 Compare December 31, 2025 01:57
@sip-21 sip-21 force-pushed the fix-logout-auth-and-token-revocation branch 2 times, most recently from e50f95a to 1b83112 Compare December 31, 2025 18:10
@sip-21 sip-21 force-pushed the fix-logout-auth-and-token-revocation branch from 1b83112 to 50dca0b Compare January 3, 2026 02:20
sip-21 added 2 commits January 2, 2026 23:38
- Add configurable access token expiration via `--jwt-access-token-expiration` CLI option (default: 60s)
- Wrap `/logout` in `authenticate("auth-jwt")` to require authentication and ensure token revocation
@sip-21 sip-21 force-pushed the fix-logout-auth-and-token-revocation branch from 50dca0b to f3abb3c Compare January 3, 2026 02:47
@sip-21
Copy link
Owner Author

sip-21 commented Jan 5, 2026

Done.

@sip-21 sip-21 closed this Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants