Skip to content

Feature/support oauth2 secret in keyring#17

Open
notthatjesus wants to merge 7 commits into
ssp-data:mainfrom
notthatjesus:feature/support-oauth2-secret-in-keyring
Open

Feature/support oauth2 secret in keyring#17
notthatjesus wants to merge 7 commits into
ssp-data:mainfrom
notthatjesus:feature/support-oauth2-secret-in-keyring

Conversation

@notthatjesus
Copy link
Copy Markdown
Contributor

What is it about

This PR implements the same feature to store the password in the OS keyring to support as well the oauth2_secret.

How does it work

It follows the same implementation as the password storage with the difference that it uses the key: account/account_name/oauth2_client_secret to store it.

Additional features

It reuses the code that was created for the set-password command and registers a set-oauth2-secret. While the set-password command is not wired to the keyring SetPassword() function, the new command calls SetClientSecret(). I will send an additional PR to do the same for SetPassword.

How to test

Store your oauth2_client_secret using secret-tool

secret-tool store --label "neomd Personal" service neomd username account/Personal/oauth2_client_secret

Replace the actual oauth2_client_secret field in config.toml to keyring

[[accounts]]
name = "NAME"
auth_type = "oauth2"
imap = "outlook.office365.com:993"
smtp = "smtp.office365.com:587"
user = "you@example.com"
from = "My Name"
oauth2_client_id = "xxxx-xxxxx-xxxxx"
oauth2_client_secret = "keyring"

Start neomd normally

Adds clientSecretKey(), GetClientSecret(), SetClientSecret(), and
DeleteClientSecret() for OAuth2 client secrets, stored under
account/<name>/oauth2_client_secret — separate from the password slot.
Adds resolveKeyringClientSecret() mirroring resolveKeyringPassword().
Setting oauth2_client_secret = "keyring" in config.toml now causes
Load() to fetch the secret from the OS keyring instead of using the
sentinel as a literal value.
Adds TestResolveKeyringClientSecret (four sub-tests: resolved, missing,
passthrough, empty account) and TestLoad_KeyringResolvesClientSecret
(end-to-end Load() coverage) mirroring the existing password tests.
Extends the promptType enum with promptOAuth2Secret and adds matching
title/hint text in View() so the same masked-input dialog can be used
for OAuth2 client secrets.
Adds statePasswordPrompt viewState, passwordPrompt field, and handlers
for passwordSubmittedMsg and passwordCancelledMsg. On submit, dispatches
to keyring.SetClientSecret or keyring.SetPassword depending on prompt type.
Wires the new command to the password prompt in promptOAuth2Secret mode,
allowing users to store the OAuth2 client secret in the OS keyring from
within the TUI.
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.

1 participant