Skip to content

feat: add auth password-login, pull, and push commands#422

Open
moranshe-max wants to merge 7 commits intomainfrom
feature/add-password-login-command
Open

feat: add auth password-login, pull, and push commands#422
moranshe-max wants to merge 7 commits intomainfrom
feature/add-password-login-command

Conversation

@moranshe-max
Copy link
Collaborator

@moranshe-max moranshe-max commented Mar 17, 2026

Note

Description

This PR introduces a new base44 auth command group that allows developers to manage app authentication settings from the CLI. It adds auth password-login, auth pull, and auth push subcommands, backed by a new auth-config resource module in the core SDK layer. Auth config is also integrated into the deploy pipeline so it is pushed automatically alongside other resources.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Added packages/cli/src/cli/commands/auth/ with three subcommands:
    • auth password-login <enable|disable> — toggles username/password authentication in the local auth config file, with a lockout warning if no login methods remain enabled
    • auth pull — fetches the remote auth config from Base44 and writes it to the local auth/config.jsonc file
    • auth push [-y] — pushes the local auth config to Base44, with an interactive confirmation prompt (skippable with --yes)
  • Added packages/cli/src/core/resources/auth-config/ resource module following the Resource<T> pattern:
    • schema.ts — Zod schemas for AuthConfig, API response, and file format (camelCase ↔ snake_case transforms)
    • api.tsgetAuthConfig() and pushAuthConfigToApi() HTTP client functions
    • config.ts — local file read/write helpers with deep-equality check to avoid unnecessary writes
    • pull.ts / push.ts — resource-level pull/push operations
    • resource.tsResource<AuthConfig> interface implementation for use in readProjectConfig / deployAll
  • Updated core/project/config.ts to read authConfig as part of readProjectConfig()
  • Updated core/project/deploy.ts (hasResourcesToDeploy, deployAll) to include auth config in the deploy pipeline
  • Added authDir field (default "auth") to ProjectConfigSchema
  • Registered getAuthCommand() in program.ts
  • Added integration tests (tests/cli/auth_password_setup.spec.ts) and unit tests (tests/core/auth-password.spec.ts)

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

The auth push command warns users before pushing a config that disables all login methods, preventing accidental lockouts. The password-login command similarly warns when disabling the last remaining login method. The deploy flow integrates auth config seamlessly — if an auth/config.jsonc file exists in the project, it is pushed as part of base44 deploy.


🤖 Generated by Claude | 2026-03-24 00:00 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.47-pr.422.d37d331

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.47-pr.422.d37d331"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.47-pr.422.d37d331"
  }
}

Preview published to npm registry — try new features instantly!

@moranshe-max moranshe-max requested a review from kfirstri March 17, 2026 09:05
@moranshe-max moranshe-max force-pushed the feature/add-password-login-command branch from 53d8672 to 60fd351 Compare March 17, 2026 11:52
@kfirstri kfirstri moved this from Backlog to In review in CLI Development Mar 18, 2026
Copy link
Collaborator

@Paveltarno Paveltarno left a comment

Choose a reason for hiding this comment

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

claude is pretty dumb sometimes

@moranshe-max moranshe-max changed the title feat: add auth password-login command feat: add auth password-login, pull, and push commands Mar 22, 2026
@moranshe-max moranshe-max force-pushed the feature/add-password-login-command branch from 837aaa9 to 3cd3e7a Compare March 22, 2026 12:40
@moranshe-max moranshe-max requested a review from Paveltarno March 22, 2026 13:30
/**
* Returns true if at least one login method is enabled in the given config.
*/
export function hasAnyLoginMethod(config: AuthConfig): boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be in config / schema or somewhere else because it's not really API.ts file


let response: KyResponse;
try {
response = await base44Client.get(`api/apps/${id}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if this should really big in project/api.ts file since it's the entire project data.. but maybe it's a future refactor

* Reads the auth config file from the given directory.
* Returns [config] if the file exists, or [] if the directory or file doesn't exist.
*/
export async function readAuthConfig(authDir: string): Promise<AuthConfig[]> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we returning an array of AuthConfig instead just the AuthConfig? is it possible to have multiple AuthConfigs? 🤔

Comment on lines +81 to +84
export async function updateAuthConfigFile(
authDir: string,
updates: Partial<AuthConfig>,
): Promise<AuthConfig> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we need a read / write / update functions, maybe just read and write? write will also do updates or updates will happen before calling the config.ts?

return;
}

await pushAuthConfigToApi(configs[0]);
Copy link
Collaborator

@kfirstri kfirstri Mar 23, 2026

Choose a reason for hiding this comment

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

I commented it in the config.ts file, can AuthConfig be just singular and not an array? then we don't need to keep putting into an array and out of an array 💪

Comment on lines +82 to +83
.option("--enable", "Enable password authentication")
.option("--disable", "Disable password authentication")
Copy link
Collaborator

Choose a reason for hiding this comment

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

what do you think about using commander's .choices instead of 2 different flags? and then the command will look like base44 auth password-login enable

// something like
.argument('<state>').choices(['enable', 'disable'])

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great tip! Claude claims it's easier for it to consume the cli that way.

const authDir = join(configDir, project.authDir);

const updated = await runTask(
`${shouldEnable ? "Enabling" : "Disabling"} username & password authentication`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe the message should be something like "Updating authenticaiton configuration" or something? so make sure it's only locally

Copy link
Collaborator

Choose a reason for hiding this comment

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

i just saw the outro message, so maybe it's fine

Comment on lines +61 to +63
return await updateAuthConfigFile(authDir, {
enableUsernamePassword: shouldEnable,
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

I also commented baout this inside the updateAuthConfigFile function, i just feel writeAuthConfigFile can do everything?


export function getAuthPullCommand(): Command {
return new Base44Command("pull")
.description("Pull auth config from Base44 to local file")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might worth adding some text about overwriting existing file

Copy link
Collaborator

@kfirstri kfirstri left a comment

Choose a reason for hiding this comment

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

Good work 💪, Added some comments

@moranshe-max moranshe-max force-pushed the feature/add-password-login-command branch from fdced31 to 2916115 Compare March 23, 2026 19:26
onResult: options?.onFunctionResult,
});
await agentResource.push(agents);
if (authConfig) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. You should have a resource.ts file inside resources/auth-config/resource.ts with the "readAll" and "push" command configured, this is basically our interface for resourced, i don't want deploy.ts to be too familiar with resources implementation
  2. move the if(authConfig) check to be inside the resource push function, like all other resourced do

Copy link
Collaborator

@kfirstri kfirstri left a comment

Choose a reason for hiding this comment

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

one small change about adding a resource.ts to the auth-config, and then call the push method from deploy.ts.

@github-project-automation github-project-automation bot moved this from In review to Ready in CLI Development Mar 24, 2026
kfirstri
kfirstri previously approved these changes Mar 24, 2026
Copy link
Collaborator

@kfirstri kfirstri left a comment

Choose a reason for hiding this comment

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

🚀

@github-project-automation github-project-automation bot moved this from Ready to In review in CLI Development Mar 24, 2026
moranshe-max and others added 3 commits March 24, 2026 20:02
Add `base44 auth password-login` command for enabling/disabling username &
password authentication. Introduces the `auth` command group and the core
`auth-config` module with Zod schemas, API client, and camelCase transforms.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove interactive prompts in favor of explicit --enable and --disable flags.
Add comprehensive input validation with agent-friendly error hints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Migrate auth-config from standalone core module to the unified resources
pattern. Add `auth pull` and `auth push` CLI commands for syncing auth
configuration. Extend project config and deploy to support auth-config
as a deployable resource.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
moranshe-max and others added 4 commits March 24, 2026 20:02
Replace removed runCommand/RunCommandResult imports with Base44Command
and import RunCommandResult from @/cli/types.js to match the new
command pattern introduced on main.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move hasAnyLoginMethod from api.ts to schema.ts (not an API concern)
- Use singular AuthConfig | null instead of AuthConfig[] everywhere
- Remove Resource<T> adapter (resource.ts) — call readAuthConfig/pushAuthConfig directly
- Remove updateAuthConfigFile — inline read-merge-write in password-login command
- Switch password-login from --enable/--disable flags to positional argument (enable|disable)
- Update task spinner message to "Updating local auth config"
- Add overwrite warning to auth pull outro message
- Add confirmation prompt and lockout warning to auth push (with --yes flag)
- Update tests for new signatures and positional arg syntax

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ace in deploy

Move auth-config back to the standard Resource<T> pattern so deploy.ts
doesn't need to know about the resource's internal null-vs-array semantics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update password-login, pull, and push commands to receive CLIContext
as the first argument, matching the refactored Base44Command pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants