Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ for machine-readable output: `{"url": …, "confirmation_code": …, "status": "
The credential refreshes itself; `frbit auth status` shows its expiry and the next
setup step.

`--signup` opens the sign-up page, for people without an account.
`--name "<name>"` suggests the name for the new account (1 to 100 characters).
`--name "<name>"` suggests the name for a new account (1 to 100 characters).

In CI or without a browser, store a personal API token from standard input:

Expand Down
8 changes: 4 additions & 4 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ The command prints the sign-in URL and a code first, opens the URL in your defau
|--|--|
| `--no-browser` | Print the URL without opening a browser |
| `--json` | Print `{"url": …, "confirmation_code": …, "status": "waiting"}` at once, then `{"status": "signed_in", "next": …}` |
| `--signup` | Open the sign-up page instead of the login page, for people without an account |
| `--name "<name>"` | Suggest a name for the new account, 1 to 100 characters |
| `--name "<name>"` | Suggest a name for a new account, 1 to 100 characters |

If the person denies the consent request, the browser tab shows "Not connected. Your agent knows; you can close this tab." and the command fails. With `--json` the last line is `{"status": "error", "code": "access_denied", "error": …}`. The consent request is used up, so ask the person before running `frbit auth login` again. Other stable codes: `timeout` and `frbit_token_set`.

Coding agents run `frbit auth login --json` in the background, show the URL to the person, and continue with `next`. For a person without an account they add `--signup`.
Coding agents run `frbit auth login --json` in the background, show the URL to the person, and continue with `next`.

Verify the active credential at any time. It shows the profile, host, credential kind, expiry, and the next setup step. With `--json` it prints one line with `"status": "signed_in"` and the same fields, `{"status": "signed_out"}` (exit 0) without a credential, or `{"status": "error", "error": …}` (exit 1):

Expand Down Expand Up @@ -879,12 +878,13 @@ Behaviour that changed since v1.14.0 and can break a script:
| A path argument with `.` or `..` segments was sent as is | The CLI refuses it before any request |
| `environments list` printed `ID NAME SOFTWARE UPDATED` | It prints `ID APP NAME UPDATED`; `--json` is unchanged |
| A command with nothing linked failed with `no environment for this checkout; …` only | Without a terminal, the environments of the account follow on the next lines; on a terminal it asks |
| `auth login --signup` opened the sign-up page | The flag is gone and fails as unknown: the sign-in page also creates accounts |

## Command reference

| Command | Description |
| --- | --- |
| `frbit auth login` | Sign in through the browser. Accepts `--no-browser`, `--json`, `--signup`, `--name`, and `--token-stdin` for a personal API token. |
| `frbit auth login` | Sign in through the browser. Accepts `--no-browser`, `--json`, `--name`, and `--token-stdin` for a personal API token. |
| `frbit auth status` | Validate the credential selected by `--profile` or `FRBIT_TOKEN` and show its kind, expiry, and the next setup step. Accepts `--json`. |
| `frbit auth logout` | Revoke a browser sign-in and remove the stored credential for the selected profile. |
| `frbit apps list` | List apps. Accepts `--page`, `--limit`, `--all`, repeatable `--id`, and `--json`. |
Expand Down
9 changes: 3 additions & 6 deletions internal/cmd/auth/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ type Options struct {
TokenStdin bool
NoBrowser bool
JSON bool
Signup bool
Name string
Timeout time.Duration
}
Expand All @@ -48,8 +47,7 @@ In CI or without a browser, pipe a personal API token to --token-stdin, or set
FRBIT_TOKEN for each command instead of signing in. With FRBIT_TOKEN set, login
refuses to start, since FRBIT_TOKEN overrides any stored credential.

Use --signup when the person has no fortrabbit account yet: the browser opens the
sign-up page instead of the login page. --name suggests the name for the new
The sign-in page also creates accounts. --name suggests the name for a new
account (1 to 100 characters); pass only a name the person gave you or their git user.name.

With --json, a failure prints {"status": "error", "code": …, "error": …}. The code is
Expand All @@ -65,7 +63,7 @@ func NewCmdLogin(factory *app.Factory, runF func(*Options) error) *cobra.Command
Long: longHelp,
Example: ` frbit auth login
frbit auth login --json
frbit auth login --signup --name "Ada Lovelace"
frbit auth login --name "Ada Lovelace"
printf '%s' "$TOKEN" | frbit auth login --token-stdin`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -79,7 +77,6 @@ func NewCmdLogin(factory *app.Factory, runF func(*Options) error) *cobra.Command
command.Flags().BoolVar(&options.TokenStdin, "token-stdin", false, "Read a personal API token from standard input instead of signing in")
command.Flags().BoolVar(&options.NoBrowser, "no-browser", false, "Print the sign-in URL without opening a browser")
command.Flags().BoolVar(&options.JSON, "json", false, "Print the sign-in URL, the confirmation code and the result as JSON lines")
command.Flags().BoolVar(&options.Signup, "signup", false, "Open the sign-up page, for people without an account")
command.Flags().StringVar(&options.Name, "name", "", "Suggest a name for the new account")
return command
}
Expand Down Expand Up @@ -141,7 +138,7 @@ func runBrowser(options *Options) error {
}

out := command.OutOrStdout()
loginOptions := oauth.Options{Signup: options.Signup, NameHint: options.Name, Host: host, DashboardURL: dashboardURL, Out: out, Timeout: options.Timeout, HTTPClient: options.Factory.HTTPClient}
loginOptions := oauth.Options{NameHint: options.Name, Host: host, DashboardURL: dashboardURL, Out: out, Timeout: options.Timeout, HTTPClient: options.Factory.HTTPClient}
if !options.NoBrowser {
loginOptions.OpenBrowser = options.Factory.OpenBrowser
}
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/auth/login/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,15 @@ func TestLoginJSONLinesAreNotEscaped(t *testing.T) {
}
}

func TestLoginSignupAndNameReachTheAuthorizeURL(t *testing.T) {
func TestLoginNameReachesTheAuthorizeURL(t *testing.T) {
cases := []struct {
extra []string
noBrowser bool
}{{nil, false}, {[]string{"--json"}, false}, {[]string{"--no-browser", "--json"}, true}}
for _, tc := range cases {
fake := newFakeAPI(t)
factory, _, _ := loginFactory(t, fake)
args := append([]string{"--signup", "--name", "Ada Lovelace & Co"}, tc.extra...)
args := append([]string{"--name", "Ada Lovelace & Co"}, tc.extra...)
var err error
if tc.noBrowser {
writer := &urlWriter{onURL: fake.approve(t)}
Expand All @@ -491,13 +491,13 @@ func TestLoginSignupAndNameReachTheAuthorizeURL(t *testing.T) {
fake.mu.Lock()
query := fake.authorize
fake.mu.Unlock()
if query.Get("prompt") != "create" || query.Get("name_hint") != "Ada Lovelace & Co" {
if query.Has("prompt") || query.Get("name_hint") != "Ada Lovelace & Co" {
t.Fatalf("login %v authorize query = %v", args, query)
}
}
}

func TestLoginWithoutSignupSendsNeitherParameter(t *testing.T) {
func TestLoginWithoutNameSendsNeitherParameter(t *testing.T) {
fake := newFakeAPI(t)
factory, _, _ := loginFactory(t, fake)
if _, err := executeLogin(t, factory, fake.URL); err != nil {
Expand All @@ -515,7 +515,7 @@ func TestLoginRejectsInvalidNameBeforeOpeningTheBrowser(t *testing.T) {
fake := newFakeAPI(t)
factory, _, _ := loginFactory(t, fake)
factory.OpenBrowser = func(string) error { t.Error("browser opened for an invalid name"); return nil }
output, err := executeLogin(t, factory, fake.URL, "--signup", "--name", name, "--json")
output, err := executeLogin(t, factory, fake.URL, "--name", name, "--json")
if err == nil || !strings.Contains(err.Error(), "--name") {
t.Fatalf("name %q: error = %v", name, err)
}
Expand Down
5 changes: 0 additions & 5 deletions internal/oauth/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ type Options struct {
HTTPClient *http.Client
// OnURL replaces the default sign-in prompt on Out, for machine-readable output. It gets the URL and the confirmation code.
OnURL func(authorizeURL string, confirmationCode string) error
// Signup sends prompt=create, so a person without an account lands on the sign-up page.
Signup bool
// NameHint suggests the name for a new account, sent as name_hint.
NameHint string
}
Expand Down Expand Up @@ -422,9 +420,6 @@ func (m serverMetadata) authorizeURL(redirectURI string, challenge string, confi
query.Set("code_challenge_method", "S256")
query.Set("state", state)
query.Set("confirmation_challenge", confirmation)
if options.Signup {
query.Set("prompt", "create")
}
if options.NameHint != "" {
query.Set("name_hint", options.NameHint)
}
Expand Down
11 changes: 4 additions & 7 deletions internal/oauth/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,14 @@ func TestHumanDuration(t *testing.T) {
}
}

func TestLoginAuthorizeURLCarriesSignupAndNameHint(t *testing.T) {
func TestLoginAuthorizeURLCarriesNameHint(t *testing.T) {
cases := []struct {
name string
options Options
prompt string
hint string
}{
{"plain", Options{}, "", ""},
{"signup", Options{Signup: true}, "create", ""},
{"name", Options{NameHint: "Ada Lovelace"}, "", "Ada Lovelace"},
{"both", Options{Signup: true, NameHint: "Ada & Co"}, "create", "Ada & Co"},
{"plain", Options{}, ""},
{"name", Options{NameHint: "Ada & Co"}, "Ada & Co"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand All @@ -584,7 +581,7 @@ func TestLoginAuthorizeURLCarriesSignupAndNameHint(t *testing.T) {
t.Fatal(err)
}
query := authorize.Query()
if query.Get("prompt") != tc.prompt || query.Get("name_hint") != tc.hint || query.Has("prompt") != (tc.prompt != "") || query.Has("name_hint") != (tc.hint != "") {
if query.Has("prompt") || query.Get("name_hint") != tc.hint || query.Has("name_hint") != (tc.hint != "") {
t.Fatalf("query = %v", query)
}
})
Expand Down