Skip to content

⚙️ FEATURE-#269: Add dotflow login with device flow and config file#271

Merged
FernandoCelmer merged 28 commits intodevelopfrom
feature/269
Apr 15, 2026
Merged

⚙️ FEATURE-#269: Add dotflow login with device flow and config file#271
FernandoCelmer merged 28 commits intodevelopfrom
feature/269

Conversation

@FernandoCelmer
Copy link
Copy Markdown
Member

@FernandoCelmer FernandoCelmer commented Apr 15, 2026

Description

Add dotflow login with device flow and config file management

Summary

  • dotflow login opens the browser, shows the user_code, polls /auth/cli/token, and saves the resulting API token to ~/.dotflow/config.toml.
  • dotflow logout removes the saved config.
  • New dotflow/core/config_file.py with TOML-minimal reader/writer and an env-over-file resolve() helper.
  • ServerDefault now resolves SERVER_BASE_URL / SERVER_USER_TOKEN via resolve() so env wins and the config file is the fallback — CI/CD keeps working when env vars are set, and interactive users get the saved token.
  • dotflow login tries https://www.host.dotflow.io/api/v1 first, then https://www.lib.dotflow.io/api/v1 on RequestException. --base-url / SERVER_BASE_URL skip the fallback.
  • Non-interactive dotflow login --token <t> bypasses the browser for CI.

Motivation and Context

Closes #269

Types of changes

  • New feature (change which adds functionality)

Test plan

  • ruff check + ruff format --check.
  • pytest tests/cli tests/core — includes 16 new tests (login device flow, base-url fallback, explicit-wins, logout noop/cleanup, config file roundtrip, 0600 perms, env-over-file precedence).

Checklist

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the CHANGELOG
  • I have updated the documentation accordingly

Pairs with:

  • dotflow-io/dotflow-api#121 — backend endpoints
  • dotflow-io/dotflow-frontend#127 — authorize page

Copy link
Copy Markdown
Member Author

@FernandoCelmer FernandoCelmer left a comment

Choose a reason for hiding this comment

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

🔍 Code Review

Code issues found: 2

# Severity Comment
1 [Suggestion] Token file race: writable before chmod
2 [Suggestion] slow_down aborts login flow (RFC 8628)

Comment thread dotflow/core/config_file.py
Comment thread dotflow/cli/commands/login.py
@FernandoCelmer FernandoCelmer added enhancement New feature or request 1.0.0 labels Apr 15, 2026
Comment thread dotflow/cli/commands/login.py
Copy link
Copy Markdown
Member Author

@FernandoCelmer FernandoCelmer left a comment

Choose a reason for hiding this comment

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

🔍 Code Review (Re-review)

Previous issues: 2/2 fixed ✓

New issues found: 1

# Severity Comment
1 [Suggestion] Unbounded interval growth on repeated slow_down

@FernandoCelmer FernandoCelmer merged commit aebb38f into develop Apr 15, 2026
10 checks passed
@FernandoCelmer FernandoCelmer deleted the feature/269 branch April 15, 2026 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.0.0 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant