<commit_before>import os
from social_core.backends.base import BaseAuth
from social_core.exceptions import AuthException
from hashlib import sha256
import hmac
from base64 import b64encode, b64decode
import urllib
import urlparse
from crm.models import Person
from django.conf import settings
from django.contrib.auth.models import User

from django.conf import settings

class DiscourseSSOAuth(BaseAuth):
    name = 'discourse'

    def auth_url(self):
        returnUrl = self.redirect_uri
        nonce = str(81098579)
        payload = "nonce="+nonce+"&return_sso_url="+returnUrl
        base64Payload = b64encode(payload)
        payloadSignature = hmac.new(settings.DISCOURSE_SSO_SECRET, base64Payload,
                sha256).hexdigest()
        encodedParams = urllib.urlencode({'sso': base64Payload, 'sig':
            payloadSignature})
        return settings.DISCOURSE_BASE_URL+"?"+encodedParams

    def get_user_id(self, details, response):
        return response['email'][0]

    def get_user_details(self, response):
        flattened = {}
        for (k, v) in response.iteritems():
            if len(v) > 0:
                flattened[k] = v[0]

        return {
            'username': flattened.get('username'),
            'email': flattened.get('email'),
            'name': flattened.get('name'),<commit_msg>organizer: auth: hardcode sso provider url into auth backend to match documentation<commit_after>import os
from social_core.backends.base import BaseAuth
from social_core.exceptions import AuthException
from hashlib import sha256
import hmac
from base64 import b64encode, b64decode
import urllib
import urlparse
from crm.models import Person
from django.conf import settings
from django.contrib.auth.models import User

from django.conf import settings

class DiscourseSSOAuth(BaseAuth):
    name = 'discourse'

    def auth_url(self):
        returnUrl = self.redirect_uri
        nonce = str(81098579)
        payload = "nonce="+nonce+"&return_sso_url="+returnUrl
        base64Payload = b64encode(payload)
        payloadSignature = hmac.new(settings.DISCOURSE_SSO_SECRET, base64Payload,
                sha256).hexdigest()
        encodedParams = urllib.urlencode({'sso': base64Payload, 'sig':
            payloadSignature})
        return settings.DISCOURSE_BASE_URL+"/session/sso_provider?"+encodedParams

    def get_user_id(self, details, response):
        return response['email'][0]

    def get_user_details(self, response):
        flattened = {}
        for (k, v) in response.iteritems():
            if len(v) > 0:
                flattened[k] = v[0]

        return {
            'username': flattened.get('username'),
            'email': flattened.get('email'),
            'name': flattened.get('name'),
{'fraction_non_alphanumeric': 0.09727767695099819, 'fraction_numerical': 0.02250453720508167, 'mean_word_length': 3.1506024096385543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '609534', 'n_tokens_mistral': 850, 'n_tokens_neox': 797, 'n_words': 196}