django-keycloak icon indicating copy to clipboard operation
django-keycloak copied to clipboard

Help!

Open bssher opened this issue 6 years ago • 9 comments

Having trouble with the following when I run the django admin keycloak add user command.
File "/usr/local/lib/python2.7/dist-packages/keycloak/client.py", line 82, in _handle_response with response: AttributeError: exit

Not sure how to get this up and running.

bssher avatar Feb 11 '19 18:02 bssher

Hi @bssher which version do you use?

Peter-Slump avatar Feb 11 '19 21:02 Peter-Slump

Django==1.11.16 using this project. https://github.com/GeoNode/geonode

bssher avatar Feb 11 '19 21:02 bssher

@bssher The problem is probably the version of the requests library you are using. Older versions of the requests library are not compatible with the with response: as used in the keycloak client (hence the error). I would suggest updating requests to the newest version which should solve your problem.

bossan avatar Feb 12 '19 10:02 bossan

Thanks @bossan. I was able to resolve it by upgrading response.
Next question how do I access the login page. I have updated the urls.py, what is the path to navigate to? I am able to run the refresh realm django admin command and all seems populated correctly in my admin console.

bssher avatar Feb 12 '19 20:02 bssher

If you followed the docs as you said e.g.:

# your-project/urls.py
...

urlpatterns = [
    ...
    url(r'^keycloak/', include('django_keycloak.urls')),
]

You can find the login url at: /keycloak/login.

The pattern is named keycloak_login, which makes it possible to use it with Django's reverse function

Peter-Slump avatar Feb 14 '19 14:02 Peter-Slump

Thanks for the help! I'm getting closer. When I login I get the following message in the apache logs JWTError: Signature verification failed.

My guess is its a keycloak configuration. Ideas?

bssher avatar Feb 14 '19 21:02 bssher

Did you already refreshed the certificates using the Django Admin? It seems like a lack or a mismatch in certificates between your app and Keycloak which causes that the JWT signature cannot be validated.

Peter-Slump avatar Feb 15 '19 21:02 Peter-Slump

I didn't. What's the command in django admin. The only 2 commands I see available are keycloak_add_user keycloak_refresh_realm

Also any specific setting you make in keycloak in the Fine Grain OpenID Connect Configuration?

bssher avatar Feb 19 '19 15:02 bssher

In meantime I've released a new version and updated the docs. Please read the section about refreshing the certificates: https://django-keycloak.readthedocs.io/en/latest/scenario/initial_setup.html#refresh-certificates

Peter-Slump avatar Feb 26 '19 20:02 Peter-Slump