Source code for api.authentication.v1.radius.radius_authenticate

"""Autogenerated API"""

from argus_cli.plugin import register_command



[docs]@register_command(extending=("authentication","v1","radius","authenticate")) def authenticate( userName: str = None, domain: str = None, mode: str = None, password: str = None, tokenCode: str = None, state: str = None, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Initiate a new user session using RADIUS authentication (PUBLIC) Requires RADIUS authentication to be enabled on the server, and for the user. Use /methods to check which authentication methods are available on the server. This is a 2-factor authentication method, which may require additional verification. The first request should have mode AUTHENTICATION, and carry username, password and tokencode. If the authentication is challenged, submit a new request with mode CHALLENGE, andinclude the state variable returned in the challenge. :param str userName: Username to authenticate :param str domain: User domain :param str mode: Authentication mode. Use AUTHENTICATION for normal authentication, or CHALLENGE to respond to a challenge request :param str password: RADIUS static password :param str tokenCode: RADIUS token code :param str state: When responding to a challenge, include the encoded state returned by the challenge. :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises NotFoundException: on 404 :returns: {'offset': 618, 'limit': 478, 'responseCode': 200, 'count': 193, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Authority report executive half their apply.', 'messageTemplate': 'Maybe move financial college family.', 'field': 'She offer family official value gun determine.', 'parameter': {}, 'timestamp': 508212575}], 'currentPage': 537, 'size': 550} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/authentication/v1/radius/authenticate".format() headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "userName": userName, "domain": domain, "mode": mode, "password": password, "tokenCode": tokenCode, "state": state } response = post(url, json=body if body else None, verify=verify, headers=headers ) if response.status_code == 401: raise http.AuthenticationFailedException(response) elif response.status_code == 403: raise http.AccessDeniedException(response) elif response.status_code == 412: raise http.ValidationErrorException(response) elif response.status_code == 404: raise http.ObjectNotFoundException(response) return response.json() if json else response