zatosource / zato

ESB, SOA, REST, APIs and Cloud Integrations in Python
https://zato.io
GNU Affero General Public License v3.0
1.12k stars 240 forks source link

zato.security.jwt.log-in service in zato 3.2 always return "Invalid credentials" #1176

Closed LordShion closed 2 years ago

LordShion commented 2 years ago

Zato 3.2+rev.d361b8f7-py3.6.9-ubuntu.18.04-bionic

after your correction for the jwt creation on web admin. jwt login service returns invalid credentials I created name: FilipeToken username: filipesisi ttl: 3600 changed password to : fifi

curl to login and retrieve a token:

curl -X POST localhost:11223/zato/jwt/log-in -d '{"username":"filipesisi","password":"fifi"}' ends always with {"result":"Error","cid":"68698a2cfb3bb7cd19dea28b","details":"Invalid credentials"}

What I'm doing wrong?

LordShion commented 2 years ago

After some digging I found that my zato server jwt_secret was not fernet compliant. so I generated one with zato crypto create secret-key. after that, it passed the token generation but fail on jwt.py line 85
return self.fernet.encrypt(token).decode('utf8') error said it needed bytes in the crypto module replaced with return self.fernet.encrypt(token.encode('utf8')).decode('utf8') it passed this step but then fail here and I'm stuck

zato32_1    | 2021-11-24 21:58:53,150 - ERROR - 134:DummyThread-42 - zato.server.connection.http_soap.channel:0 - Caught an exception, cid:`3069837fc33277bf46afa726`, status_code:`HTTPStatus.UNAUTHORIZED`, `Traceback (most recent call last):
zato32_1    |   File "/opt/zato/3.2.0/code/zato-server/src/zato/server/service/internal/security/jwt.py", line 247, in handle
zato32_1    |     token, self.request.input.totp_code)
zato32_1    |   File "/opt/zato/3.2.0/code/zato-server/src/zato/server/sso.py", line 53, in on_external_auth
zato32_1    |     auth_id_link_map = self.server.sso_api.user.auth_id_link_map['zato.{}'.format(sec_type)] # type: dict
zato32_1    | AttributeError: 'NoneType' object has no attribute 'user'
zato32_1    | 
zato32_1    | During handling of the above exception, another exception occurred:
zato32_1    | 
zato32_1    | Traceback (most recent call last):
zato32_1    |   File "/opt/zato/3.2.0/code/zato-server/src/zato/server/connection/http_soap/channel.py", line 382, in dispatch
zato32_1    |     payload, worker_store, self.simple_io_config, post_data, path_info, soap_action)
zato32_1    |   File "/opt/zato/3.2.0/code/zato-server/src/zato/server/connection/http_soap/channel.py", line 689, in handle
zato32_1    |     params_priority=channel_item.params_pri)
zato32_1    |   File "/opt/zato/3.2.0/code/zato-server/src/zato/server/service/__init__.py", line 804, in update_handle
zato32_1    |     raise e if isinstance(e, Exception) else Exception(e)
zato32_1    |   File "/opt/zato/3.2.0/code/zato-server/src/zato/server/service/__init__.py", line 746, in update_handle
zato32_1    |     self._invoke(service, channel)
zato32_1    |   File "/opt/zato/3.2.0/code/zato-server/src/zato/server/service/__init__.py", line 627, in _invoke
zato32_1    |     service.handle()
zato32_1    |   File "/opt/zato/3.2.0/code/zato-server/src/zato/server/service/internal/security/jwt.py", line 257, in handle
zato32_1    |     self._raise_unathorized()
zato32_1    |   File "/opt/zato/3.2.0/code/zato-server/src/zato/server/service/internal/security/jwt.py", line 229, in _raise_unathorized
zato32_1    |     raise Unauthorized(self.cid, 'Invalid credentials', 'jwt')
zato32_1    | zato.common.exception.Unauthorized: <Unauthorized at 0x7f675cc959a8 cid:`3069837fc33277bf46afa726`, msg:`Invalid credentials`>
zato32_1    | `
dsuch commented 2 years ago

Thanks for the ticket - this is done. Please install the latest updates: https://zato.io/docs/3.2/admin/guide/install/update.html