Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace use of built in smart_text for Django 4.2 #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ captured in the code. Testing with other OIDC providers has not been tested.

## Compatibility

This plugin is tested and used with Keycloak 11.0.0 and Django 2.2.x.
This plugin is tested and used with Keycloak 24.0.0 and Django 4.2.x.


## Quickstart
Expand Down
12 changes: 8 additions & 4 deletions bossoidc2/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from rest_framework.settings import import_from_string
from rest_framework.authentication import get_authorization_header

from django.utils.encoding import force_bytes, smart_text, smart_bytes
from django.utils.translation import ugettext as _
from django.utils import encoding
from django.utils.translation import gettext as _
from mozilla_django_oidc.auth import OIDCAuthenticationBackend

from bossoidc2.models import Keycloak as KeycloakModel
Expand All @@ -32,6 +32,10 @@
import json
import logging


def smart_text(in_string):
return encoding.smart_str(in_string)

def _log(child):
return logging.getLogger(__name__).getChild(child)

Expand Down Expand Up @@ -326,8 +330,8 @@ def retrieve_matching_jwk(self, token):
# match or is None.
if jwk['kid'] != smart_text(header.kid) and num_keys > 1:
continue
if 'alg' in jwk and jwk['alg'] != smart_text(header.alg):
raise SuspiciousOperation('alg values do not match.')
if 'alg' in jwk and jwk['alg'] != smart_text(header.alg) and num_keys > 1:
continue
key = jwk
if key is None:
raise SuspiciousOperation('Could not find a valid JWKS.')
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def read(filename):
if __name__ == '__main__':
setup(
name='boss-oidc2',
version='2.0.1',
version='2.0.2',
packages=find_packages(),
url='https://github.com/jhuapl-boss/boss-oidc2',
license="Apache Software License",
Expand All @@ -42,7 +42,6 @@ def read(filename):
'Operating System :: OS Independent',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.12',
],
)