Skip to content

Commit

Permalink
Revert "[refactor] Moved download crl-view to mixin #116"
Browse files Browse the repository at this point in the history
This reverts commit eca0b79.

This change is not really needed.
Downstream apps with more complex authentication and authorization
mechanism are recommended to reimplement the CRL download view.
  • Loading branch information
nemesifier committed Jun 2, 2021
1 parent eca0b79 commit c5a5acd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
17 changes: 14 additions & 3 deletions django_x509/base/admin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from django import forms
from django.conf.urls import url
from django.contrib.admin import ModelAdmin
from django.shortcuts import render
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.utils.html import format_html
from django.utils.translation import ngettext
from django.utils.translation import ugettext_lazy as _

from .mixin import CrlDownloadMixin
from django_x509 import settings as app_settings


class X509Form(forms.ModelForm):
Expand Down Expand Up @@ -96,7 +97,7 @@ def get_context(self, data, ca_count=0, cert_count=0):
return context


class AbstractCaAdmin(BaseAdmin, CrlDownloadMixin):
class AbstractCaAdmin(BaseAdmin):
list_filter = ['key_length', 'digest', 'created']
fields = [
'operation_type',
Expand Down Expand Up @@ -131,6 +132,16 @@ def get_urls(self):
url(r'^x509/ca/(?P<pk>[^/]+).crl$', self.crl_view, name='crl')
] + super().get_urls()

def crl_view(self, request, pk):
authenticated = request.user.is_authenticated
authenticated = authenticated() if callable(authenticated) else authenticated
if app_settings.CRL_PROTECTED and not authenticated:
return HttpResponse(_('Forbidden'), status=403, content_type='text/plain')
instance = get_object_or_404(self.model, pk=pk)
return HttpResponse(
instance.crl, status=200, content_type='application/x-pem-file'
)

def renew_ca(self, request, queryset):
if request.POST.get('post'):
renewed_rows = 0
Expand Down
17 changes: 0 additions & 17 deletions django_x509/base/mixin.py

This file was deleted.

0 comments on commit c5a5acd

Please sign in to comment.