Add CLI authentication and automatic SDK credential loading - #90
Add CLI authentication and automatic SDK credential loading#90Gautam8387 wants to merge 4 commits into
Conversation
PR Summary by QodoAdd CLI authentication (
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Code Review by Qodo
1.
|
|
Bind every token to the exact API URL where it was supplied. # During initialization
self._auth_token_api_url = self.api_url if auth_token else NoneThen change token resolution so:
if auth_token:
self.auth_token = auth_token
self._auth_token_api_url = normalized_api_url
return auth_token
if self.auth_token and self._auth_token_api_url == normalized_api_url:
return self.auth_tokenKeep the API URL in AnnData so old jobs can be retrieved, but treat it as untrusted. Validate it and never pair it with a token bound to another URL. Add tests proving that a modified job URL raises and that no upload, submission, polling, or result request occurs |
Summary
This PR adds a packaged
cytetypecommand-line interface and connects it to the existing Python SDK.Users can authenticate once through their browser with
cytetype setup. The resulting API key is stored in an owner-only local credential file and automatically used by subsequent SDK annotation and upload requests.Users can also save an existing API key using
cytetype login.CLI commands
cytetype setupcytetype get-keycytetype setup.cytetype logincytetype dashboardcytetype view JOB_IDcytetype logoutcytetype --versionCredential storage
Credentials are stored in:
$XDG_CONFIG_HOME/cytetype/credentials.jsonwhen configured.%APPDATA%/cytetype/credentials.jsonon Windows.~/.config/cytetype/credentials.jsonby default.The credential file contains:
Storage behavior:
0600.