Skip to content

Commit

Permalink
Merge pull request #45 from zalando-stups/do-not-warn-zign-token
Browse files Browse the repository at this point in the history
#42 do not warn on zign token
  • Loading branch information
hjacobs authored Jan 11, 2017
2 parents b82c66c + 7dbc0c9 commit 124e376
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 34 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Usage
.. code-block:: bash
$ zign token uid cn
$ ztoken # shortcut
See the `STUPS documentation on zign`_ for details.

Expand Down
22 changes: 11 additions & 11 deletions zign/api.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import click
from clickclick import error, info, UrlType
import logging
import os
import stups_cli.config
import time
import tokens
import requests
import socket
import time
import webbrowser
from urllib.parse import urlparse, urlunsplit

import click
import requests
import stups_cli.config
import tokens
import yaml
from clickclick import UrlType, error, info
from requests import RequestException

from .config import (CONFIG_NAME, OLD_CONFIG_NAME, REFRESH_TOKEN_FILE_PATH,
TOKENS_FILE_PATH)
from .oauth2 import ClientRedirectServer

from .config import OLD_CONFIG_NAME, CONFIG_NAME, REFRESH_TOKEN_FILE_PATH, TOKENS_FILE_PATH
from requests import RequestException
from urllib.parse import urlparse
from urllib.parse import urlunsplit

TOKEN_MINIMUM_VALIDITY_SECONDS = 60*5 # 5 minutes

logger = logging.getLogger('zign.api')
Expand Down
33 changes: 12 additions & 21 deletions zign/cli_zign.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import os

import click
from clickclick import AliasedGroup

import stups_cli.config
from clickclick import AliasedGroup
from zign import cli

from .api import get_named_token, ServerError
from .api import get_token
from .cli import output_option, print_version
from zign import cli

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

Expand Down Expand Up @@ -39,25 +36,19 @@ def delete_token(ctx, name):

@cli_zign.command()
@click.argument('scope', nargs=-1)
@click.option('--url', help='URL to generate access token', metavar='URI')
@click.option('--realm', help='Use custom OAuth2 realm', metavar='NAME')
@click.option('-n', '--name', help='Custom token name (will be stored)', metavar='TOKEN_NAME')
@click.option('-U', '--user', help='Username to use for authentication', envvar='ZIGN_USER', metavar='NAME')
@click.option('-p', '--password', help='Password to use for authentication', envvar='ZIGN_PASSWORD', metavar='PWD')
@click.option('--insecure', help='Do not verify SSL certificate', is_flag=True, default=False)
@click.option('-r', '--refresh', help='Force refresh of the access token', is_flag=True, default=False)
# all these options are deprecated, but still here for compatibility
@click.option('--url', help='DEPRECATED: URL to generate access token', metavar='URI')
@click.option('--realm', help='DEPRECATED: Use custom OAuth2 realm', metavar='NAME')
@click.option('-n', '--name', help='DEPRECATED: Custom token name (will be stored)', metavar='TOKEN_NAME')
@click.option('-U', '--user', help='DEPRECATED: Username to use for authentication', envvar='ZIGN_USER', metavar='NAME')
@click.option('-p', '--password', help='DEPRECATED: Password to use for authentication', envvar='ZIGN_PASSWORD')
@click.option('--insecure', help='DEPRECATED: Do not verify SSL certificate', is_flag=True, default=False)
@click.option('-r', '--refresh', help='DEPRECATED: Force refresh of the access token', is_flag=True, default=False)
@click.pass_obj
def token(obj, scope, url, realm, name, user, password, insecure, refresh):
'''Create a new token or use an existing one'''

user = user or obj.get('user') or os.getenv('USER')

try:
token = get_named_token(scope, realm, name, user, password, url, insecure, refresh, prompt=True)
except ServerError as e:
raise click.UsageError(e)
access_token = token.get('access_token')

access_token = get_token(name, scope)
print(access_token)


Expand Down
3 changes: 1 addition & 2 deletions zign/oauth2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import parse_qs, urlparse

from urllib.parse import parse_qs
from urllib.parse import urlparse

SUCCESS_PAGE = '''<!DOCTYPE HTML>
<html lang="en-US">
Expand Down

0 comments on commit 124e376

Please sign in to comment.