Skip to content

Add CredentialManager absctract class #71

Open
alberefe wants to merge 1 commit intochaoss:mainfrom
alberefe:Library-Standalone-Credential-manager
Open

Add CredentialManager absctract class #71
alberefe wants to merge 1 commit intochaoss:mainfrom
alberefe:Library-Standalone-Credential-manager

Conversation

@alberefe
Copy link
Contributor

@alberefe alberefe commented Mar 3, 2026

Add CredentialManager ABC with a resolve_credentials() Template Method
that orchestrates login, secret fetching, field extraction, and logout
in a single call. This allows any caller (BackendCommand, KingArthur,
scripts) to resolve secrets without depending on Perceval's CLI layer.

  • Add CredentialManager ABC as base class for credential managers
  • Add resolve_credentials() with field extraction loop and login/logout
    lifecycle management
  • Fix BitwardenManager logout to clean up temporary appdata directory
  • Document usage in README

@alberefe alberefe force-pushed the Library-Standalone-Credential-manager branch 3 times, most recently from 984f30a to a91b6fb Compare March 8, 2026 14:44
@alberefe
Copy link
Contributor Author

alberefe commented Mar 9, 2026

@sduenas Changes for dealing with credentials with same format of perceval are up.

Copy link
Member

@sduenas sduenas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make more sense if this code is part of the credentials manager of each provider/service. I think how to access to the credentials/fields should be encapsulated on each provider's class. The behavior is different for each manager, so I think the access should be transparent for the client.

You can create an abstract class that BitwardenManager and HashicorpManager need to implement, now that we know what similarities they have. The resolve_credentials function duplicates code for both managers. I think you can make it more generic if needed, by including the specific code of each manager in a method classes have to implement, and that resolve_credentials will call.

Also, I don't think we need a factory because we only have two different classes.

Add CredentialManager ABC with a resolve_credentials() Template Method
that orchestrates login, secret fetching, field extraction, and logout
in a single call. This allows any caller (BackendCommand, KingArthur,
scripts) to resolve secrets without depending on Perceval's CLI layer.

- Add CredentialManager ABC as base class for credential managers
- Add resolve_credentials() with field extraction loop and login/logout
  lifecycle management
- Fix BitwardenManager logout to clean up temporary appdata directory
- Document usage in README

Signed-off-by: Alberto Ferrer Sánchez <alberefe@gmail.com>
@alberefe alberefe force-pushed the Library-Standalone-Credential-manager branch from a91b6fb to 1bbb0bf Compare March 16, 2026 15:43
@alberefe
Copy link
Contributor Author

alberefe commented Mar 16, 2026

Hi.
So I've tried to implement your ideas. Kept the resolve_credentials() function in credential_manager.py creating a unified interface for all the managers.

I say I've tried cause not sure if it's what you meant. It does work by itself, tests pass and it works with perceval. Also works as standalone library and does not need cli to work.

Removed the factory, left the ABC CredentialManager.

Tell me your thoughts!

Also, i added a temp file creation by bw_manager and modified the logout cause sometimes the previous stale session would give problems, so solved it with this using info from the docs of Bitwarden CLI on how to run parallel sessions of the tool.

@alberefe alberefe requested a review from sduenas March 16, 2026 15:46
@alberefe alberefe changed the title Add resolve_credentials() for standalone credential resolution Add CredentialManager absctract class Mar 17, 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.

2 participants