added "auth_id" as alias for "authId" on login

Changed "uds_auth" to "uds_token"
This commit is contained in:
Adolfo Gómez García 2021-06-28 19:02:44 +02:00
parent bddb9355c8
commit c5a02686c4
4 changed files with 6 additions and 6 deletions

View File

@ -112,11 +112,11 @@ class Login(Handler):
logger.info('Access to REST API %s is blocked for %s seconds since last fail', self._request.ip, GlobalConfig.LOGIN_BLOCK.getInt())
try:
if 'authId' not in self._params and 'authSmallName' not in self._params and 'auth' not in self._params:
if 'auth_id' not in self._params and 'authId' not in self._params and 'authSmallName' not in self._params and 'auth' not in self._params:
raise RequestError('Invalid parameters (no auth)')
scrambler: str = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(32)) # @UndefinedVariable
authId: typing.Optional[str] = self._params.get('authId', None)
authId: typing.Optional[str] = self._params.get('authId', self._params.get('auth_id', None))
authSmallName: typing.Optional[str] = self._params.get('authSmallName', None)
authName: typing.Optional[str] = self._params.get('auth', None)
platform: str = self._params.get('platform', self._request.os)

View File

@ -58,7 +58,7 @@ class ConfigurationType(typing.NamedTuple):
ssl_dhparam: str
uds_server: str
uds_auth: str
uds_token: str
secret: str
allow: typing.Set[str]
@ -105,7 +105,7 @@ def read() -> ConfigurationType:
ssl_ciphers=uds.get('ssl_ciphers'),
ssl_dhparam=uds.get('ssl_dhparam'),
uds_server=uds_server,
uds_auth=uds.get('uds_auth', 'unauthorized'),
uds_token=uds.get('uds_token', 'unauthorized'),
secret=secret,
allow=set(uds.get('allow', '127.0.0.1').split(',')),
)

View File

@ -55,7 +55,7 @@ class Proxy:
@staticmethod
def _getUdsUrl(cfg: config.ConfigurationType, ticket: bytes, msg: str) -> typing.MutableMapping[str, typing.Any]:
try:
url = cfg.uds_server + '/' + ticket.decode() + '/' + msg + '/' + cfg.uds_auth
url = cfg.uds_server + '/' + ticket.decode() + '/' + msg + '/' + cfg.uds_token
r = requests.get(url, headers={'content-type': 'application/json'})
if not r.ok:
raise Exception(r.content)

View File

@ -40,7 +40,7 @@ ssl_dhparam = /etc/certs/dhparam.pem
# http://www.example.com/uds/rest/tunnel/ticket
# https://www.example.com:14333/uds/rest/tunnel/ticket
uds_server = http://172.27.0.1:8000/uds/rest/tunnel/ticket
uds_auth = 123456789012345678901234567890123456789012345678
uds_token = 123456789012345678901234567890123456789012345678
# Secret to get access to admin commands (Currently only stats commands). No default for this.
# Admin commands and only allowed from "allow" ips