python3: encoding variations in idp_oidc
This commit is contained in:
parent
05af4ef140
commit
d781f02fc4
|
@ -35,7 +35,7 @@ from . import app_settings
|
|||
|
||||
|
||||
def base64url(content):
|
||||
return base64.urlsafe_b64encode(content).strip('=')
|
||||
return base64.urlsafe_b64encode(content).strip(b'=')
|
||||
|
||||
|
||||
def get_jwkset():
|
||||
|
@ -66,7 +66,8 @@ def make_idtoken(client, claims):
|
|||
'''Make a serialized JWT targeted for this client'''
|
||||
if client.idtoken_algo == client.ALGO_HMAC:
|
||||
header = {'alg': 'HS256'}
|
||||
jwk = JWK(kty='oct', k=base64url(client.client_secret.encode('utf-8')))
|
||||
k=base64url(client.client_secret.encode('utf-8'))
|
||||
jwk = JWK(kty='oct', k=force_text(k))
|
||||
elif client.idtoken_algo == client.ALGO_RSA:
|
||||
header = {'alg': 'RS256'}
|
||||
jwk = get_first_rsa_sig_key()
|
||||
|
|
|
@ -24,6 +24,7 @@ import time
|
|||
from django.http import (HttpResponse, HttpResponseBadRequest,
|
||||
HttpResponseNotAllowed, JsonResponse)
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.timezone import now, utc
|
||||
from django.utils.http import urlencode
|
||||
from django.shortcuts import render
|
||||
|
@ -368,7 +369,7 @@ def authenticate_client(request, client=None):
|
|||
if authorization[0] != 'Basic' or len(authorization) != 2:
|
||||
return None
|
||||
try:
|
||||
decoded = base64.b64decode(authorization[1])
|
||||
decoded = force_text(base64.b64decode(authorization[1]))
|
||||
except Base64Error:
|
||||
return None
|
||||
parts = decoded.split(':')
|
||||
|
|
Loading…
Reference in New Issue