Skip to content

feat: add --client-id and --client-secret flags to login command - #451

Closed
A-d-i-t-y wants to merge 1 commit into
microcks:masterfrom
A-d-i-t-y:feat/login-client-id-secret-flags
Closed

A-d-i-t-y wants to merge 1 commit into
microcks:masterfrom
A-d-i-t-y:feat/login-client-id-secret-flags

Conversation

@A-d-i-t-y

Copy link
Copy Markdown

Summary

Adds --client-id and --client-secret flags to the login command
so client credentials can be passed directly without requiring
environment variables.

Problem

Currently the login command only reads client credentials from
environment variables:

MICROCKS_CLIENT_ID=my-client
MICROCKS_CLIENT_SECRET=my-secret
microcks login http://localhost:8080 --username admin --password secret

This is inconvenient in CI/CD environments where injecting env vars
is not always possible or desirable.

Solution

Added two new flags with environment variables as fallback:

microcks login http://localhost:8080
--username admin
--password secret
--client-id my-client
--client-secret my-secret

If flags are not provided, environment variables are still used
as fallback — no breaking changes.

Files Changed

  • cmd/login.go — added --client-id and --client-secret flags

Previously client credentials could only be provided via environment
variables (MICROCKS_CLIENT_ID, MICROCKS_CLIENT_SECRET). This made it
inconvenient in CI/CD environments where injecting env vars is not
always possible.

Now credentials can be passed directly as CLI flags:
  microcks login http://localhost:8080 \
    --username admin \
    --password secret \
    --client-id my-client \
    --client-secret my-secret

Environment variables are still supported as fallback.

Signed-off-by: Aditya <[email protected]>
@A-d-i-t-y

Copy link
Copy Markdown
Author

Hi @Harsh4902 @Vaishnav88sk @lbroudoux, I have raised this PR to add --client-id and --client-secret flags to the login command. Previously credentials could only be provided via environment variables which is inconvenient in many CI/CD setups. This change adds flag support with environment variables as fallback — no breaking changes. Would love your feedback!

@Vaishnav88sk

Copy link
Copy Markdown
Contributor

@A-d-i-t-y From onwards, please create an issue first, and illustrate the actual problem with reproduction steps (if suitable).

@Vaishnav88sk

Vaishnav88sk commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Before merge, I’d like two small follow-ups:

  • update the command help/examples to show the new flags explicitly, (Check if necessary)
  • add a small test for flag-vs-env behavior (flags provided, env fallback, and flags taking precedence over env vars).

One note to keep in mind in the docs/help: passing secrets via CLI flags is convenient, but it is also more visible in shell history/process lists.

@Harsh4902

Copy link
Copy Markdown
Member

@A-d-i-t-y Thanks for proposing a more convenient way to provide Keycloak client credentials during login.

We’re closing this implementation because the CLI already exposes the inherited --keycloakClientId and --keycloakClientSecret options. Adding another pair of flags would duplicate the existing interface and make credential precedence harder to understand. Passing secrets directly on the command line can also expose them through shell history or process listings.

@Harsh4902 Harsh4902 closed this Nov 12, 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.

3 participants