Skip to content

Commit 4229300

Browse files
committed
changed default character set for client_id and client_secret generators, fixes #167 #170
1 parent 1425267 commit 4229300

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

oauth2_provider/generators.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from __future__ import absolute_import
2+
from __future__ import unicode_literals
3+
14
from oauthlib.common import generate_client_id as oauthlib_generate_client_id
5+
from oauthlib.common import UNICODE_ASCII_CHARACTER_SET
26

37
from .settings import oauth2_settings
48

59

6-
CLIENT_ID_CHARACTER_SET = r'_-.:;=?!@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
7-
8-
910
class BaseHashGenerator(object):
1011
"""
1112
All generators should extend this class overriding `.hash()` method.
@@ -20,13 +21,13 @@ def hash(self):
2021
Generate a client_id without colon char as in http://tools.ietf.org/html/rfc2617#section-2
2122
for Basic Authentication scheme
2223
"""
23-
client_id_charset = CLIENT_ID_CHARACTER_SET.replace(":", "")
24-
return oauthlib_generate_client_id(length=40, chars=client_id_charset)
24+
return oauthlib_generate_client_id(length=40, chars=UNICODE_ASCII_CHARACTER_SET)
2525

2626

2727
class ClientSecretGenerator(BaseHashGenerator):
2828
def hash(self):
29-
return oauthlib_generate_client_id(length=oauth2_settings.CLIENT_SECRET_GENERATOR_LENGTH, chars=CLIENT_ID_CHARACTER_SET)
29+
return oauthlib_generate_client_id(length=oauth2_settings.CLIENT_SECRET_GENERATOR_LENGTH,
30+
chars=UNICODE_ASCII_CHARACTER_SET)
3031

3132

3233
def generate_client_id():

0 commit comments

Comments
 (0)