Add credential system for external platform authentication#710
Draft
Irozuku wants to merge 35 commits into
Draft
Add credential system for external platform authentication#710Irozuku wants to merge 35 commits into
Irozuku wants to merge 35 commits into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds an extensible authentication system for external platforms, driven by the backend. A new BaseCredential component type lets the app authenticate against HuggingFace and Kaggle, persists keys encrypted at rest, and exposes them through a REST API and a global "Credentials" manager modal. Components can now declare REQUIRED_CREDENTIALS / OPTIONAL_CREDENTIALS; the registry tracks a credentials_satisfied flag per component and the frontend reflects availability (locked and disabled cards when a required credential is missing, a key hint for optional ones). StableDiffusionV3 now requires a HuggingFace credential instead of a dedicated key field, and the HuggingFace dataset source uses it optionally.
Type of Change
Changes (by file)
Credentials core (backend)
DashAI/back/credentials/base_credential.py:BaseCredentialABC (TYPE="Credential"); abstractverify()with shared concreteauth(),get_key(),is_authenticated(),apply().DashAI/back/credentials/huggingface_credential.py,kaggle_credential.py,github_credential.py: platform implementations (HuggingFace viahuggingface_hub, Kaggle via the officialkagglelibrary with an env guard so it does not exit on import, GitHub via the official REST API).DashAI/back/credentials/encryptor.py: Fernet encryption plus key bootstrap (env var or a key file).DashAI/back/credentials/store.py:CredentialStore, the single boundary for the DB and encryption.DashAI/back/credentials/sync.py: refreshes thecredentials_satisfiedflags from stored statuses.Registry and wiring (backend)
DashAI/back/dependencies/registry/relationship_manager.py: relations are now typed (compatible_components,required_credentials,optional_credentials) using a nested dict.DashAI/back/dependencies/registry/component_registry.py: registers credential relations, exposesrequired_credentials/optional_credentialsandcredentials_satisfied, and addsrefresh_credentials_status.DashAI/back/config_object.py:get_credential(name)helper available to any component.DashAI/back/container.py,config.py,dependencies/config_builder.py: build the encryptor and store and resolve the key path.DashAI/back/initial_components.py: register the three credential components.DashAI/back/api/api_v1/endpoints/plugins.py: sync credential flags on plugin install.Persistence (backend)
DashAI/back/dependencies/database/models.pyandalembic/.../d4e8a2c6f0b1_add_credential_table.py: newcredentialtable (encrypted key, verified flag).API (backend)
DashAI/back/api/api_v1/endpoints/credentials.pyandapi.py:GET /credential/,GET /credential/{name},POST /credential/{name}/auth,DELETE /credential/{name}.Component auth (backend)
DashAI/back/models/hugging_face/stable_diffusion_v3_model.py: declaresREQUIRED_CREDENTIALS=["HuggingFaceCredential"], removes thehuggingface_keyschema field, and logs in viaget_credential().apply().DashAI/back/dataset_sources/huggingface_dataset_source.py: declaresOPTIONAL_CREDENTIALS=["HuggingFaceCredential"].Frontend
api/credentials.ts,types/credential.ts,types/component.ts: credential client and types; the component type gains the credential fields.components/credentials/CredentialsDialog.jsx,CredentialsButton.jsx,ResponsiveAppBar.jsx: global Credentials manager (gear button) with verify and remove, key shown (masked by default with a reveal toggle).components/custom/ComponentSelector.jsx: lock icon and disabled card when a required credential is missing; key icon for optional credentials.hooks/useComponentAvailability.js: availability helper.utils/i18n/index.jsandlocales/{en,es,pt,de,zh}/credentials.json: translations.Packaging
requirements.txt: addcryptographyandkaggle.Testing
pytest tests/back). New coverage undertests/back/credentials/(encryptor, store, base and concrete credentials,get_credential),tests/back/registries/(typed relations, credential tracking), andtests/back/api/test_credentials_api.py.Notes
DASHAI_CREDENTIALS_SECRETor an auto generated~/.DashAI/.credentials_key.credentials_satisfied, which covers required credentials only), a candidate follow up.github_credential.py) is implemented and tested but not registered ininitial_components.py, so it does not appear in the Credentials modal. Re list it there to enable it.