qwc-services / qwc-data-service

QWC Data service
MIT License
5 stars 10 forks source link

qwc-oidc-auth and qwc-data-service: can't adapt type 'dict' #27

Closed rsrg-zwiama closed 11 months ago

rsrg-zwiama commented 11 months ago

as discussed here https://github.com/qwc-services/qwc-oidc-auth/issues/2 , i moved this issue from oidc to data service ... We use qwc services (qwc-docker as well as qwc-services on Kubernetes). We started with the db-auth-service for authorization and switched to the qwc-oidc-auth later. Now the field type for username doesn't match for the "edit_user_field" to automatically update the editing user.

ERROR in data_service: (psycopg2.ProgrammingError) can't adapt type 'dict'
...
[parameters: {'__val0': '12', '__val1': '4', '__val2': False, '__val3': '...', '__val4': {'username': 'zwiama', 'groups': ['verified']}, '__val5': '2023-11-06 10:57:26.675526', '__val6': False, 'geom': '{"coordinates": [[2534723.023262591, 1154148.493121253, 0]], "type": "MultiPoint"}', 'id': 277}]

I think the matter is the different definition of identity. For qwc-oidc-auth the identity is defined as:

identity = {'username': username, 'groups': groups}
app.logger.info(identity)
# Create the tokens we will be sending back to the user
access_token = create_access_token(identity)

For qwc-db-auth the identity is defined as:

identity = {
            'username': user.name
        }
...
 access_token = create_access_token(identity=identity)

Can data service be changed to handle both formats of identity?

manisandro commented 11 months ago

Should be fixed in v2023.11.29

rsrg-zwiama commented 11 months ago

Thanks, I tested and it's working fine!