Skip to content

Commit e74ee80

Browse files
committed
Support other nextstrain.org-like remotes
Adds support for other nextstrain.org-like remotes to the `nextstrain remote` family of commands, along with support for OIDC/OAuth2 authentication with them to the `nextstrain login` and related commands. Required IdP and client configuration for OIDC/OAuth2 is auto-discovered. One giant pile of changes, because I did not have time to go thru my typical editing and splitting process before going on leave. :/ Ah well. Related-to: <nextstrain/private#94>
1 parent dc957d5 commit e74ee80

23 files changed

+1761
-616
lines changed

doc/commands/authorization.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,35 @@ nextstrain authorization
1212

1313
.. code-block:: none
1414
15-
usage: nextstrain authorization [-h]
15+
usage: nextstrain authorization [-h] [<remote-url>]
1616
1717
18-
Produce an Authorization header appropriate for nextstrain.org's web API.
18+
Produce an Authorization header appropriate for the web API of nextstrain.org
19+
(and other remotes).
1920

2021
This is a development tool unnecessary for normal usage. It's useful for
21-
directly making API requests to nextstrain.org with `curl` or similar
22-
commands. For example::
22+
directly making API requests to nextstrain.org (and other remotes) with `curl`
23+
or similar commands. For example::
2324

2425
curl -si https://nextstrain.org/whoami \
2526
--header "Accept: application/json" \
2627
--header @<(nextstrain authorization)
2728

2829
Exits with an error if no one is logged in.
2930

31+
positional arguments
32+
====================
33+
34+
35+
36+
.. option:: <remote-url>
37+
38+
Remote URL for which to produce an Authorization header. Expects
39+
URLs like the remote source/destination URLs used by the
40+
`nextstrain remote` family of commands. Only the domain name
41+
(technically, the origin) of the URL is required/used, but a full
42+
URL may be specified.
43+
3044
options
3145
=======
3246

doc/commands/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ commands
7474

7575
.. option:: login
7676

77-
Log into Nextstrain.org. See :doc:`/commands/login`.
77+
Log into Nextstrain.org (and other remotes). See :doc:`/commands/login`.
7878

7979
.. option:: logout
8080

81-
Log out of Nextstrain.org. See :doc:`/commands/logout`.
81+
Log out of Nextstrain.org (and other remotes). See :doc:`/commands/logout`.
8282

8383
.. option:: whoami
8484

doc/commands/login.rst

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,37 @@ nextstrain login
1212

1313
.. code-block:: none
1414
15-
usage: nextstrain login [-h] [--username <name>] [--no-prompt] [--renew]
15+
usage: nextstrain login [-h] [--username <name>] [--no-prompt] [--renew] [<remote-url>]
1616
1717
18-
Log into Nextstrain.org and save credentials for later use.
18+
Log into Nextstrain.org (and other remotes) and save credentials for later use.
1919

20-
The first time you log in, you'll be prompted for your Nextstrain.org username
21-
and password. After that, locally-saved authentication tokens will be used and
22-
automatically renewed as needed when you run other `nextstrain` commands
23-
requiring log in. You can also re-run this `nextstrain login` command to force
24-
renewal if you want. You'll only be prompted for your username and password if
25-
the locally-saved tokens are unable to be renewed or missing entirely.
20+
The first time you log in to a remote you'll be prompted to authenticate via
21+
your web browser or, if you provide a username (e.g. with --username), for your
22+
Nextstrain.org password. After that, locally-saved authentication tokens will
23+
be used and automatically renewed as needed when you run other `nextstrain`
24+
commands requiring log in. You can also re-run this `nextstrain login` command
25+
to force renewal if you want. You'll only be prompted to reauthenticate (via
26+
your web browser or username/password) if the locally-saved tokens are unable
27+
to be renewed or missing entirely.
2628

27-
If you log out of Nextstrain.org on other devices/clients (like your web
28-
browser), you may be prompted to re-enter your username and password by this
29-
command sooner than usual.
29+
If you log out of Nextstrain.org (or other remotes) on other devices/clients
30+
(like your web browser), you may be prompted to reauthenticate by this command
31+
sooner than usual.
3032

31-
Your password itself is never saved locally.
33+
Your username and password themselves are never saved locally.
34+
35+
positional arguments
36+
====================
37+
38+
39+
40+
.. option:: <remote-url>
41+
42+
Remote URL to log in to, like the remote source/destination URLs
43+
used by the `nextstrain remote` family of commands. Only the
44+
domain name (technically, the origin) of the URL is required/used,
45+
but a full URL may be specified.
3246

3347
options
3448
=======
@@ -45,7 +59,7 @@ options
4559

4660
.. option:: --no-prompt
4761

48-
Never prompt for a username/password; succeed only if there are login credentials in the environment or existing valid/renewable tokens saved locally, otherwise error. Useful for scripting.
62+
Never prompt for authentication (via web browser or username/password); succeed only if there are login credentials in the environment or existing valid/renewable tokens saved locally, otherwise error. Useful for scripting.
4963

5064
.. option:: --renew
5165

@@ -62,4 +76,7 @@ of interactive input and/or command-line options:
6276
.. envvar:: NEXTSTRAIN_PASSWORD
6377

6478
Password for nextstrain.org user. Required if :option:`--no-prompt` is
65-
used without existing valid/renewable tokens.
79+
used without existing valid/renewable tokens.
80+
81+
If you want to suppress ever opening a web browser automatically, you
82+
may set the environment variable ``NOBROWSER=1``.

doc/commands/logout.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,29 @@ nextstrain logout
1212

1313
.. code-block:: none
1414
15-
usage: nextstrain logout [-h]
15+
usage: nextstrain logout [-h] [<remote-url>]
1616
1717
18-
Log out of Nextstrain.org by deleting locally-saved credentials.
18+
Log out of Nextstrain.org (and other remotes) by deleting locally-saved
19+
credentials.
1920

2021
The authentication tokens are removed but not invalidated, so if you used them
2122
outside of the `nextstrain` command, they will remain valid until they expire.
2223

2324
Other devices/clients (like your web browser) are not logged out of
24-
Nextstrain.org.
25+
Nextstrain.org (or other remotes).
26+
27+
positional arguments
28+
====================
29+
30+
31+
32+
.. option:: <remote-url>
33+
34+
Remote URL to log out of, like the remote source/destination URLs
35+
used by the `nextstrain remote` family of commands. Only the
36+
domain name (technically, the origin) of the URL is required/used,
37+
but a full URL may be specified.
2538

2639
options
2740
=======

doc/commands/whoami.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,29 @@ nextstrain whoami
1212

1313
.. code-block:: none
1414
15-
usage: nextstrain whoami [-h]
15+
usage: nextstrain whoami [-h] [<remote-url>]
1616
1717
18-
Show information about the logged-in user.
18+
Show information about the logged-in user for Nextstrain.org (and other
19+
remotes).
1920

20-
The username, email address, and Nextstrain Groups memberships of the currently
21-
logged-in user are shown.
21+
The username, email address (if available), and Nextstrain Groups memberships
22+
of the currently logged-in user are shown.
2223

2324
Exits with an error if no one is logged in.
2425

26+
positional arguments
27+
====================
28+
29+
30+
31+
.. option:: <remote-url>
32+
33+
Remote URL for which to show the logged-in user. Expects URLs like
34+
the remote source/destination URLs used by the `nextstrain remote`
35+
family of commands. Only the domain name (technically, the origin)
36+
of the URL is required/used, but a full URL may be specified.
37+
2538
options
2639
=======
2740

doc/development.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,23 @@ resources from our ["testing" configuration][], you can configure `nextstrain`
5959
with the same, e.g.:
6060

6161
export NEXTSTRAIN_DOT_ORG=http://localhost:5000
62-
export NEXTSTRAIN_COGNITO_USER_POOL_ID="$(jq -r .COGNITO_USER_POOL_ID ../nextstrain.org/env/testing/config.json)"
63-
export NEXTSTRAIN_COGNITO_CLI_CLIENT_ID="$(jq -r .OAUTH2_CLI_CLIENT_ID ../nextstrain.org/env/testing/config.json)"
6462

6563
nextstrain login
6664
nextstrain whoami
6765
nextstrain remote ls groups/test-private
6866

67+
Most of the times the above is not necessary, however, as you can specify the
68+
local remote explicitly instead of pretending it's nextstrain.org, e.g.:
69+
70+
nextstrain remote ls http://localhost:5000/groups/test
71+
72+
nextstrain login http://localhost:5000
73+
nextstrain whoami http://localhost:5000
74+
nextstrain remote ls http://localhost:5000/groups/test-private
75+
76+
Setting `NEXTSTRAIN_DOT_ORG` is mostly useful when testing the default-remote
77+
code paths themselves.
78+
6979
## Releasing
7080

7181
New releases are made frequently and tagged in git using a [_signed_ tag][].

nextstrain/cli/authn.py

Lines changed: 0 additions & 177 deletions
This file was deleted.

0 commit comments

Comments
 (0)