Skip to content

Commit 60cf61f

Browse files
committed
add ability to turn off ZM auth in mlapi, add params to config
1 parent 682d2ad commit 60cf61f

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

mlapi.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,17 @@ def ret_val(exception):
348348
api.add_resource(Health, '/health')
349349

350350
secrets_conf = pyzmutils.read_config(g.config['secrets'])
351+
351352
g.config['api_portal'] = g.config['api_portal'] or pyzmutils.get(key='ZM_API_PORTAL', section='secrets', conf=secrets_conf)
352353
g.config['portal'] = g.config['portal'] or pyzmutils.get(key='ZM_PORTAL', section='secrets', conf=secrets_conf)
353354
g.config['user'] = g.config['user'] or pyzmutils.get(key='ZM_USER', section='secrets', conf=secrets_conf)
354355
g.config['password'] = g.config['password'] or pyzmutils.get(key='ZM_PASSWORD', section='secrets', conf=secrets_conf)
355356

357+
if g.config['auth_enabled'] == 'no':
358+
g.config['user'] = None
359+
g.config['password'] = None
360+
g.logger.Info('Turning off auth for mlapi')
361+
356362
api_options = {
357363
'apiurl': g.config['api_portal'],
358364
'portalurl':g.config['portal'],

mlapiconfig.ini

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
#secrets=./secrets.ini
77
secrets=/etc/zm/secrets.ini
88

9+
# portal/user/password are needed if you plan on using ZM's legacy
10+
# auth mechanism to get images
11+
portal=!ZM_PORTAL
12+
user=!ZM_USER
13+
password=!ZM_PASSWORD
14+
15+
# api portal is needed if you plan to use tokens to get images
16+
# requires ZM 1.33 or above
17+
api_portal=!ZM_API_PORTAL
18+
19+
# make this no, if you don't plan to use auth. Default is yes.
20+
auth_enabled=yes
921

1022
# port that mlapi will listen on. Default 5000
1123
port=5000

modules/common_params.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
'section': 'general',
1919
'default': None,
2020
'type': 'string',
21+
},
22+
'auth_enabled':{
23+
'section': 'general',
24+
'default': 'yes',
25+
'type': 'string',
2126
},
2227
'portal':{
2328
'section': 'general',

0 commit comments

Comments
 (0)