mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-24 00:56:15 +01:00
- add support to handle authentification token support
This commit is contained in:
parent
67802e6a41
commit
63e1124c09
8
NEWS
8
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
|
||||
|
@ -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 [<PROJECT> <PACKAGE>]
|
||||
osc token --delete <TOKENID>
|
||||
${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',
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user