0

My pipline is below

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',
    'create_user_and_set_email_as_username',
    'social.pipeline.social_auth.associate_by_email',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
    )

The create_user_and_set_email_as_username is the function I built to do some extra things to the user. It's come to the stage where in that function I want to be able to kick out users who aren't using a particular oauth client. (We have some corporate customers who want to force their employees to use azure oauth2).

I can't figure out how to access the currently used backend in that function. IE what the person just clicked and what service they're trying to use. Tried pdb'ing and looking at the components of strategy but couldn't see anything useful there.

Am I even trying to do this in the right place?

How do I access what backend they're trying to use. Tried strategy.get_backends() but that the lists possible not the current one.

bungleofsketches
  • 554
  • 1
  • 7
  • 18

1 Answers1

0

I figured out what I'm meant to do.

say expected_oauth_provider is what you want them to use. Then in any function added to the pipeline you should be taking in **kwargs and can access what they're really using there.

 if expected_oauth_provider != kwargs.get('backend').name:
     return HttpResponse("You cannot use your companies accounts that are not " + rule.force_oauth_provider, status=405)
bungleofsketches
  • 554
  • 1
  • 7
  • 18