feat: store OAuth tokens securely

Add bounded token response parsing with refresh-token retention and a cancellable worker-thread libsecret adapter using versioned credential payloads.

Verify CRUD, isolation, cancellation, corruption, unavailable service, redaction, and cleanup against an isolated D-Bus and gnome-keyring Secret Service in normal, warning-as-error, and sanitizer profiles.
This commit is contained in:
2026-07-18 11:56:04 +01:00
parent 295acbc125
commit 3560a7d23d
13 changed files with 1405 additions and 27 deletions

View File

@@ -15,7 +15,10 @@ inc = include_directories('include')
sqlite = dependency('sqlite3')
libcrypto = dependency('libcrypto')
libcurl = dependency('libcurl')
libsecret = dependency('libsecret-1')
nlohmann_json = dependency('nlohmann_json')
threads = dependency('threads')
shell = find_program('sh')
nocal_sources = files(
'src/domain/calendar_transfer.cpp',
'src/domain/date.cpp',
@@ -26,15 +29,17 @@ nocal_sources = files(
'src/sync/curl_http.cpp',
'src/sync/desktop_oauth.cpp',
'src/sync/oauth.cpp',
'src/sync/oauth_tokens.cpp',
'src/sync/secret_store.cpp',
'src/tui/Screen.cpp',
'src/tui/EventEditor.cpp',
'src/tui/Terminal.cpp',
'src/tui/TuiApp.cpp',
)
nocal_lib = static_library('nocal-core', nocal_sources, include_directories: inc,
dependencies: [sqlite, libcrypto, libcurl])
dependencies: [sqlite, libcrypto, libcurl, libsecret, nlohmann_json])
nocal_dep = declare_dependency(include_directories: inc, link_with: nocal_lib,
dependencies: [sqlite, libcrypto, libcurl])
dependencies: [sqlite, libcrypto, libcurl, libsecret, nlohmann_json])
nocal_executable = executable('nocal', 'src/main.cpp',
dependencies: nocal_dep, install: true)
@@ -63,6 +68,13 @@ test('curl-http', curl_http_tests)
desktop_oauth_tests = executable('desktop-oauth-tests',
'tests/desktop_oauth_tests.cpp', dependencies: [nocal_dep, threads])
test('desktop-oauth', desktop_oauth_tests)
oauth_token_tests = executable('oauth-token-tests',
'tests/oauth_token_tests.cpp', dependencies: nocal_dep)
test('oauth-tokens', oauth_token_tests)
secret_store_tests = executable('secret-store-tests',
'tests/secret_store_tests.cpp', dependencies: nocal_dep)
test('secret-store', shell,
args: [files('tests/run_secret_store_test.sh'), secret_store_tests])
tui_tests = executable('tui-tests', 'tests/tui_tests.cpp',
dependencies: nocal_dep)
test('tui', tui_tests)
@@ -73,7 +85,6 @@ editor_tests = executable('editor-tests', 'tests/editor_tests.cpp',
dependencies: nocal_dep)
test('editor', editor_tests)
shell = find_program('sh')
test('cli-recovery', shell,
args: [files('tests/cli_recovery_test.sh'), nocal_executable])
test('cli-transfer', shell,