Exemple #1
0
def res_code(request, vender, action, mode):
    """
    """
    authres = AuthRes.from_url(request.get_full_path())
    valid_state = authres.state == request.session["state"]
    if not valid_state:
        raise Exception("Invalid State")

    signon = None
    errors = None
    try:
        signon = SignOn.objects.get(state=authres.state)
        signon.response_object = authres
        signon.save()

        if authres.error:
            raise Exception("authres error")

        id_token = request_token(request, signon, vender)

        save_signon(request, signon)
        return bind(request, signon)

    except Exception, ex:
        errors = traceback.format_exc()
        if signon:
            signon.errors = errors
            signon.save()
Exemple #2
0
def res_implicit(request, vender, action, mode):
    """
    """
    authres = AuthRes.from_url(request.get_full_path())
    valid_state = authres.state == request.session["state"]
    if not valid_state:
        raise Exception("Invalid State")

    if not authres.id_token:
        raise Exception("No ID Token")

    signon = None
    errors = None
    try:
        signon = SignOn.objects.get(state=authres.state)

        # Save AuthRes
        signon.response_object = authres

        # Save Id Token
        id_token_string = signon.get_id_token_string()
        if id_token_string:
            id_token = IdToken.parse_siop_token(id_token_string)
            signon.verified = id_token.verified
            signon.id_token_object = id_token
            signon.subject = id_token.sub

        signon.save()

        if authres.error:
            raise Exception("authres error")

        save_signon(request, signon)
        return bind(request, signon)

    except Exception, ex:
        errors = traceback.format_exc()
        if signon:
            signon.errors = errors
            signon.save()