-
Notifications
You must be signed in to change notification settings - Fork 4
fix(macos): store desktop secrets in Keychain #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
veryCrunchy
wants to merge
12
commits into
main
Choose a base branch
from
fix/macos-keychain-secret-store
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
89caf2d
fix(macos): store desktop secrets in Keychain
veryCrunchy 74f6daa
fix(macos): migrate credentials and recover locked storage
veryCrunchy 266fc94
chore(website): refresh marketing captures
obiente-automations[bot] 777213b
fix(macos): harden secret migration recovery
veryCrunchy 323f801
fix(macos): keep credential recovery actionable
veryCrunchy 121797e
fix(macos): preserve legacy credential recovery
veryCrunchy c855635
chore(website): refresh marketing captures
obiente-automations[bot] 16380e7
fix(macos): create fresh draft keys without legacy storage
veryCrunchy e246a78
fix(macos): recover keychain cleanup after sign-out
veryCrunchy 86a1005
chore(website): refresh marketing captures
obiente-automations[bot] 962e6b8
fix(macos): preserve draft and legacy recovery
veryCrunchy 5d05fde
fix(macos): finish credential cleanup recovery
veryCrunchy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| category: fix | ||
| issue: 335 | ||
| pull: 430 | ||
| platforms: macos | ||
| user-facing: yes | ||
|
|
||
| Store desktop login credentials and Deck draft keys in macOS Keychain, migrate Secret Service values, and keep locked access and sign-out cleanup retryable. Preserve encrypted Deck drafts instead of replacing a missing key. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
ui/src/commonMain/kotlin/dev/obiente/nextcloudnative/app/NextcloudSessionLoading.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package dev.obiente.nextcloudnative.app | ||
|
|
||
| import kotlinx.coroutines.CancellationException | ||
|
|
||
| internal open class NextcloudSessionStorageUnavailableException( | ||
| message: String, | ||
| cause: Throwable? = null, | ||
| ) : IllegalStateException(message, cause) | ||
|
|
||
| internal class NextcloudSessionLegacyMigrationUnavailableException( | ||
| cause: Throwable, | ||
| ) : NextcloudSessionStorageUnavailableException( | ||
| "The legacy secure-storage provider required for session migration is unavailable.", | ||
| cause, | ||
| ) | ||
|
|
||
| internal sealed interface NextcloudSessionLoadState { | ||
| data class Loaded(val session: NextcloudSession?) : NextcloudSessionLoadState | ||
|
|
||
| data object SecureStorageUnavailable : NextcloudSessionLoadState | ||
|
|
||
| data object LegacyMigrationUnavailable : NextcloudSessionLoadState | ||
| } | ||
|
|
||
| internal fun loadNextcloudSessionSafely( | ||
| loadSession: () -> NextcloudSession?, | ||
| ): NextcloudSessionLoadState = try { | ||
| NextcloudSessionLoadState.Loaded(loadSession()) | ||
| } catch (failure: CancellationException) { | ||
| throw failure | ||
| } catch (_: NextcloudSessionLegacyMigrationUnavailableException) { | ||
| NextcloudSessionLoadState.LegacyMigrationUnavailable | ||
| } catch (_: NextcloudSessionStorageUnavailableException) { | ||
| NextcloudSessionLoadState.SecureStorageUnavailable | ||
|
veryCrunchy marked this conversation as resolved.
|
||
| } | ||
90 changes: 90 additions & 0 deletions
90
ui/src/commonMain/kotlin/dev/obiente/nextcloudnative/app/NextcloudStatusMessages.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package dev.obiente.nextcloudnative.app | ||
|
|
||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.material3.CircularProgressIndicator | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.OutlinedButton | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.unit.dp | ||
| import dev.obiente.nextcloudnative.app.design.NextcloudIcons | ||
| import dev.obiente.nextcloudnative.app.design.NextcloudSpacing | ||
|
|
||
| @Composable | ||
| internal fun LoadingMessage(message: String) { | ||
| Column( | ||
| modifier = Modifier.fillMaxSize(), | ||
| horizontalAlignment = Alignment.CenterHorizontally, | ||
| verticalArrangement = Arrangement.Center, | ||
| ) { | ||
| CircularProgressIndicator() | ||
| Text(message, modifier = Modifier.padding(top = NextcloudSpacing.Large)) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun EmptyMessage(message: String) { | ||
| Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { | ||
| Text(message, modifier = Modifier.padding(NextcloudSpacing.XLarge), color = MaterialTheme.colorScheme.onSurfaceVariant) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun ErrorMessage(message: String, onRetry: (() -> Unit)? = null) { | ||
| Column(modifier = Modifier.padding(NextcloudSpacing.XLarge), verticalArrangement = Arrangement.spacedBy(12.dp)) { | ||
| Icon(NextcloudIcons.Error, contentDescription = null, tint = MaterialTheme.colorScheme.error) | ||
| Text(message, color = MaterialTheme.colorScheme.error) | ||
| onRetry?.let { retry -> OutlinedButton(onClick = retry) { Text("Try again") } } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun SecureSessionStorageUnavailable( | ||
| onRetry: () -> Unit, | ||
| onSignInAgain: () -> Unit, | ||
| ) { | ||
| Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { | ||
| Column( | ||
| modifier = Modifier.padding(NextcloudSpacing.XLarge), | ||
| verticalArrangement = Arrangement.spacedBy(12.dp), | ||
| ) { | ||
| Icon(NextcloudIcons.Error, contentDescription = null, tint = MaterialTheme.colorScheme.error) | ||
| Text( | ||
| "Secure session storage is locked or unavailable. Unlock it or allow " + | ||
| "Nextcloud Native access, then try again, or discard the stored session and sign in again.", | ||
| color = MaterialTheme.colorScheme.error, | ||
| ) | ||
| OutlinedButton(onClick = onRetry) { Text("Try again") } | ||
| OutlinedButton(onClick = onSignInAgain) { Text("Sign in again") } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun LegacySessionMigrationUnavailable( | ||
| onRetry: () -> Unit, | ||
| onSignInAgain: () -> Unit, | ||
| ) { | ||
| Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { | ||
| Column( | ||
| modifier = Modifier.padding(NextcloudSpacing.XLarge), | ||
| verticalArrangement = Arrangement.spacedBy(12.dp), | ||
| ) { | ||
| Icon(NextcloudIcons.Error, contentDescription = null, tint = MaterialTheme.colorScheme.error) | ||
| Text( | ||
| "The previous session needs the legacy secure-storage provider. Install the provider " + | ||
| "and try again, or discard the stored session and sign in again.", | ||
| color = MaterialTheme.colorScheme.error, | ||
| ) | ||
| OutlinedButton(onClick = onRetry) { Text("Try again") } | ||
| OutlinedButton(onClick = onSignInAgain) { Text("Sign in again") } | ||
| } | ||
| } | ||
| } |
53 changes: 53 additions & 0 deletions
53
ui/src/commonTest/kotlin/dev/obiente/nextcloudnative/app/NextcloudSessionLoadingTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package dev.obiente.nextcloudnative.app | ||
|
|
||
| import kotlin.test.Test | ||
| import kotlin.test.assertEquals | ||
| import kotlin.test.assertFailsWith | ||
| import kotlin.test.assertIs | ||
| import kotlinx.coroutines.CancellationException | ||
|
|
||
| class NextcloudSessionLoadingTest { | ||
| @Test | ||
| fun secureStorageFailureBecomesRetryableWithoutExposingItsMessage() { | ||
| var attempts = 0 | ||
| val expected = NextcloudSession("https://cloud.invalid", "alice", "synthetic-secret") | ||
| val load = { | ||
| attempts += 1 | ||
| if (attempts == 1) throw NextcloudSessionStorageUnavailableException("private provider failure") | ||
| expected | ||
| } | ||
|
|
||
| assertEquals( | ||
| NextcloudSessionLoadState.SecureStorageUnavailable, | ||
| loadNextcloudSessionSafely(load), | ||
| ) | ||
| val recovered = assertIs<NextcloudSessionLoadState.Loaded>(loadNextcloudSessionSafely(load)) | ||
| assertEquals(expected, recovered.session) | ||
| } | ||
|
|
||
| @Test | ||
| fun cancellationRemainsControlFlow() { | ||
| assertFailsWith<CancellationException> { | ||
| loadNextcloudSessionSafely { throw CancellationException("cancelled") } | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun missingLegacyMigrationProviderKeepsItsRecoveryCategory() { | ||
| assertEquals( | ||
| NextcloudSessionLoadState.LegacyMigrationUnavailable, | ||
| loadNextcloudSessionSafely { | ||
| throw NextcloudSessionLegacyMigrationUnavailableException( | ||
| NextcloudSessionStorageUnavailableException("private provider failure"), | ||
| ) | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun unrelatedProgrammingFailureIsNotPresentedAsUnavailableStorage() { | ||
| assertFailsWith<IllegalStateException> { | ||
| loadNextcloudSessionSafely { error("synthetic invariant failure") } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.