Ejemplo n.º 1
0
def discourse_sso_login():
    if not main.app.config["ENABLE_SSO_FOR_DISCOURSE"]:
        return "Single-sign on for discourse forum is disabled by Exeris server configuration"

    payload = request.args["sso"]
    signature = request.args["sig"]
    sso_secret = main.app.config["DISCOURSE_SSO_SECRET"]

    try:
        sso_validate(payload, signature, sso_secret)
    except DiscourseError as e:
        return str(e.args)

    if g.player.confirmed_at is None:
        return "The email address of the {} is not yet confirmed".format(g.player.id)

    base64_encoded_payload = urllib.parse.unquote(payload)
    payload = urllib.parse.parse_qs(base64.b64decode(base64_encoded_payload).decode("utf8"))

    response_payload = sso_payload(sso_secret,
                                   nonce=payload["nonce"][0],
                                   email=g.player.email,
                                   external_id=g.player.id,
                                   username=g.player.id
                                   )

    return redirect(payload["return_sso_url"][0] + "?" + response_payload)
Ejemplo n.º 2
0
    def sync_sso(self, **kwargs):
        """

        expect sso_secret, name, username, email, external_id, avatar_url,
        avatar_force_update

        Args:
            **kwargs:

        Returns:

        """
        sso_secret = kwargs.pop("sso_secret")
        payload = sso_payload(sso_secret, **kwargs)
        return self._post("/admin/users/sync_sso?{0}".format(payload), **kwargs)
Ejemplo n.º 3
0
    def sync_sso(self, **kwargs):
        """

        expect sso_secret, name, username, email, external_id, avatar_url,
        avatar_force_update

        Args:
            **kwargs:

        Returns:

        """
        sso_secret = kwargs.pop('sso_secret')
        payload = sso_payload(sso_secret, **kwargs)
        return self._post('/admin/users/sync_sso?{0}'.format(payload), **kwargs)
Ejemplo n.º 4
0
 def sync_sso(self, **kwargs):
     # expect sso_secret, name, username, email, external_id, avatar_url, avatar_force_update
     sso_secret = kwargs.pop("sso_secret")
     payload = sso_payload(sso_secret, **kwargs)
     return self._post("/admin/users/sync_sso?{0}".format(payload), **kwargs)