|
1 |
| -import os |
2 |
| - |
3 | 1 | import click
|
4 |
| -from clickclick import AliasedGroup |
5 |
| - |
6 | 2 | import stups_cli.config
|
| 3 | +from clickclick import AliasedGroup |
| 4 | +from zign import cli |
7 | 5 |
|
8 |
| -from .api import get_named_token, ServerError |
| 6 | +from .api import get_token |
9 | 7 | from .cli import output_option, print_version
|
10 |
| -from zign import cli |
11 | 8 |
|
12 | 9 | CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
13 | 10 |
|
@@ -39,25 +36,19 @@ def delete_token(ctx, name):
|
39 | 36 |
|
40 | 37 | @cli_zign.command()
|
41 | 38 | @click.argument('scope', nargs=-1)
|
42 |
| -@click.option('--url', help='URL to generate access token', metavar='URI') |
43 |
| -@click.option('--realm', help='Use custom OAuth2 realm', metavar='NAME') |
44 |
| -@click.option('-n', '--name', help='Custom token name (will be stored)', metavar='TOKEN_NAME') |
45 |
| -@click.option('-U', '--user', help='Username to use for authentication', envvar='ZIGN_USER', metavar='NAME') |
46 |
| -@click.option('-p', '--password', help='Password to use for authentication', envvar='ZIGN_PASSWORD', metavar='PWD') |
47 |
| -@click.option('--insecure', help='Do not verify SSL certificate', is_flag=True, default=False) |
48 |
| -@click.option('-r', '--refresh', help='Force refresh of the access token', is_flag=True, default=False) |
| 39 | +# all these options are deprecated, but still here for compatibility |
| 40 | +@click.option('--url', help='DEPRECATED: URL to generate access token', metavar='URI') |
| 41 | +@click.option('--realm', help='DEPRECATED: Use custom OAuth2 realm', metavar='NAME') |
| 42 | +@click.option('-n', '--name', help='DEPRECATED: Custom token name (will be stored)', metavar='TOKEN_NAME') |
| 43 | +@click.option('-U', '--user', help='DEPRECATED: Username to use for authentication', envvar='ZIGN_USER', metavar='NAME') |
| 44 | +@click.option('-p', '--password', help='DEPRECATED: Password to use for authentication', envvar='ZIGN_PASSWORD') |
| 45 | +@click.option('--insecure', help='DEPRECATED: Do not verify SSL certificate', is_flag=True, default=False) |
| 46 | +@click.option('-r', '--refresh', help='DEPRECATED: Force refresh of the access token', is_flag=True, default=False) |
49 | 47 | @click.pass_obj
|
50 | 48 | def token(obj, scope, url, realm, name, user, password, insecure, refresh):
|
51 | 49 | '''Create a new token or use an existing one'''
|
52 | 50 |
|
53 |
| - user = user or obj.get('user') or os.getenv('USER') |
54 |
| - |
55 |
| - try: |
56 |
| - token = get_named_token(scope, realm, name, user, password, url, insecure, refresh, prompt=True) |
57 |
| - except ServerError as e: |
58 |
| - raise click.UsageError(e) |
59 |
| - access_token = token.get('access_token') |
60 |
| - |
| 51 | + access_token = get_token(name, scope) |
61 | 52 | print(access_token)
|
62 | 53 |
|
63 | 54 |
|
|
0 commit comments