mirror of
https://github.com/cs3org/wopiserver.git
synced 2025-04-18 13:04:00 +03:00
Add usertype to wopiopen
This commit is contained in:
parent
7a47a6c681
commit
33e92151d6
@ -13,7 +13,7 @@ import getopt
|
||||
import configparser
|
||||
import requests
|
||||
sys.path.append('src') # for tests out of the git repo
|
||||
from core.wopiutils import ViewMode # noqa: E402
|
||||
from core.wopiutils import ViewMode, UserType # noqa: E402
|
||||
|
||||
|
||||
# usage function
|
||||
@ -21,18 +21,20 @@ def usage(exitcode):
|
||||
'''Prints usage'''
|
||||
print('Usage : ' + sys.argv[0] + ' -a|--appname <app_name> -u|--appurl <app_url> [-i|--appinturl <app_url>] '
|
||||
'-k|--apikey <api_key> [-s|--storage <storage_endpoint>] [-v|--viewmode VIEW_ONLY|READ_ONLY|READ_WRITE|PREVIEW] '
|
||||
'[-x|--x-access-token <reva_token>] <filename>')
|
||||
'[-t|--user-type REGULAR|FEDERATED|ANONYMOUS] [-x|--x-access-token <reva_token>] <filename>')
|
||||
sys.exit(exitcode)
|
||||
|
||||
|
||||
# first parse the options
|
||||
try:
|
||||
options, args = getopt.getopt(sys.argv[1:], 'hv:s:a:i:u:x:k:',
|
||||
['help', 'viewmode', 'storage', 'appname', 'appinturl', 'appurl', 'x-access-token', 'apikey'])
|
||||
options, args = getopt.getopt(sys.argv[1:], 'hv:t:s:a:i:u:x:k:',
|
||||
['help', 'viewmode', 'usertype', 'storage', 'appname', 'appinturl', 'appurl',
|
||||
'x-access-token', 'apikey'])
|
||||
except getopt.GetoptError as e:
|
||||
print(e)
|
||||
usage(1)
|
||||
viewmode = ViewMode.READ_WRITE
|
||||
usertype = UserType.REGULAR
|
||||
endpoint = ''
|
||||
appname = ''
|
||||
appurl = ''
|
||||
@ -49,6 +51,12 @@ for f, v in options:
|
||||
except ValueError:
|
||||
print("Invalid argument for viewmode: " + v)
|
||||
usage(1)
|
||||
elif f == '-t' or f == '--usertype':
|
||||
try:
|
||||
usertype = UserType(v)
|
||||
except ValueError:
|
||||
print("Invalid argument for usertype: " + v)
|
||||
usage(1)
|
||||
elif f == '-s' or f == '--storage':
|
||||
endpoint = v
|
||||
elif f == '-i' or f == '--appinturl':
|
||||
@ -111,8 +119,8 @@ requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.
|
||||
|
||||
# open the file and get WOPI token
|
||||
wopiheaders = {'Authorization': 'Bearer ' + iopsecret}
|
||||
wopiparams = {'fileid': filename, 'endpoint': endpoint,
|
||||
'viewmode': viewmode.value, 'username': 'Operator', 'userid': userid, 'folderurl': '/',
|
||||
wopiparams = {'fileid': filename, 'endpoint': endpoint, 'viewmode': viewmode.value, 'usertype': usertype.value,
|
||||
'username': 'Operator', 'userid': userid, 'folderurl': '/',
|
||||
'appurl': appurl, 'appinturl': appinturl, 'appname': appname}
|
||||
wopiheaders['TokenHeader'] = revatoken
|
||||
# for bridged apps, also set the API key
|
||||
|
Loading…
x
Reference in New Issue
Block a user