示例#1
0
def info(request, service, auth_token,
         template_name='api/sso/base.xml'):
    """
    Returns xml blob on the format.
    <result>
      <success>True|False</success>
      <error_code>ERROR_CODE</error_code>

      <user id="username">
        ...
      </user>
    </result>

    """

    user = models.get_user_from_token(auth_token)

    data = {}

    if user is None:
        data['success'] = False
        data['error_code'] = ErrorCodes.INFO_USER_NOT_AUTHENTICATED
    else:
        data['success'] = True
        data['user'] = user
        data['groups'] = _filter_groups(user, service)

    return render_to_response(template_name, data)
示例#2
0
def validate(request, service, auth_token):
    """
    Returns "rejected" on reject and "accepted/username" on accept
    """
    user = models.get_user_from_token(auth_token)

    if user is None:
        return HttpResponse(u'rejected')

    return HttpResponse(u'accepted/%s' % user.username)