Skip to content

Commit

Permalink
Merge pull request #575 from chengshifan/enable-deploy-docker-compose
Browse files Browse the repository at this point in the history
[INT] fix vault v1 and no namespace bug
  • Loading branch information
chengshifan authored Nov 22, 2023
2 parents 248ed0c + d130902 commit e8a1a5b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/api/handlers/job_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,24 +286,24 @@ def get_secret(name):
if not namespace:
namespace = ''
if version == 'v1':
url += '/v1/' + namespace + '/' + secret_path
url += '/v1/' + namespace + '/' + secret_path if namespace else '/v1/' + secret_path
elif version == 'v2':
paths = secret_path.split('/')
url += '/v1/' + namespace + '/' + paths[0] + '/data/' + '/'.join(paths[1:])
url += '/v1/' + namespace + '/' + paths[0] + '/data/' + '/'.join(paths[1:]) if namespace else '/v1/' + paths[0] + '/data/' + '/'.join(paths[1:])
# choose validate way
validate_res = get_auth_type(result)
if validate_res == 'token':
logger.info('validate way is token')
elif validate_res == 'appRole':
app_role = {'role_id': role_id, 'secret_id': secret_id}
json_data = json.dumps(app_role)
app_role_url = result[0] + '/v1/' + namespace + '/auth/approle/login'
app_role_url = result[0] + '/v1/' + namespace + '/auth/approle/login' if namespace else result[0] + '/v1/auth/approle/login'
res = requests.post(url=app_role_url, data=json_data, verify=False)
if res.status_code == 200:
json_res = json.loads(res.content)
token = json_res['auth']['client_token']
else:
abort(400, "Getting value from vault error: url is '%s', validate way is appRole; API response: '%s'" % (url, res.text))
abort(400, "Getting value from vault error: url is '%s', validate way is appRole; API response: '%s'" % (app_role_url, res.text))
else:
abort(400, "Validate way is '%s' ! result is '%s' " % (validate_res, result))

Expand Down

0 comments on commit e8a1a5b

Please sign in to comment.