diff --git a/NEWS b/NEWS index 9d0c540c..e7a57fdf 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +0.142 + - ppc64p7 build support + - request --no-devel to disable request forwarding +# +# Features which requires OBS 2.5 +# + - authentification token support + 0.141 - crash fixes - support for kiwi appliance builds using obsrepositories:/ directive diff --git a/osc/commandline.py b/osc/commandline.py index 256466cc..cf2ec826 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -585,6 +585,52 @@ class Osc(cmdln.Cmdln): set_devel_project(apiurl, project, package, devprj, devpkg) + @cmdln.option('-c', '--create', action='store_true', + help='Create a new token') + @cmdln.option('-d', '--delete', metavar='TOKENID', + help='Create a new token') + def do_token(self, subcmd, opts, *args): + """${cmd_name}: Show and manage authentification token + + Authentification token can be used to run specific commands without + sending credentials. + + Usage: + osc token + osc token --create [ ] + osc token --delete + ${cmd_option_list} + """ + + args = slash_split(args) + + apiurl = self.get_api_url() + url = apiurl + "/person/" + conf.get_apiurl_usr(apiurl) + "/token" + + if opts.create: + print("Create a new token") + url += "?cmd=create" + if len(args) > 1: + url += "&project=" + args[0] + url += "&package=" + args[1] + + f = http_POST(url) + while True: + buf = f.read(16384) + if not buf: + break + sys.stdout.write(buf) + + elif opts.delete: + print("Delete token") + url += "/" + opts.delete + http_DELETE(url) + else: + # just list token + for data in streamfile(url, http_GET): + sys.stdout.write(data) + + @cmdln.option('-a', '--attribute', metavar='ATTRIBUTE', help='affect only a given attribute') @cmdln.option('--attribute-defaults', action='store_true', diff --git a/osc/core.py b/osc/core.py index 02ea194e..5c2e842a 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5,7 +5,7 @@ from __future__ import print_function -__version__ = '0.141' +__version__ = '0.141git' # __store_version__ is to be incremented when the format of the working copy # "store" changes in an incompatible way. Please add any needed migration