Skip to content

Commit 124e376

Browse files
authored
Merge pull request #45 from zalando-stups/do-not-warn-zign-token
#42 do not warn on zign token
2 parents b82c66c + 7dbc0c9 commit 124e376

File tree

4 files changed

+25
-34
lines changed

4 files changed

+25
-34
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Usage
3434
.. code-block:: bash
3535
3636
$ zign token uid cn
37+
$ ztoken # shortcut
3738
3839
See the `STUPS documentation on zign`_ for details.
3940

zign/api.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import click
2-
from clickclick import error, info, UrlType
31
import logging
42
import os
5-
import stups_cli.config
6-
import time
7-
import tokens
8-
import requests
93
import socket
4+
import time
105
import webbrowser
6+
from urllib.parse import urlparse, urlunsplit
7+
8+
import click
9+
import requests
10+
import stups_cli.config
11+
import tokens
1112
import yaml
13+
from clickclick import UrlType, error, info
14+
from requests import RequestException
1215

16+
from .config import (CONFIG_NAME, OLD_CONFIG_NAME, REFRESH_TOKEN_FILE_PATH,
17+
TOKENS_FILE_PATH)
1318
from .oauth2 import ClientRedirectServer
1419

15-
from .config import OLD_CONFIG_NAME, CONFIG_NAME, REFRESH_TOKEN_FILE_PATH, TOKENS_FILE_PATH
16-
from requests import RequestException
17-
from urllib.parse import urlparse
18-
from urllib.parse import urlunsplit
19-
2020
TOKEN_MINIMUM_VALIDITY_SECONDS = 60*5 # 5 minutes
2121

2222
logger = logging.getLogger('zign.api')

zign/cli_zign.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import os
2-
31
import click
4-
from clickclick import AliasedGroup
5-
62
import stups_cli.config
3+
from clickclick import AliasedGroup
4+
from zign import cli
75

8-
from .api import get_named_token, ServerError
6+
from .api import get_token
97
from .cli import output_option, print_version
10-
from zign import cli
118

129
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
1310

@@ -39,25 +36,19 @@ def delete_token(ctx, name):
3936

4037
@cli_zign.command()
4138
@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)
4947
@click.pass_obj
5048
def token(obj, scope, url, realm, name, user, password, insecure, refresh):
5149
'''Create a new token or use an existing one'''
5250

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)
6152
print(access_token)
6253

6354

zign/oauth2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from http.server import BaseHTTPRequestHandler, HTTPServer
2+
from urllib.parse import parse_qs, urlparse
23

3-
from urllib.parse import parse_qs
4-
from urllib.parse import urlparse
54

65
SUCCESS_PAGE = '''<!DOCTYPE HTML>
76
<html lang="en-US">

0 commit comments

Comments
 (0)