Exemplo n.º 1
0
def validate_domain_in_entityid(entity, doc, user=None):
    """
    Makes sure the entityid url belongs to the domain of the entity
    """
    errors, metadata = _parse_metadata(doc)
    if errors:
        return errors

    domain = entity.domain.name
    if user is None:
        user = entity.domain.owner

    url = urlparse.urlparse(metadata.entityid)
    if not check_superdomain_verified(url.netloc.lower(), user=user):
        errors.append(u'The entityid does not belong to the domain %s'
                      u' or to any of its subdomains.' % domain)

    return errors
Exemplo n.º 2
0
def validate_domain_in_entityid(entity, doc, user=None):
    """
    Makes sure the entityid url belongs to the domain of the entity
    """
    errors, metadata = _parse_metadata(doc)
    if errors:
        return errors

    domain = entity.domain.name
    if user is None:
        user = entity.domain.owner

    url = urlparse.urlparse(metadata.entityid)
    if not check_superdomain_verified(url.netloc.lower(), user=user):
        errors.append(
            u'The entityid does not belong to the domain %s'
            u' or to any of its subdomains.' % domain)

    return errors
Exemplo n.º 3
0
def validate_domain_in_endpoints(entity, doc, user=None):
    """
    Makes sure the endpoints urls belongs to the domain of the entity
    """
    errors, metadata = _parse_metadata(doc)
    if errors:
        return errors

    domain = entity.domain.name
    if user is None:
        user = entity.domain.owner

    for endpoint in metadata.endpoints:
        if 'Location' in endpoint:
            url = urlparse.urlparse(endpoint['Location'])
            if not check_superdomain_verified(url.hostname.lower(), user=user):
                errors.append(
                    u'The endpoint at %s does not belong to the domain %s'
                    u' or to any of its subdomains.' %
                    (endpoint['Location'], domain))

    return errors
Exemplo n.º 4
0
def validate_domain_in_endpoints(entity, doc, user=None):
    """
    Makes sure the endpoints urls belongs to the domain of the entity
    """
    errors, metadata = _parse_metadata(doc)
    if errors:
        return errors

    domain = entity.domain.name
    if user is None:
        user = entity.domain.owner

    for endpoint in metadata.endpoints:
        if 'Location' in endpoint:
            url = urlparse.urlparse(endpoint['Location'])
            if not check_superdomain_verified(url.hostname.lower(), user=user):
                errors.append(
                    u'The endpoint at %s does not belong to the domain %s'
                    u' or to any of its subdomains.' %
                    (endpoint['Location'], domain))

    return errors
Exemplo n.º 5
0
def domain_add(request):
    if request.method == 'POST':
        form = DomainForm(request.POST)
        if form.is_valid():
            messages.success(request, _(u'Domain created'))
            instance = form.save(commit=False)
            instance.owner = request.user
            if check_superdomain_verified(instance):
                return _domain_validate(request, instance)
            instance.save()
            return HttpResponseRedirect(
                reverse('domain_verify',
                        kwargs={'domain_id': instance.id}))
        else:
            messages.error(request, _('Please correct the errors'
                                      ' indicated below'))

    else:
        form = DomainForm()

    return render_to_response('domain/add.html', {
        'form': form,
    }, context_instance=RequestContext(request))
Exemplo n.º 6
0
def domain_add(request):
    if request.method == 'POST':
        form = DomainForm(request.POST)
        if form.is_valid():
            messages.success(request, _(u'Domain created'))
            instance = form.save(commit=False)
            instance.owner = request.user
            if check_superdomain_verified(instance):
                return _domain_validate(request, instance)
            instance.save()
            return HttpResponseRedirect(
                reverse('domain_verify',
                        kwargs={'domain_id': instance.id}))
        else:
            messages.error(request, _('Please correct the errors'
                                      ' indicated below'))

    else:
        form = DomainForm()

    return render_to_response('domain/add.html', {
        'form': form,
    }, context_instance=RequestContext(request))