feat: git credential backend for credential storage (#371)
## Problem
Credentials were stored as plaintext JSON in
`stdpath('data')/cp-nvim.json`, with no integration with system
credential managers.
## Solution
Replace file-based credential storage with `git credential
fill/approve/reject`, delegating to whatever credential helper the user
has configured (`cache`, `store`, `libsecret`, macOS Keychain, etc.).
- New `lua/cp/git_credential.lua` module wrapping the git credential
protocol
- All credential consumers (`credentials.lua`, `submit.lua`,
`scraper.lua`) use `git_credential` directly — `cache.lua` no longer
handles credentials
- CSES API token packed into the password field (`password<TAB>token`)
so it works with helpers that ignore the `path` field
- `has_helper()` guard on `:CP login`, `:CP logout`, and `:CP submit`
with an error message if no helper is configured
- Healthcheck split into `[required]`/`[optional]` sections; git version
and credential helper status shown
- `git` checked at startup in `check_required_runtime()`
- Cache version system (`CACHE_VERSION`, v1→v2 migration) removed — the
cache file is now a plain JSON blob
- `:CP` command gets `bar = true`
This commit is contained in:
parent
27d7a4e6b5
commit
da4e2ebeba
12 changed files with 283 additions and 150 deletions
|
|
@ -49,7 +49,8 @@ REQUIREMENTS *cp-requirements*
|
|||
|
||||
- Neovim 0.10.0+
|
||||
- Unix-like operating system
|
||||
- uv package manager (https://docs.astral.sh/uv/)
|
||||
- (Optional) git 1.7.9+ (credential storage)
|
||||
- (Optional) uv package manager (https://docs.astral.sh/uv/)
|
||||
|
||||
==============================================================================
|
||||
SETUP *cp-setup*
|
||||
|
|
@ -998,8 +999,15 @@ CREDENTIALS *cp-credentials*
|
|||
|
||||
Manage stored login credentials for platform submission.
|
||||
|
||||
Credentials are stored under _credentials in the main cache file
|
||||
(stdpath('data')/cp-nvim.json). Use :CP cache read to inspect them.
|
||||
Credentials are stored via git-credential(1), using whatever credential
|
||||
helper is configured in your git config (macOS Keychain, libsecret,
|
||||
credential-store, etc.). Git is required. Cookie files
|
||||
(~/.cache/cp-nvim/cookies.json) are unaffected.
|
||||
|
||||
To inspect stored credentials:
|
||||
>sh
|
||||
printf 'protocol=https\nhost=cses.fi\n\n' | git credential fill
|
||||
<
|
||||
|
||||
:CP login [platform]
|
||||
Set or update credentials for a platform. Prompts for username
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue