Skip to content

Commit 92685b8

Browse files
committed
Update auth.py with changes
1 parent 380818d commit 92685b8

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

cloudsmith_cli/cli/commands/auth.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616
AUTH_SERVER_PORT = 12400
1717

1818

19-
def _perform_saml_authentication(opts, owner, enable_token_creation=False):
19+
def _perform_saml_authentication(opts, owner, enable_token_creation=False, json=False):
2020
"""Perform SAML authentication via web browser and local web server."""
2121
session = create_configured_session(opts)
2222
api_host = opts.api_config.host
2323

2424
idp_url = get_idp_url(api_host, owner, session=session)
25-
click.echo(
26-
f"Opening your organization's SAML IDP URL in your browser: {click.style(idp_url, bold=True)}"
27-
)
25+
if not json:
26+
click.echo(
27+
f"Opening your organization's SAML IDP URL in your browser: {click.style(idp_url, bold=True)}"
28+
)
2829
click.echo()
2930
webbrowser.open(idp_url)
30-
click.echo("Starting webserver to begin authentication ... ")
31+
if not json:
32+
click.echo("Starting webserver to begin authentication ... ")
3133

3234
auth_server = AuthenticationWebServer(
3335
(AUTH_SERVER_HOST, AUTH_SERVER_PORT),
@@ -86,13 +88,16 @@ def authenticate(ctx, opts, owner, token, force, save_config, json):
8688
"""Authenticate to Cloudsmith using the org's SAML setup."""
8789
owner = owner[0].strip("'[]'")
8890

89-
click.echo(
90-
f"Beginning authentication for the {click.style(owner, bold=True)} org ... "
91-
)
91+
if not json:
92+
click.echo(
93+
f"Beginning authentication for the {click.style(owner, bold=True)} org ... "
94+
)
9295

9396
context_message = "Failed to authenticate via SSO!"
9497
with handle_api_exceptions(ctx, opts=opts, context_msg=context_message):
95-
_perform_saml_authentication(opts, owner, enable_token_creation=token)
98+
_perform_saml_authentication(
99+
opts, owner, enable_token_creation=token, json=json
100+
)
96101

97102
if token:
98103
ctx.invoke(create, opts=opts, save_config=save_config, force=force, json=json)

0 commit comments

Comments
 (0)