omab / python-social-auth

Social auth made simple
http://psa.matiasaguirre.net
BSD 3-Clause "New" or "Revised" License
2.83k stars 1.09k forks source link

On upgrading python-social-auth from 0.1.17 to 0.2.4, session and user attributes is not provided in request, to custom pipeline method ? #994

Closed siddharthsahu closed 7 years ago

siddharthsahu commented 8 years ago

I have noticed that attributes set by middleware are not present in request even though middlewares are included in settings as: MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django_user_agents.middleware.UserAgentMiddleware', 'workbench.middlewares.MultiHostMiddleware', 'corsheaders.middleware.CorsMiddleware', 'workbench.middlewares.SocialAuthExceptionMiddleware', 'workbench.disable.DisableCSRF', 'anafero.middleware.SessionJumpingMiddleware', 'axes.middleware.FailedLoginMiddleware', 'workbench.middlewares.CustomCookieMiddleWare' )

My social-auth pipeline is as follows:

SOCIAL_AUTH_PIPELINE = ( 'social.pipeline.social_auth.social_details', 'social.pipeline.social_auth.social_uid', 'social.pipeline.social_auth.auth_allowed', 'social.pipeline.social_auth.social_user', 'social.pipeline.user.get_username', 'social.pipeline.social_auth.associate_by_email', 'social.pipeline.user.create_user', 'social.pipeline.social_auth.associate_user', 'social.pipeline.social_auth.load_extra_data', 'social.pipeline.user.user_details', 'useraccounts.models.create_user_profile' )

When 'useraccounts.models.create_user_profile' does following: request = kwargs.get('request') do_something(session_key=request.session.session_key)

Following error comes: 'QueryDict' object has no attribute 'session'

'Request' dictionary has elements with following keys: state, code, prompt, session_state, authuser

I am using Django version 1.5.5. The problem is coming since I have upgraded python-social-auth from v0.1.17 to v0.2.4 and there is no code change.

omab commented 7 years ago

Django 1.5.5 is too old, this lib won't be supporting anything older than the last Django LTS (currently 1.8), but if you need the request, you can access it by doing strategy.request.