datopian / ckanext-auth

Login via CKAN Classic from a separate service.
GNU Affero General Public License v3.0
4 stars 2 forks source link

Throws internal server error in CKAN v2.9 #3

Open anuveyatsu opened 1 year ago

anuveyatsu commented 1 year ago

Acceptance criteria

Tasks

Analysis

This line of code https://github.com/datopian/ckanext-auth/blob/master/ckanext/auth/logic.py#L30 is calling authenticate method from ckan.lib.authenticator.

In CKAN v2.8 it was returning user.name, but in CKAN v2.9 it is returning a string in format user.id, 1

Solution

We need to get user name with:

authUser_id = auth.authenticate(context, identity).split(',')[0]
authUser_name = model.User.get(authUser_id).name

instead of:

authUser = auth.authenticate(context, identity)

because it is returning user.id, 1 as a string.

In CKAN v2.10 this changed again, so this authenticate method is returning the whole user object

If this is urgent we can apply the solution and keep it in a branch. In opposite, I can create one robust solution where we'll check CKAN version and handle user data in a way to be compatible with CKAN version.

gavram commented 1 year ago

@anuveyatsu This should be fixed with this commit https://github.com/datopian/ckanext-auth/commit/cfe476ca5bf47fc75baa89d41b12f41361540841

The solution is in v2.9 branch