Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change HTTP method to POST when using the API login endpoint #2705

Closed
mcarmona99 opened this issue Mar 21, 2022 · 0 comments · Fixed by #2810
Closed

Change HTTP method to POST when using the API login endpoint #2705

mcarmona99 opened this issue Mar 21, 2022 · 0 comments · Fixed by #2810
Assignees

Comments

@mcarmona99
Copy link
Contributor

This issue is part of wazuh/wazuh#12793.

The epic issue aims to change the API login endpoint method from GET to POST, as using GET as the method of a login endpoint is incorrect.

As it was said in wazuh/wazuh#10203 (comment), both GET /security/user/authenticate and POST /security/user/authenticate endpoints will coexist and the deprecation of GET /security/user/authenticate will happen in a future major release.

To avoid future problems when the actual login endpoint (GET) is deprecated, we should update all the references found in this repository:

  • Occurrences of API_LOGIN_ENDPOINT

API_LOGIN_ENDPOINT = '/security/user/authenticate'

def get_token_login_api(protocol, host, port, user, password, login_endpoint, timeout, login_attempts, sleep_time):
"""Get API login token"""
login_url = f"{get_base_url(protocol, host, port)}{login_endpoint}"
for _ in range(login_attempts):
response = requests.get(login_url, headers=get_login_headers(user, password), verify=False, timeout=timeout)
if response.status_code == 200:
return json.loads(response.content.decode())['data']['token']
time.sleep(sleep_time)
else:
raise RuntimeError(f"Error obtaining login token: {response.json()}")

login_token = get_token_login_api(protocol, host, port, user, password, login_endpoint, timeout, login_attempts,

get_response = requests.get(f'{api.API_PROTOCOL}://{api.API_HOST}:{api.API_PORT}{api.API_LOGIN_ENDPOINT}',

@mcarmona99 mcarmona99 changed the title Change method when using the API login endpoint Change HTTP method to POST when using the API login endpoint Mar 21, 2022
@mcarmona99 mcarmona99 self-assigned this Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants