Skip to content
Snippets Groups Projects
Commit 4f508978 authored by Alexander Pace's avatar Alexander Pace
Browse files

Fixed decoding error in cert subjects

API requests on AWS were returning a 500 Server Error, traced it
down to a bytes vs string conversion when retrieving the certificate
subject
parent 87d01ac3
No related branches found
No related tags found
1 merge request!29Python3
Pipeline #88935 failed
......@@ -221,6 +221,7 @@ class GraceDbX509FullCertAuthentication(GraceDbX509Authentication):
def authenticate(self, request):
raise ValueError(request)
# Make sure this request is directed to the API
if self.api_only and not is_api_request(request.path):
return None
......@@ -298,19 +299,22 @@ class GraceDbX509FullCertAuthentication(GraceDbX509Authentication):
@staticmethod
def get_certificate_subject_string(certificate):
subject = certificate.get_subject()
subject_decoded = [[word.decode("utf8") for word in sets]
for sets in subject.get_components()]
subject_string = '/' + "/".join(["=".join(c) for c in
subject.get_components()])
subject_decoded])
return subject_string
@staticmethod
def get_certificate_issuer_string(certificate):
issuer = certificate.get_issuer()
issuer_decoded = [[word.decode("utf8") for word in sets]
for sets in issuer.get_components()]
issuer_string = '/' + "/".join(["=".join(c) for c in
issuer.get_components()])
issuer_decoded])
return issuer_string
class GraceDbAuthenticatedAuthentication(authentication.BaseAuthentication):
"""
If user is already authenticated by the main Django middleware,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment