diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b65a4ae..b41b96eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,3 +43,13 @@ Refactored install_re2o.sh script. install_re2o.sh help ``` * The installation templates (LDIF files and `re2o/settings_locale.example.py`) have been changed to use `example.net` instead of `example.org` (more neutral and generic) + + + +## MR XXX: Cleanup and refactor API + +Activate HTTP Authorization passthrough in by adding the following in /etc/apache2/site-available/re2o.conf (example in install_utils/apache2/re2o.conf): +``` + WSGIPassAuthorization On +``` + diff --git a/api/serializers.py b/api/serializers.py index 608e077d..647f9d26 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -214,8 +214,6 @@ class ServiceSerializer(NamespacedHMSerializer): class ServiceLinkSerializer(NamespacedHMSerializer): - need_regen = serializers.BooleanField() - class Meta: model = machines.Service_link fields = ('service', 'server', 'last_regen', 'asked_regen', @@ -466,12 +464,13 @@ class WhitelistSerializer(NamespacedHMSerializer): class ServiceRegenSerializer(NamespacedHMSerializer): hostname = serializers.CharField(source='server.domain.name', read_only=True) service_name = serializers.CharField(source='service.service_type', read_only=True) + need_regen = serializers.BooleanField() class Meta: model = machines.Service_link fields = ('hostname', 'service_name', 'need_regen', 'api_url') extra_kwargs = { - 'api_url': {'view_name': 'servicelink-detail'} + 'api_url': {'view_name': 'serviceregen-detail'} } @@ -545,7 +544,7 @@ class ARecordSerializer(serializers.ModelSerializer): class AAAARecordSerializer(serializers.ModelSerializer): hostname = serializers.CharField(source='domain.name', read_only=True) - ipv6 = serializers.CharField(read_only=True) + ipv6 = Ipv6ListSerializer(many=True, read_only=True) class Meta: model = machines.Interface @@ -561,7 +560,7 @@ class CNAMERecordSerializer(serializers.ModelSerializer): fields = ('alias', 'hostname') -class DNSZonesSerializer(NamespacedHMSerializer): +class DNSZonesSerializer(serializers.ModelSerializer): soa = SOARecordSerializer() ns_records = NSRecordSerializer(many=True, source='ns_set') originv4 = OriginV4RecordSerializer(source='origin') @@ -577,7 +576,4 @@ class DNSZonesSerializer(NamespacedHMSerializer): model = machines.Extension fields = ('name', 'soa', 'ns_records', 'originv4', 'originv6', 'mx_records', 'txt_records', 'srv_records', 'a_records', - 'aaaa_records', 'cname_records', 'api_url') - extra_kwargs = { - 'api_url': {'view_name': 'dnszone-detail'} - } + 'aaaa_records', 'cname_records') diff --git a/api/urls.py b/api/urls.py index 8138facb..57ce1e12 100644 --- a/api/urls.py +++ b/api/urls.py @@ -86,12 +86,13 @@ router.register(r'users/listrights', views.ListRightViewSet) router.register(r'users/shells', views.ShellViewSet, base_name='shell') router.register(r'users/bans', views.BanViewSet) router.register(r'users/whitelists', views.WhitelistViewSet) -# DNS -router.register(r'dns/zones', views.DNSZonesViewSet, base_name='dnszone') +# SERVICES REGEN +router.register(r'services/regen', views.ServiceRegenViewSet, base_name='serviceregen') + urlpatterns = [ url(r'^', include(router.urls)), url(r'^dhcp/hostmacip', views.HostMacIpView.as_view()), - url(r'^services/regen', views.ServiceRegenView.as_view()), + url(r'^dns/zones', views.DNSZonesView.as_view()), url(r'^token-auth', views.ObtainExpiringAuthToken.as_view()) ] diff --git a/api/views.py b/api/views.py index 36061deb..b290d578 100644 --- a/api/views.py +++ b/api/views.py @@ -160,7 +160,7 @@ class ServiceViewSet(viewsets.ReadOnlyModelViewSet): serializer_class = serializers.ServiceSerializer -class ServiceLinkViewSet(viewsets.ModelViewSet): +class ServiceLinkViewSet(viewsets.ReadOnlyModelViewSet): queryset = machines.Service_link.objects.all() serializer_class = serializers.ServiceLinkSerializer @@ -316,7 +316,7 @@ class WhitelistViewSet(viewsets.ReadOnlyModelViewSet): # Services views -class ServiceRegenView(generics.ListAPIView): +class ServiceRegenViewSet(viewsets.ModelViewSet): serializer_class = serializers.ServiceRegenSerializer def get_queryset(self): @@ -340,7 +340,7 @@ class HostMacIpView(generics.ListAPIView): # DNS views -class DNSZonesViewSet(viewsets.ReadOnlyModelViewSet): +class DNSZonesView(generics.ListAPIView): queryset = machines.Extension.objects.all() serializer_class = serializers.DNSZonesSerializer